#!/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 {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 {} {
  if {[widget_bindings] != ""} {
    global FB_Command
    do_cmd "set TH(File,Browse,Command) \{$FB_Command\}\n" 0
    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} \
	{search.Text.tcl th_Text_string_first}
    teach_frame_code
    do_cmd "set TH(Pipe,Enabled) 1\n" 0
}}

# 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 {[lindex [send $App $Widget configure -state] 4] == "disabled"} {return ""}
  return $Bindings(File,Browse)
}


create_form_entry .fbc "List Directory Command" FB_Command "| ls -l -F"


