#!/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 {Filebrowseth -- Add keybindings to browse among files and directories

This program teaches text widgets how to browse among different files and
directories.

} $TH_Bindings_Help {

Widgets of Filebrowseth

List Directory Command Entry

This entry is filled with the command to be executed when examining a directory,
which should probably be some variant of 'ls'.

} $TH_Frame_Help {

The Forward and Back commands keep the directory listing cached while working
within one directory. This means you can quickly scan through all the files in
one directory, and scan files in multiple directories, albeit more slowly. This
also means that the program is not aware of the directory's contents being
changed, unless you scan in a different directory first.}


# Gives app all the code necessary to do our functions.
proc teach_code {} {
  global Class FB_Command
  if {[lsearch "Text" $Class] < 0} {return ""}
  do_cmd_set TH(File,Browse,Command) $FB_Command
  include_files {file.browse.tcl th_up_file} \
	{file.Misc.tcl th_load_file} \
	{file.Text.tcl th_Text_insert_file} \
	{browse.Text.tcl th_Text_goto}
  do_cmd_set TH(Pipe,Enabled) 1
}

# For a widget, returns the appropriate bindings. (They will depend on the
# widget)
proc widget_bindings {} {
  global Bindings Class App Widget
  if {[lsearch "Text" $Class] < 0} {return ""}
  if {[send $App $Widget cget -state] == "disabled"} {return ""}
  return $Bindings(File,Browse)
}


create_form_entry .fbc "List Directory Command" FB_Command "|ls -lFa"
