# Elsbeth bindings (created by makebeth)

set TH(Copyright) {Teacher Hypertools: Copyright (c) 1994,1995  David Svoboda}

bind Text <Key> {th_[winfo class %W]_self_insert %W %A}
bind Text <Key> {th_Misc_exp_check_self %W %A}



proc elsbeth_Text_instance {w} {set code {
set TH(Modified,%T) 0
pack [checkbutton %T_fm.fmb -relief flat -variable TH(Modified_Button,%T) -offvalue {} -onvalue {Modified} -indicatoron 0 -textvariable TH(Modified_Button,%T) -command {if {$TH(Modified_Button,%T) == ""} {set TH(Modified,%T) 0} else {set TH(Modified,%T) 1}}] -side left
trace variable TH(Modified,%T) w {th_modified_widget %T %T_fm.fmb}
pack [checkbutton %T_fm.fpl -textvariable TH(File,fpl,%T) -indicatoron 0 -variable TH(File,fpl,%T) -anchor e -onvalue {} -offvalue {-}] -side left
set TH(File,fpl,%T) {}
pack [checkbutton %T_fm.fnl -textvariable TH(File,fnl,%T) -indicatoron 0 -variable TH(File,fnl,%T) -anchor e -onvalue {} -offvalue {-}] -side left
set TH(File,fnl,%T) {}
set TH(Search,Select,Text) search
set TH(Search,Text,Tag) {-background yellow -foreground black}
set TH(Completions,Text) {{th_word_replace %T {}}}
set TH(Paren,Select,Text) paren
set TH(Paren,Text,Tag) {-background red}
set TH(Paren,Show,Text) 1
th_Misc_paren_initialize Text
th_Misc_paren_add Text \[ \]
th_Misc_paren_add Text \{ \}
th_Misc_paren_add Text \( \)

set TH(Completions,%T) {{th_word_replace %T {}}}
set TH(Completions,Text) {}
}
regsub -all %T $code $w new_code
uplevel #0 $new_code
}

set TH(Module,Code,elsbeth) {
set TH(Binding,Help) <Meta-Control-h>
set TH(Binding,Toggle_Menus) <Button-3>
bind Text <Meta-Control-x> {elsbeth_goto_file %W X}
bind Text <Meta-Control-h> {elsbeth_help %W}
bind Text <Meta-m> {elsbeth_make %W}
bind Text <Meta-Control-v> {elsbeth_visit_file %W}
foreach th_binding {<Meta-v> <Control-Double-Button-1>} {
 bind Text $th_binding {elsbeth_visit_file %W insert}}
bind Text <Meta-q> {elsbeth_destroy_text %W 0}
bind Text <Meta-Q> {elsbeth_destroy_text %W 1}



th_add_menucode %T {
th_Misc_paren_initialize Text
th_Misc_paren_add Text \[ \]
th_Misc_paren_add Text \{ \}
th_Misc_paren_add Text \( \)


%M_mb.mb_command.m.commands add command -l {Show X Selection} -u 5 -acc {<Meta-Control-x>} -co {if {![winfo exists %M]} {destroy %M_mb} else {
  elsbeth_goto_file %M X}}
%M_mb.mb_command.m.commands add command -l {Help} -u 0 -acc {<Meta-Control-h>} -co {if {![winfo exists %M]} {destroy %M_mb} else {
  elsbeth_help %M}}
%M_mb.mb_command.m.commands add command -l {Make} -u 0 -acc {<Meta-m>} -co {if {![winfo exists %M]} {destroy %M_mb} else {
  elsbeth_make %M}}
%M_mb.mb_file.m add command -l {Visit} -u 0 -acc {<Meta-Control-v>} -co {if {![winfo exists %M]} {destroy %M_mb} else {
  elsbeth_visit_file %M}}
%M_mb.mb_file.m add command -l {Visit Implicit} -u 4 -acc {<Meta-v>} -co {if {![winfo exists %M]} {destroy %M_mb} else {
  elsbeth_visit_file %M insert}}
%M_mb.mb_file.m add cascade -l Quit -u 0 -m %M_mb.mb_file.m.quit
menu %M_mb.mb_file.m.quit
%M_mb.mb_file.m.quit add command -l {Forget View} -u 0 -acc {<Meta-q>} -co {if {![winfo exists %M]} {destroy %M_mb} else {
  elsbeth_destroy_text %M 0}}
%M_mb.mb_file.m.quit add command -l {Remember View} -u 0 -acc {<Meta-Q>} -co {if {![winfo exists %M]} {destroy %M_mb} else {
  elsbeth_destroy_text %M 1}}


}}

