# TH bindings (created by makebeth) for Entry widgets

set TH(Undo,Max,Entry) -1
set TH(Undo,Label,Max) 30
set TH(Pipe,Enabled) 1
set TH(File,Pad) 0
set TH(Binding,Search_Forward) <Control-s>
set TH(Menuentry,Search_Forward) {Forward 0}
set TH(Binding,Search_Backward) <Control-r>
set TH(Menuentry,Search_Backward) {Reverse 0}
set TH(Binding,Toggle_Case_Sensitivity) <Meta-Control-c>
set TH(Menuentry,Toggle_Case_Sensitivity) {"Case Inensitive" 0}
set TH(Binding,Toggle_Incremental_Search) <Meta-C>
set TH(Menuentry,Toggle_Incremental_Search) {"Incremental Search" 0}
set TH(Search,Select,Entry) sel
set TH(Search,Case,Implicit) 1
set TH(Binding,Replace_One) <Control-c>
set TH(Menuentry,Replace_One) {"Replace One" 8}
set TH(Binding,Replace_All) <Control-C>
set TH(Menuentry,Replace_All) {"Replace All" 8}
set TH(Completions,Entry) {{th_substring_replace th_string_tcl_result {[}} {th_substring_replace th_string_global_value {$}} {th_substring_replace th_string_glob_files { }} {th_substring_complete th_filter_cmds {[}} {th_substring_complete th_filter_vars {$}} {th_substring_complete th_filter_glob { }}}
set TH(Paren,Select,Entry) sel
set TH(Paren,Length) 30
set TH(Paren,Show,Entry) 0
th_Misc_paren_initialize Entry
th_Misc_paren_add Entry \[ \]
th_Misc_paren_add Entry \{ \}
th_Misc_paren_add Entry \( \)
bind Entry <Button-3> {th_toggle_menus %W}
bind Entry <Control-l> {th_scroll %W xview [expr [%W index insert] - (([%W index "@[winfo width %W]"] - [%W index @0]) / 2)]}
bind Entry <Control-b> {th_Entry_goto %W [expr [%W index insert] - 1]}
bind Entry <Control-f> {th_Entry_goto %W [expr [%W index insert] + 1]}
bind Entry <Meta-b> {th_Entry_goto %W [string wordstart [%W get] [expr [%W index insert] -1]]}
bind Entry <Meta-f> {th_Entry_goto %W [string wordend [%W get] [%W index insert]]}
bind Entry <Control-comma> {th_Entry_goto %W @0}
bind Entry <Control-period> {th_Entry_goto %W "@[winfo width %W]"}
bind Entry <Control-a> {th_Entry_goto %W 0}
bind Entry <Control-e> {th_Entry_goto %W end}
bind Entry <Control-L> {th_Entry_goto %W "@[expr [winfo width %W] / 2]"}
bind Entry <Control-K> {th_Entry_select_next_line %W}
bind Entry <Control-Shift-space> {%W selection to insert}
bind Entry <Control-slash> {%W selection range 0 end}
bind Entry <Control-space> {%W selection from [%W index insert]}
bind Entry <Control-x> {th_[winfo class %W]_exchange_mark %W}
bind Entry <Meta-g> {th_goto %W}
bind Entry <Control-backslash> {selection clear -displayof %W}
bind Entry <Meta-w> {if {[selection own -displayof %W] == "%W"} {
	    clipboard clear -displayof %W
	    clipboard append -displayof %W -- [selection get -displayof %W]}}
bind Entry <Meta-Z> {th_scroll %W xview scroll -1 units}
bind Entry <Control-Z> {th_scroll %W xview scroll  1 units}
bind Entry <Meta-asciitilde> {th_scroll %W xview scroll -1 pages}
bind Entry <Control-asciitilde> {th_scroll %W xview scroll  1 pages}
bind Entry <Control-g> {th_cancel_all %W}
bind Entry <Meta-Control-u> {th_[winfo class %W]_undo %W}
bind Entry <Meta-Control-l> {th_look_undo %W}
bind Entry <Meta-Control-k> {th_kill_undos %W}
bind Entry <Control-y> {th_paste_selection %W -selection CLIPBOARD}
bind Entry <Control-v> {th_paste_selection %W}
bind Entry <ButtonRelease-2> {if !$tkPriv(mouseMoved) {th_paste_selection %W}}
bind Entry <Control-q> {th_quote %W}
bind Entry <Control-w> {th_[winfo class %W]_kill_region %W}
foreach th_binding {<Control-BackSpace> <Delete>} {
 bind Entry $th_binding {th_[winfo class %W]_delete_selection %W}}
bind Entry <Meta-u> {th_[winfo class %W]_filter %W th_string_toupper}
bind Entry <Meta-l> {th_[winfo class %W]_filter %W th_string_tolower}
bind Entry <Meta-c> {th_[winfo class %W]_filter %W th_string_capitalize}
bind Entry <Control-t> {th_[winfo class %W]_transpose_chars %W}
bind Entry <Meta-t> {th_[winfo class %W]_transpose_words %W}
bind Entry <Control-c> {th_Entry_kill_range %W insert end}
bind Entry <Control-u> {th_Entry_kill_range %W 0 end}
foreach th_binding {<Control-h> <BackSpace>} {
 bind Entry $th_binding {th_Entry_delete_range %W [expr [%W index insert] - 1] insert 0}}
bind Entry <Control-d> {th_Entry_delete_range %W insert [expr [%W index insert] + 1] 0}
foreach th_binding {<Meta-h> <Meta-BackSpace>} {
 bind Entry $th_binding {th_Entry_delete_range %W [string wordstart [%W get] [expr [%W index insert] - 1]] insert}}
bind Entry <Meta-d> {th_Entry_delete_range %W insert [string wordend [%W get] [%W index insert]]}
bind Entry <Control-k> {th_Entry_delete_range %W insert end}
bind Entry <Meta-o> {th_checkbutton_variable Overwrite,%W}
bind Entry <Key> {th_[winfo class %W]_self_insert %W %A}
bind Entry <Meta-s> {th_save_file %W}
bind Entry <Meta-S> {th_save_file_prompt %W}
bind Entry <Meta-r> {th_read_file %W}
bind Entry <Meta-R> {th_read_file_prompt %W}
bind Entry <Meta-Control-r> {th_insert_file %W}
bind Entry <Enter> {th_check_mtime %W}
bind Entry <Meta-x> {th_[winfo class %W]_toggle_grid_x %W bottom}
bind Entry <Control-s> {th_Misc_search %W forward string}
bind Entry <Control-r> {th_Misc_search %W backward string}
bind Entry <Control-S> {th_Misc_search %W forward regexp}
bind Entry <Control-R> {th_Misc_search %W backward regexp}
bind Entry <Meta-C> {th_toggle_incremental_search %W}
bind Entry <Escape> {th_[winfo class %W]_complete_multiple %W [th_completions %W]}
bind Entry <Control-Escape> {th_[winfo class %W]_completion_dialog %W}
bind Entry <Meta-X> {th_toggle_scrollbar %W x bottom}
bind Entry <Meta-Y> {th_toggle_scrollbar %W y left}
bind Entry <Meta-space> {th_Misc_exp_check %W}
bind Entry <Key> {th_Misc_exp_check_self %W %A}
bind Entry <Meta-a> {th_[winfo class %W]_goto %W [th_Misc_left_exp %W]}
bind Entry <Meta-e> {th_[winfo class %W]_goto %W [th_Misc_right_exp %W]}
bind Entry <Meta-Shift-space> {th_Misc_select_exp %W}



proc th_Entry_menus {w} {
  th_Misc_menus $w
set code {

menubutton %W_mb.mb_browse -m %W_mb.mb_browse.m -text Browse -u 0
pack %W_mb.mb_browse -in %W_mb -side left
menu %W_mb.mb_browse.m
%W_mb.mb_browse.m add cascade -l Scroll -u 0 -m %W_mb.mb_browse.m.scroll
menu %W_mb.mb_browse.m.scroll
%W_mb.mb_browse.m.scroll add command -l {Center Cursor} -u 0 -acc {<Control-l>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_scroll %W xview [expr [%W index insert] - (([%W index "@[winfo width %W]"] - [%W index @0]) / 2)]}}
%W_mb.mb_browse.m add cascade -l Goto -u 0 -m %W_mb.mb_browse.m.goto
menu %W_mb.mb_browse.m.goto
%W_mb.mb_browse.m.goto add cascade -l Character -u 0 -m %W_mb.mb_browse.m.goto.character
menu %W_mb.mb_browse.m.goto.character
%W_mb.mb_browse.m.goto.character add command -l {Left} -u 0 -acc {<Control-b>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_goto %W [expr [%W index insert] - 1]}}
%W_mb.mb_browse.m.goto.character add command -l {Right} -u 0 -acc {<Control-f>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_goto %W [expr [%W index insert] + 1]}}
%W_mb.mb_browse.m.goto add cascade -l Word -u 0 -m %W_mb.mb_browse.m.goto.word
menu %W_mb.mb_browse.m.goto.word
%W_mb.mb_browse.m.goto.word add command -l {Left} -u 0 -acc {<Meta-b>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_goto %W [string wordstart [%W get] [expr [%W index insert] -1]]}}
%W_mb.mb_browse.m.goto.word add command -l {Right} -u 0 -acc {<Meta-f>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_goto %W [string wordend [%W get] [%W index insert]]}}
%W_mb.mb_browse.m.goto add cascade -l Screen -u 0 -m %W_mb.mb_browse.m.goto.screen
menu %W_mb.mb_browse.m.goto.screen
%W_mb.mb_browse.m.goto.screen add command -l {Left} -u 0 -acc {<Control-comma>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_goto %W @0}}
%W_mb.mb_browse.m.goto.screen add command -l {Right} -u 0 -acc {<Control-period>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_goto %W "@[winfo width %W]"}}
%W_mb.mb_browse.m.goto add cascade -l Edge -u 0 -m %W_mb.mb_browse.m.goto.edge
menu %W_mb.mb_browse.m.goto.edge
%W_mb.mb_browse.m.goto.edge add command -l {Left} -u 0 -acc {<Control-a>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_goto %W 0}}
%W_mb.mb_browse.m.goto.edge add command -l {Right} -u 0 -acc {<Control-e>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_goto %W end}}
%W_mb.mb_browse.m.goto add command -l {Center of Screen} -u 5 -acc {<Control-L>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_goto %W "@[expr [winfo width %W] / 2]"}}
%W_mb.mb_browse.m add cascade -l Select -u 1 -m %W_mb.mb_browse.m.select
menu %W_mb.mb_browse.m.select
%W_mb.mb_browse.m.select add command -l {Line} -u 0 -acc {<Control-K>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_select_next_line %W}}
%W_mb.mb_browse.m.select add command -l {Region} -u 0 -acc {<Control-Shift-space>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  %W selection to insert}}
%W_mb.mb_browse.m.select add command -l {All} -u 0 -acc {<Control-slash>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  %W selection range 0 end}}
%W_mb.mb_browse.m add command -l {Anchor} -u 0 -acc {<Control-space>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  %W selection from [%W index insert]}}
%W_mb.mb_browse.m.goto add command -l {Anchor} -u 0 -acc {<Control-x>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_exchange_mark %W}}
%W_mb.mb_browse.m.goto add command -l {Specify an Index} -u 11 -acc {<Meta-g>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_goto %W}}
%W_mb.mb_browse.m.select add command -l {Clear} -u 0 -acc {<Control-backslash>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  selection clear -displayof %W}}
%W_mb.mb_browse.m.select add command -l {Copy} -u 1 -acc {<Meta-w>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  if {[selection own -displayof %W] == "%W"} {
	    clipboard clear -displayof %W
	    clipboard append -displayof %W -- [selection get -displayof %W]}}}
