#!/afs/ece/usr/tcl/bin/wish -f

set Bind_Keyword [file tail [info script]]
source "[file dirname [info script]]/../aux/frame.tcl"

# Help text.
set Help "" ; append Help {Htmlth -- Add keybindings for HTML files

This program teaches text widgets about HTML style, namely paragraphs (in the
actual widget, not in the HTML sense), and HTML anchors.

} $TH_Bindings_Help {

Widgets of Htmlth
} $TH_Frame_Help {
The paragraph tag is not always aligned to point only to paragraphs. This
shouldn't affect the appearance of the text, but the Tags menu may be screwey.
Doing an 'Update Paragraphs' (menu option under the Index menu) should fix this.
Likewise then anchor tag is not always aligned to point only to anchors.
Generally, hitting <Return> after closeing a new anchor should update the anchor
index. And the 'Update Anchors' menu option should fix discrepencies that
arise.
}


# Gives app all the code necessary to do our functions.
proc teach_code {app widget} {
  if {[widget_bindings $app $widget] == ""} {return ""}
  include_files $app {html.tcl th_anchor_begin} \
	{modes.tcl th_Text_tag_regions} \
	{paren.Misc.tcl th_Misc_paren_reeval} \
	{paren.Text.tcl th_Text_left_exp} \
	{edit.Text.tcl th_Text_delete_range} \
	{browse.Text.tcl th_Text_select_range}
  do_cmd $app "set TH(Exp,Angle,$widget) 1\n" 0
  do_cmd $app "set TH(Exp,Angle,$widget) 1\n" 0
  do_cmd $app "th_Misc_paren_reeval $widget\n" 0
  do_cmd $app "th_Text_tag_regions $widget anchor th_anchor_begin th_anchor_end th_anchor_next\n" 0
}

# For a widget, returns the appropriate bindings. (They will depend on the
# widget)
proc widget_bindings {app w} {
  global Bindings
  if {[send $app winfo class $w] != "Text"} {return ""}
  return [widget_frame_bindings $Bindings(Html)]
}


