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

#
# TH calling program
#

# TH programs & descriptions
set TH_App(browseth) {Teach traversal, scrolling and selection commands to widgets}
set TH_App(busyth) {Teach an application to indicate when it is busy with some operation}
set TH_App(commandeth) {Teach remote programs to prompt the user for wish or shell commands}
set TH_App(completh) {Teach many different types of completion to textual widgets}
set TH_App(cth) {Teach text widgets to format C comments and functions}
set TH_App(edith) {Teach basic text editing commands to widgets}
set TH_App(filebrowseth) {Turn text widgets into simple file/directory browsers}
set TH_App(fileth) {Teach file I/O to widgets}
set TH_App(focuth) {Teach keyboard focus switching between widgets}
set TH_App(gridth) {Add row and column numbers to text, listbox and entry widgets}
set TH_App(historyth) {Teach remote entries to remember their previous contents}
set TH_App(htmlth) {Teach text widgets to format HTML}
set TH_App(iterath) {Teach widgets to iterate commands many times at once}
set TH_App(lispth) {Teach text widgets to format Lisp comments and functions}
set TH_App(marketh) {Teach text widgets to let the user highlight various ranges of text}
set TH_App(makebeth) {Create Elsbeth full-scale text editor from Els, bare-bones file browser}
set TH_App(multh) {Teach multiple widgets of same class to work with each other}
set TH_App(painth) {Teach text widgets to paint special words}
set TH_App(paragrath) {Teach text widgets about paragraphs}
set TH_App(parenth) {Teach widgets to help keep parentheses and other delimiters balanced}
set TH_App(resizeth) {Teach widgets to shrink and expand themselves}
set TH_App(searcheth) {Teach widgets to search for strings, glob patterns, or regular expressions}
set TH_App(scrolleth) {Add and remove scrollbars to scrollable widgets}
set TH_App(taggeth) {Add a menu of tags to a text widget}
set TH_App(tclth) {Teach text widgets to format Tcl comments and procedures}
set TH_App(windowth) {Teach programs to resize, move, raise, and iconify their windows}

set Number_Of_Frames 4

foreach pair {{th_history_sanity_check lib/history.tcl}
		{get_widget aux/teach.tcl}
		{th_Misc_menus lib/tk.tcl}} {
  if {[info procs [lindex $pair 0]] == ""} {
    source "[file dirname [info script]]/../[lindex $pair 1]"
}}

set Help "" ; append Help {Teacher Hypertools

This is a simple wish script designed to itemize the Teacher Hypertools
available. From this window, you can execute any hypertool available. Here
are the widgets shown:


XF Location Label and Entry

This contains the location for the source code to XF. TH attempts to read
your XF_DIR environment variable for this value, otherwise it uses a value
supplied in lib/th.tcl. Some programs, like configureth, use XF's template
procedures to allow the user more power in selecting colors, fonts, etc.

Note that this entry, as well as the others have the historyth extension (the
menu and button to their left), so you can save old values in the entry and
retrieve them later. See the historyth help page for more info.


Arguments Menu, Button, and Entry

This contains the arguments sent to whatever hypertool you call. Any hypertool
can be called with no arguments, and a hypertool will ignore any arguments
it doesn't understand. 


Hypertools Buttons

Each button runs a different hypertool. When you pass the mouse over each button
a short description of the button's hypertool appears in the text widget.

} $TH_Help {

Bugs / Limitations

None
(I hope!)}


set env(XF_DIR) $XF_Dir
catch {destroy .buttons.source}
catch {destroy .buttons.teach}

create_form_entry .xf "Location of XF" env(XF_DIR)
lappend TH(Completions,.xf.e) {th_line_complete th_filter_glob none}
create_form_entry .args "Arguments" app_args ""

.output configure -state normal -wrap word -xscrollcommand {} -yscrollcommand {}
destroy .o.sx ; destroy .o.sy

for {set f 0} {$f < $Number_Of_Frames} {incr f} {
  frame .button$f
  pack .button$f -side left -fill both -expand yes
}

set i 0
set apps [lsort [array names TH_App]]
set l [llength $apps]
foreach app $apps {
  set w .button[expr ($i * $Number_Of_Frames) / $l ].$app
  incr i
  button $w -text "$app" -command "eval exec wish -f $TH_Dir/bin/$app \$app_args &"
  pack $w -side top -fill x
  bind $w <Any-Enter> "[bind Button <Any-Enter>] ; .output insert 1.0 [list $TH_App($app)]"
  bind $w <Any-Leave> "[bind Button <Any-Leave>] ; .output delete 1.0 end"
}