%W_mb.mb_browse.m.scroll add cascade -l Line -u 0 -m %W_mb.mb_browse.m.scroll.line
menu %W_mb.mb_browse.m.scroll.line
%W_mb.mb_browse.m.scroll.line add command -l {Left} -u 0 -acc {<Meta-Z>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_scroll %W xview scroll -1 units}}
%W_mb.mb_browse.m.scroll.line add command -l {Right} -u 0 -acc {<Control-Z>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_scroll %W xview scroll  1 units}}
%W_mb.mb_browse.m.scroll add cascade -l Page -u 0 -m %W_mb.mb_browse.m.scroll.page
menu %W_mb.mb_browse.m.scroll.page
%W_mb.mb_browse.m.scroll.page add command -l {Left} -u 0 -acc {<Meta-asciitilde>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_scroll %W xview scroll -1 pages}}
%W_mb.mb_browse.m.scroll.page add command -l {Right} -u 0 -acc {<Control-asciitilde>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_scroll %W xview scroll  1 pages}}

menubutton %W_mb.mb_edit -m %W_mb.mb_edit.m -text Edit -u 0
pack %W_mb.mb_edit -in %W_mb -side left
menu %W_mb.mb_edit.m
%W_mb.mb_edit.m add cascade -l Undo -u 0 -m %W_mb.mb_edit.m.undo
menu %W_mb.mb_edit.m.undo
%W_mb.mb_edit.m.undo add command -l {Undo} -u 0 -acc {<Meta-Control-u>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_undo %W}}
%W_mb.mb_edit.m.undo add command -l {Show Last} -u 5 -acc {<Meta-Control-l>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_look_undo %W}}
%W_mb.mb_edit.m.undo add command -l {Kill Undo Log} -u 0 -acc {<Meta-Control-k>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_kill_undos %W}}
%W_mb.mb_edit.m add cascade -l Paste -u 0 -m %W_mb.mb_edit.m.paste
menu %W_mb.mb_edit.m.paste
%W_mb.mb_edit.m.paste add command -l {Clipboard} -u 0 -acc {<Control-y>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_paste_selection %W -selection CLIPBOARD}}
%W_mb.mb_edit.m.paste add command -l {Selection} -u 0 -acc {<Control-v>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_paste_selection %W}}
%W_mb.mb_edit.m add command -l {Quote} -u 0 -acc {<Control-q>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_quote %W}}
%W_mb.mb_edit.m add cascade -l Cut -u 0 -m %W_mb.mb_edit.m.cut
menu %W_mb.mb_edit.m.cut
%W_mb.mb_edit.m.cut add command -l {Region} -u 0 -acc {<Control-w>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_kill_region %W}}
%W_mb.mb_edit.m add cascade -l Delete -u 0 -m %W_mb.mb_edit.m.delete
menu %W_mb.mb_edit.m.delete
%W_mb.mb_edit.m.delete add command -l {Selection} -u 0 -acc {<Control-BackSpace>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_delete_selection %W}}
%W_mb.mb_edit.m add cascade -l Case -u 1 -m %W_mb.mb_edit.m.case
menu %W_mb.mb_edit.m.case
%W_mb.mb_edit.m.case add command -l {Upper} -u 0 -acc {<Meta-u>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_filter %W th_string_toupper}}
%W_mb.mb_edit.m.case add command -l {Lower} -u 0 -acc {<Meta-l>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_filter %W th_string_tolower}}
%W_mb.mb_edit.m.case add command -l {Capitalize} -u 0 -acc {<Meta-c>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_filter %W th_string_capitalize}}
%W_mb.mb_edit.m add cascade -l Transpose -u 0 -m %W_mb.mb_edit.m.transpose
menu %W_mb.mb_edit.m.transpose
%W_mb.mb_edit.m.transpose add command -l {Characters} -u 0 -acc {<Control-t>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_transpose_chars %W}}
%W_mb.mb_edit.m.transpose add command -l {Words} -u 0 -acc {<Meta-t>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_transpose_words %W}}
%W_mb.mb_edit.m.cut add command -l {Line} -u 0 -acc {<Control-c>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_kill_range %W insert end}}
%W_mb.mb_edit.m.cut add command -l {All} -u 0 -acc {<Control-u>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_kill_range %W 0 end}}
%W_mb.mb_edit.m.delete add cascade -l Character -u 0 -m %W_mb.mb_edit.m.delete.character
menu %W_mb.mb_edit.m.delete.character
%W_mb.mb_edit.m.delete.character add command -l {Previous} -u 0 -acc {<Control-h>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_delete_range %W [expr [%W index insert] - 1] insert 0}}
%W_mb.mb_edit.m.delete.character add command -l {Next} -u 0 -acc {<Control-d>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_delete_range %W insert [expr [%W index insert] + 1] 0}}
%W_mb.mb_edit.m.delete add cascade -l Word -u 0 -m %W_mb.mb_edit.m.delete.word
menu %W_mb.mb_edit.m.delete.word
%W_mb.mb_edit.m.delete.word add command -l {Previous} -u 0 -acc {<Meta-h>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_delete_range %W [string wordstart [%W get] [expr [%W index insert] - 1]] insert}}
%W_mb.mb_edit.m.delete.word add command -l {Next} -u 0 -acc {<Meta-d>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_delete_range %W insert [string wordend [%W get] [%W index insert]]}}
%W_mb.mb_edit.m.delete add command -l {Line} -u 0 -acc {<Control-k>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Entry_delete_range %W insert end}}
%W_mb.mb_edit.m add checkbutton -variable TH(Overwrite,%W)\
  -onvalue 1 -offvalue 0 -l {Toggle Overwrite} -u 7 -acc {<Meta-o>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_checkbutton_variable Overwrite,%W}}

