#!/afs/ece/usr/tcl/bin/wish -f
# The next line is executed by most shells, but not Tcl \
wish $0 $*


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

# Help text.
set Help "" ; append Help {Paragrath -- Add keybindings for standard paragraph manipulation and formatting.

This program teaches text widgets about paragraphs, including formating,
selection, and several other paragraph features.

} $TH_Bindings_Help {

Widgets of Paragrath
} $TH_Frame_Help {

When splitting, or reformatting paragraphs, paragrath will make each line as
long as possible so as to fit into the window. However, for indenting,
paragrath uses the text's -width option, which may not necessarily be the 
actual size of the window.}


# Gives app all the code necessary to do our functions.
proc teach_code {} {
  global Widget Class App
  if {$Class != "Text"} {return ""}
  include_files {paragraph.tcl th_para_begin} \
	{modes.tcl th_Text_tag_regions} \
	{edit.Text.tcl th_Text_indent} \
	{edit.Misc.tcl th_indent} \
	{browse.Text.tcl th_Text_select_range}

  if {[send $App $Widget cget -wrap] != "word"} {
    do_cmd "$Widget configure -wrap word\n" 0}
  do_cmd_set TH(Para,Narrow,$Widget) 1

  do_cmd_set TH(Paint,Hook,$Widget) "th_Text_tag_regions $Widget PARAGRAPH th_para_begin th_para_end th_para_next \$start \$end"
  do_cmd "$Widget tag configure PARAGRAPH -background MidnightBlue\n" 0
  do_cmd "$Widget tag raise sel\n" 0
}

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