#!/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 {Commandeth -- Add command execution capability to an application

This program teaches widgets how to execute wish or shell commands. They can
take the input and give the output back to any widget, although they work best with Text widgets.

} $TH_Bindings_Help {

Widgets of Commandeth

Temporary File Entry

The command module uses a temporary file to do exec commands. This specifies a
good name to use for this temporary file.


Print Command

This specifies the default command value for the print command. Note that in
the default form, the user should enter a string to be the title of the
printout.


Mail Command

This specifies the default command value for the mail command. Note that in the
default form, the user should enter a string to be the subject of the message,
and then add one or more recipients for the message to be mailed to.

} $TH_Frame_Help {

You might wish to alter the print and mail commands to handle text with
extra-long lines, tag markups, bindings, etc.}


# Gives app all the code necessary to do our functions.
proc teach_code {} {
  global Class

  include_files {command.tcl th_cmd_wish} \
	[list "edit.$Class.tcl" "th_[set Class]_undoable_insert"] \
	[list "browse.$Class.tcl" "th_[set Class]_goto"]
  teach_frame_code

  global Tmpfile Print Mail
  do_cmd_set TH(Cmd,Default,Print) $Print
  do_cmd_set TH(Cmd,Default,Mail) $Mail
  do_cmd_set TH(Tmpfile) $Tmpfile
}

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


create_form_entry .cmdtmp "Temporary File" Tmpfile "/tmp/th.cmd.tmp"
lappend TH(Completions,.cmdtmp.e) {th_line_complete th_filter_glob none}
create_form_entry .cmdprint "Print Command" Print "| lpr -m -p -T "
create_form_entry .cmdmail "Mail Command" Mail "| mail -s "