menubutton %W_mb.mb_file -m %W_mb.mb_file.m -text File -u 0
pack %W_mb.mb_file -in %W_mb -side left
menu %W_mb.mb_file.m
%W_mb.mb_file.m add command -l {Save} -u 0 -acc {<Meta-s>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_save_file %W}}
%W_mb.mb_file.m add command -l {Save As} -u 5 -acc {<Meta-S>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_save_file_prompt %W}}
%W_mb.mb_file.m add command -l {Revert} -u 1 -acc {<Meta-r>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_read_file %W}}
%W_mb.mb_file.m add command -l {Read} -u 0 -acc {<Meta-R>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_read_file_prompt %W}}
%W_mb.mb_file.m add command -l {Insert} -u 0 -acc {<Meta-Control-r>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_insert_file %W}}
%W_mb.mb_file.m add checkbutton -variable TH(Pipe)\
  -onvalue 1 -offvalue 0 -l {Use a Pipe} -u 6 -acc {} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_checkbutton_variable Pipe}}
%W_mb.mb_window.m add checkbutton -variable TH(Grid_X,%W)\
  -onvalue 1 -offvalue 0 -l {Horizontal Grid} -u 0 -acc {<Meta-x>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_toggle_grid_x %W bottom}}

menubutton %W_mb.mb_search -m %W_mb.mb_search.m -text Search -u 0
pack %W_mb.mb_search -in %W_mb -side left
menu %W_mb.mb_search.m
%W_mb.mb_search.m add cascade -l String -u 0 -m %W_mb.mb_search.m.string
menu %W_mb.mb_search.m.string
%W_mb.mb_search.m.string add command -l {Forward} -u 0 -acc {<Control-s>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Misc_search %W forward string}}
%W_mb.mb_search.m.string add command -l {Reverse} -u 0 -acc {<Control-r>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Misc_search %W backward string}}
%W_mb.mb_search.m add cascade -l Regexp -u 0 -m %W_mb.mb_search.m.regexp
menu %W_mb.mb_search.m.regexp
%W_mb.mb_search.m.regexp add command -l {Forward} -u 0 -acc {<Control-S>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Misc_search %W forward regexp}}
%W_mb.mb_search.m.regexp add command -l {Reverse} -u 0 -acc {<Control-R>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Misc_search %W backward regexp}}
%W_mb.mb_search.m add checkbutton -variable TH(Search,Incremental,%W)\
  -onvalue 1 -offvalue 0 -l {Incremental Search} -u 0 -acc {<Meta-C>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_toggle_incremental_search %W}}
%W_mb.mb_extras.m add command -l {Complete} -u 0 -acc {<Escape>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_complete_multiple %W [th_completions %W]}}
%W_mb.mb_extras.m add command -l {Show Completions} -u 0 -acc {<Control-Escape>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_completion_dialog %W}}
%W_mb.mb_window.m add checkbutton -variable TH(Scrollbar,X,%W)\
  -onvalue 1 -offvalue 0 -l {X Scrollbar} -u 0 -acc {<Meta-X>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_toggle_scrollbar %W x bottom}}
%W_mb.mb_window.m add checkbutton -variable TH(Scrollbar,Y,%W)\
  -onvalue 1 -offvalue 0 -l {Y Scrollbar} -u 0 -acc {<Meta-Y>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_toggle_scrollbar %W y left}}
%W_mb.mb_extras.m add command -l {Check Expression} -u 0 -acc {<Meta-space>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Misc_exp_check %W}}
%W_mb.mb_browse.m.goto add cascade -l Expression -u 1 -m %W_mb.mb_browse.m.goto.expression
menu %W_mb.mb_browse.m.goto.expression
%W_mb.mb_browse.m.goto.expression add command -l {Left} -u 0 -acc {<Meta-a>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_goto %W [th_Misc_left_exp %W]}}
%W_mb.mb_browse.m.goto.expression add command -l {Right} -u 0 -acc {<Meta-e>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_goto %W [th_Misc_right_exp %W]}}
%W_mb.mb_browse.m.select add command -l {Expression} -u 1 -acc {<Meta-Shift-space>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_Misc_select_exp %W}}


}

global TH
regsub -all "%W_mb" $code $TH(Menubar,$w) new_code
regsub -all %W $new_code $w code
eval $code
}


