00001 # TKE - Advanced Programmer's Editor
00002 # Copyright (C) 2014-2019 Trevor Williams (phase1geo@gmail.com)
00003 #
00004 # This program is free software; you can redistribute it and/or modify
00005 # it under the terms of the GNU General Public License as published by
00006 # the Free Software Foundation; either version 2 of the License, or
00007 # (at your option) any later version.
00008 #
00009 # This program is distributed in the hope that it will be useful,
00010 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00012 # GNU General Public License for more details.
00013 #
00014 # You should have received a copy of the GNU General Public License along
00015 # with this program; if not, write to the Free Software Foundation, Inc.,
00016 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017
00018 ######################################################################
00019 # Name: menus.tcl
00020 # Author: Trevor Williams (phase1geo@gmail.com)
00021 # Date: 5/11/2013
00022 # Brief: Namespace containing menu functionality
00023 ######################################################################
00024
00025 namespace eval menus {
00026
00027 variable profile_report [file join $::tke_home profiling_report.log]
00028 variable show_split_pane 0
00029 variable show_birdseye 0
00030 variable indent_mode "IND+"
00031 variable last_devel_mode ""
00032 variable line_numbering "absolute"
00033 variable code_folding 0
00034 variable line_wrapping 0
00035 variable sync_panes 0
00036
00037 array set profiling_info {}
00038
00039 trace add variable preferences::prefs(Debug/DevelopmentMode) write menus::handle_development_mode
00040
00041 #######################
00042 # PUBLIC PROCEDURES #
00043 #######################
00044
00045 ######################################################################
00046 # Returns the menu associated with the given menu path. The menu path
00047 # should be a list where each menu item is the name of the menu within
00048 # the path. The final menu in the path should not be included in the
00049 # path.
00050 proc get_menu {menu_path} {
00051
00052 set parent .menubar
00053
00054 foreach mnu $menu_path {
00055 if {([set mnu_index [$parent index [msgcat::mc $mnu]]] eq "none") || ([$parent type $mnu_index] ne "cascade")} {
00056 return -code error "Invalid menu path specified"
00057 }
00058 set parent [$parent entrycget $mnu_index -menu]
00059 }
00060
00061 return $parent
00062
00063 }
00064
00065 ######################################################################
00066 # Returns the menu index for the final menu item. The value of tail
00067 # must be the non-translated string value.
00068 proc get_menu_index {mnu tail} {
00069
00070 if {[string range $tail end-2 end] eq "..."} {
00071 set tail [msgcat::mc [string range $tail 0 end-3]]...
00072 } else {
00073 set tail [msgcat::mc $tail]
00074 }
00075
00076 return [$mnu index $tail]
00077
00078 }
00079
00080 ######################################################################
00081 # Set the pane sync indicator to the given value (0 or 1).
00082 proc set_pane_sync_indicator {value} {
00083
00084 variable sync_panes
00085
00086 set sync_panes $value
00087
00088 }
00089
00090 ######################################################################
00091 # Invokes the given index in the given menu, executing the menu's postcommand
00092 # if one exists.
00093 proc invoke {mnu index} {
00094
00095 # If the menubar is disabled, don't allow any menu invocations
00096 if {[.menubar entrycget 0 -state] eq "disabled"} {
00097 return
00098 }
00099
00100 # If the menu contains a postcommand, execute it first
00101 if {[$mnu cget -postcommand] ne ""} {
00102 eval [$mnu cget -postcommand]
00103 }
00104
00105 # Next, invoke the menu
00106 $mnu invoke $index
00107
00108 }
00109
00110 ######################################################################
00111 # Sets the given state on all menus in the menubar.
00112 proc set_state {state} {
00113
00114 set last [.menubar index end]
00115
00116 for {set i 0} {$i <= $last} {incr i} {
00117 .menubar entryconfigure $i -state $state
00118 }
00119
00120 }
00121
00122 ######################################################################
00123 # Checks to see if the focus is currently on a text widget and, if it is,
00124 # executes the given command.
00125 proc text_only {cmd args} {
00126
00127 if {[set has_focus [focus]] ne ""} {
00128 gui::get_info {} current txt txt2
00129 if {($has_focus eq "$txt.t") || ($has_focus eq "$txt2.t")} {
00130 uplevel #0 [list $cmd {*}$args]
00131 }
00132 }
00133
00134 }
00135
00136 ######################################################################
00137 # Checks to see if the current keyboard focus is coming from the main
00138 # window and, if it is, executes the given command.
00139 proc main_only {cmd args} {
00140
00141 if {[focus] ne ""} {
00142 uplevel #0 [list $cmd {*}$args]
00143 }
00144
00145 }
00146
00147 ######################################################################
00148 # Handles any changes to the Debug/DevelopmentMode preference value.
00149 proc handle_development_mode {{name1 ""} {name2 ""} {op ""}} {
00150
00151 variable last_devel_mode
00152
00153 # If the menubar does not exist, we have nothing further to do
00154 if {![winfo exists .menubar]} {
00155 return
00156 }
00157
00158 # Get the development mode
00159 if {[set devel_mode [::tke_development]] ne $last_devel_mode} {
00160
00161 # Delete the development tools if they exist but we are no longer in development mode
00162 if {$devel_mode} {
00163
00164 set mb ".menubar.tools"
00165 $mb add separator
00166 $mb add command -label [msgcat::mc "Export Custom Themes"] -command [list themes::export_custom]
00167 $mb add separator
00168 $mb add command -label [msgcat::mc "Start Profiling"] -underline 0 -command [list menus::start_profiling_command $mb]
00169 $mb add command -label [msgcat::mc "Stop Profiling"] -underline 1 -command [list menus::stop_profiling_command $mb 1] -state disabled
00170 $mb add command -label [msgcat::mc "Show Last Profiling Report"] -underline 5 -command [list menus::show_last_profiling_report]
00171 $mb add separator
00172 $mb add command -label [msgcat::mc "Show Diagnostic Logfile"] -underline 5 -command "logger::view_log"
00173 if {[preferences::get View/ShowConsole]} {
00174 $mb add command -label [msgcat::mc "Hide Tcl Console"] -underline 5 -command [list menus::hide_console_view $mb]
00175 } else {
00176 $mb add command -label [msgcat::mc "Show Tcl Console"] -underline 5 -command [list menus::show_console_view $mb]
00177 }
00178 $mb add separator
00179 $mb add command -label [format "%s %s" [msgcat::mc "Run"] "BIST"] -underline 4 -command "menus::run_bist"
00180 $mb add separator
00181 $mb add command -label [format "%s %s" [msgcat::mc "Restart"] "TKE"] -underline 0 -command "menus::restart_command"
00182
00183 launcher::register [make_menu_cmd "Tools" [msgcat::mc "Export Custom Themes"]] [list themes::export_custom]
00184 launcher::register [make_menu_cmd "Tools" [msgcat::mc "Start profiling"]] [list menus::start_profiling_command $mb]
00185 launcher::register [make_menu_cmd "Tools" [msgcat::mc "Stop profiling"]] [list menus::stop_profiling_command $mb 1]
00186 launcher::register [make_menu_cmd "Tools" [msgcat::mc "Show last profiling report"]] [list menus::show_last_profiling_report]
00187 launcher::register [make_menu_cmd "Tools" [msgcat::mc "Show diagnostic logfile"]] [list logger::view_log]
00188 launcher::register [make_menu_cmd "Tools" [msgcat::mc "Show Tcl console"]] [list menus::show_console_view $mb]
00189 launcher::register [make_menu_cmd "Tools" [msgcat::mc "Hide Tcl console"]] [list menus::hide_console_view $mb]
00190 launcher::register [make_menu_cmd "Tools" [format "%s %s" [msgcat::mc "Run"] "BIST"]] [list menus::run_bist]
00191 launcher::register [make_menu_cmd "Tools" [format "%s %s" [msgcat::mc "Restart"] "TKE"]] [list menus::restart_command]
00192
00193 # If profiling was enabled at startup, disable start and enable stop
00194 if {$::cl_profile} {
00195 $mb entryconfigure [msgcat::mc "Start Profiling"] -state disabled
00196 $mb entryconfigure [msgcat::mc "Stop Profiling"] -state normal
00197 }
00198
00199 set mb ".menubar.plugins"
00200 $mb insert 3 separator
00201 $mb insert 4 command -label [format "%s..." [msgcat::mc "Create"]] -underline 0 -command [list menus::main_only plugins::create_new_plugin]
00202 $mb insert 6 command -label [format "%s..." [msgcat::mc "Export"]] -underline 0 -command [list menus::main_only plugins::export]
00203 $mb insert 7 command -label [msgcat::mc "Show plugins directory in sidebar"] -command [list menus::main_only plugins::show_iplugins]
00204
00205 launcher::register [make_menu_cmd "Plugins" [msgcat::mc "Create new plugin"]] [list menus::main_only plugins::create_new_plugin]
00206 launcher::register [make_menu_cmd "Plugins" [msgcat::mc "Export current plugin"]] [list menus::main_only plugins::export]
00207 launcher::register [make_menu_cmd "Plugins" [msgcat::mc "Show plugin source directory in sidebar"]] [list menus::main_only plugins::show_iplugins]]
00208
00209 set mb ".menubar.help"
00210 $mb insert 2 separator
00211 $mb insert 3 command -label [msgcat::mc "Plugin Developer Guide"] -underline 0 -command [list menus::main_only menus::help_devel_guide]
00212
00213 launcher::register [make_menu_cmd "Help" [msgcat::mc "Show plugin developer guide"]] [list menus::main_only menus::help_devel_guide]
00214
00215 } elseif {$last_devel_mode ne ""} {
00216
00217 set mb ".menubar.tools"
00218 set index [$mb index [msgcat::mc "Start Profiling"]]
00219 $mb delete [expr $index - 1] end
00220 launcher::unregister [make_menu_cmd "Tools" [msgcat::mc "Start profiling"]] * *
00221 launcher::unregister [make_menu_cmd "Tools" [msgcat::mc "Stop profiling"]] * *
00222 launcher::unregister [make_menu_cmd "Tools" [msgcat::mc "Show last profiling report"]] * *
00223 launcher::unregister [make_menu_cmd "Tools" [msgcat::mc "Show diagnostic logfile"]] * *
00224 launcher::unregister [make_menu_cmd "Tools" [msgcat::mc "Show Tcl console"]] * *
00225 launcher::unregister [make_menu_cmd "Tools" [msgcat::mc "Hide Tcl console"]] * *
00226 launcher::unregister [make_menu_cmd "Tools" [format "%s %s" [msgcat::mc "Run"] "BIST"]] * *
00227 launcher::unregister [make_menu_cmd "Tools" [format "%s %s" [msgcat::mc "Restart"] "TKE"]] * *
00228
00229 set mb ".menubar.plugins"
00230 $mb delete 6
00231 $mb delete 3 4
00232 launcher::unregister [make_menu_cmd "Plugins" [msgcat::mc "Create new plugin"]] * *
00233 launcher::unregister [make_menu_cmd "Plugins" [msgcat::mc "Export current plugin"]] * *
00234
00235 set mb ".menubar.help"
00236 $mb delete 2 3
00237 launcher::unregister [make_menu_cmd "Help" [msgcat::mc "Show plugin developer guide"]] * *
00238
00239 }
00240
00241 # Store the development mode
00242 set last_devel_mode $devel_mode
00243
00244 }
00245
00246 }
00247
00248 ######################################################################
00249 # Creates the main menu.
00250 proc create {} {
00251
00252 set foreground [utils::get_default_foreground]
00253 set background [utils::get_default_background]
00254
00255 set mb [menu .menubar -foreground $foreground -background $background -relief flat -tearoff false]
00256
00257 # Add the file menu
00258 $mb add cascade -label [msgcat::mc "File"] -menu [make_menu $mb.file -tearoff false -postcommand "menus::file_posting $mb.file"]
00259 add_file $mb.file
00260
00261 # Add the edit menu
00262 $mb add cascade -label [msgcat::mc "Edit"] -menu [make_menu $mb.edit -tearoff false -postcommand "menus::edit_posting $mb.edit"]
00263 add_edit $mb.edit
00264
00265 # Add the find menu
00266 $mb add cascade -label [msgcat::mc "Find"] -menu [make_menu $mb.find -tearoff false -postcommand "menus::find_posting $mb.find"]
00267 add_find $mb.find
00268
00269 # Add the view menu
00270 $mb add cascade -label [msgcat::mc "View"] -menu [make_menu $mb.view -tearoff false -postcommand "menus::view_posting $mb.view"]
00271 add_view $mb.view
00272
00273 # Add the tools menu
00274 $mb add cascade -label [msgcat::mc "Tools"] -menu [make_menu $mb.tools -tearoff false -postcommand "menus::tools_posting $mb.tools"]
00275 add_tools $mb.tools
00276
00277 # Add the sessions menu
00278 $mb add cascade -label [msgcat::mc "Sessions"] -menu [make_menu $mb.sessions -tearoff false -postcommand "menus::sessions_posting $mb.sessions"]
00279 add_sessions $mb.sessions
00280
00281 # Add the plugins menu
00282 $mb add cascade -label [msgcat::mc "Plugins"] -menu [make_menu $mb.plugins -tearoff false -postcommand "menus::plugins_posting $mb.plugins"]
00283 add_plugins $mb.plugins
00284
00285 # If we are running on Mac OS X, add the window menu with the windowlist package
00286 if {[tk windowingsystem] eq "aqua"} {
00287
00288 # Add the window menu with the windowlist package
00289 windowlist::windowMenu $mb
00290
00291 # Add the launcher command to show the about window
00292 launcher::register [make_menu_cmd "Help" [format "%s %s" [msgcat::mc "About"] "TKE"]] gui::show_about
00293
00294 }
00295
00296 # Add the help menu
00297 $mb add cascade -label [msgcat::mc "Help"] -menu [make_menu $mb.help -tearoff false -postcommand "menus::help_posting $mb.help"]
00298 add_help $mb.help
00299
00300 if {([tk windowingsystem] eq "aqua") || [preferences::get View/ShowMenubar]} {
00301 . configure -menu $mb
00302 }
00303
00304 # Handle the default development mode
00305 handle_development_mode
00306
00307 # Load and apply the menu bindings
00308 bindings::load
00309
00310 # Register the menubar for theming purposes if we are running on MacOSX
00311 if {[tk windowingsystem] ne "aqua"} {
00312 theme::register_widget $mb menus
00313 }
00314
00315 }
00316
00317 ########################
00318 # PRIVATE PROCEDURES #
00319 ########################
00320
00321 ######################################################################
00322 # Returns a menu that will be used in the main menu system.
00323 proc make_menu {w args} {
00324
00325 # Create the menu
00326 set mnu [menu $w {*}$args]
00327
00328 # Create menu binding that will allow us to Shift click menu items to
00329 # edit their shortcuts in the preferences window.
00330 bind $mnu <Control-Button-1> { menus::handle_menu_shift_click %W %y; break }
00331 bind $mnu <Control-ButtonRelease-1> { break }
00332
00333 return $mnu
00334
00335 }
00336
00337 ######################################################################
00338 # Handles menu shift click events. If the preference GUI is enabled,
00339 # automatically open preferences, display the Shortcuts panel and
00340 # set the selected menu for editing.
00341 proc handle_menu_shift_click {w y} {
00342
00343 # Unpost the menu (and all of its ancestors)
00344 catch { tk::MenuUnpost $w }
00345
00346 pref_ui::create "" "" shortcuts
00347 pref_ui::shortcut_edit_item [string map {# .} [lindex [split $w .] end]] [$w entrycget @$y -label]
00348
00349 }
00350
00351 ######################################################################
00352 # Returns the menu string with language support.
00353 proc make_menu_cmd {mnu lbl} {
00354
00355 return [format "%s %s: %s" [msgcat::mc $mnu] [msgcat::mc "Menu"] $lbl]
00356
00357 }
00358
00359 ######################################################################
00360 # Adds the file menu.
00361 proc add_file {mb} {
00362
00363 $mb delete 0 end
00364
00365 $mb add command -label [msgcat::mc "New Window"] -underline 4 -command [list menus::main_only menus::new_window_command]
00366 launcher::register [make_menu_cmd "File" [msgcat::mc "New window"]] [list menus::main_only menus::new_window_command]
00367
00368 $mb add command -label [msgcat::mc "New File"] -underline 0 -command [list menus::main_only menus::new_file_command]
00369 launcher::register [make_menu_cmd "File" [msgcat::mc "New file"]] [list menus::main_only menus::new_file_command]
00370
00371 $mb add command -label [format "%s..." [msgcat::mc "New From Template"]] -underline 9 -command [list menus::main_only templates::show_templates load_abs]
00372 launcher::register [make_menu_cmd "File" [msgcat::mc "New file from template"]] [list menus::main_only templates::show_templates load_abs]
00373
00374 $mb add separator
00375
00376 $mb add command -label [format "%s..." [msgcat::mc "Open File"]] -underline 0 -command [list menus::main_only menus::open_command]
00377 launcher::register [make_menu_cmd "File" [msgcat::mc "Open file"]] [list menus::main_only menus::open_command]
00378
00379 $mb add command -label [format "%s..." [msgcat::mc "Open Directory"]] -underline 5 -command [list menus::main_only menus::open_dir_command]
00380 launcher::register [make_menu_cmd "File" [msgcat::mc "Open directory"]] [list menus::main_only menus::open_dir_command]
00381
00382 $mb add command -label [format "%s..." [msgcat::mc "Open Remote"]] -underline 0 -command [list menus::main_only menus::open_remote_command]
00383 launcher::register [make_menu_cmd "File" [msgcat::mc "Open remote file or directory"]] [list menus::main_only menus::open_remote_command]
00384
00385 $mb add cascade -label [msgcat::mc "Open Recent"] -menu [make_menu $mb.recent -tearoff false -postcommand [list menus::file_recent_posting $mb.recent]]
00386 launcher::register [make_menu_cmd "File" [msgcat::mc "Open Recent"]] [list menus::launcher]
00387
00388 $mb add cascade -label [msgcat::mc "Open Favorite"] -menu [make_menu $mb.favorites -tearoff false -postcommand [list menus::file_favorites_posting $mb.favorites]]
00389 launcher::register [make_menu_cmd "File" [msgcat::mc "Open Favorite"]] [list favorites::launcher]
00390
00391 $mb add command -label [msgcat::mc "Reopen File"] -underline 0 -command [list menus::main_only gui::update_current]
00392 launcher::register [make_menu_cmd "File" [msgcat::mc "Reopen current file"]] [list menus::main_only gui::update_current]
00393
00394 $mb add separator
00395
00396 $mb add command -label [msgcat::mc "Change Working Directory"] -underline 0 -command [list menus::main_only menus::change_working_directory]
00397 launcher::register [make_menu_cmd "File" [msgcat::mc "Change working directory"]] [list menus::main_only menus::change_working_directory]
00398
00399 $mb add separator
00400
00401 $mb add command -label [msgcat::mc "Show File Difference"] -underline 3 -command [list menus::text_only menus::show_file_diff]
00402 launcher::register [make_menu_cmd "File" [msgcat::mc "Show file difference"]] [list menus::text_only menus::show_file_diff]
00403
00404 $mb add separator
00405
00406 $mb add command -label [msgcat::mc "Save"] -underline 0 -command [list menus::text_only menus::save_command]
00407 launcher::register [make_menu_cmd "File" [msgcat::mc "Save file"]] [list menus::text_only menus::save_command]
00408
00409 $mb add command -label [format "%s..." [msgcat::mc "Save As"]] -underline 5 -command [list menus::text_only menus::save_as_command]
00410 launcher::register [make_menu_cmd "File" [msgcat::mc "Save file as"]] [list menus::text_only menus::save_as_command]
00411
00412 $mb add command -label [format "%s..." [msgcat::mc "Save As Remote"]] -command [list menus::text_only menus::save_as_remote_command]
00413 launcher::register [make_menu_cmd "File" [msgcat::mc "Save file as remote file"]] [list menus::text_only menus::save_as_remote_command]
00414
00415 $mb add command -label [format "%s..." [msgcat::mc "Save As Template"]] -command [list menus::text_only templates::save_as]
00416 launcher::register [make_menu_cmd "File" [msgcat::mc "Save file as template"]] [list menus::text_only templates::save_as]
00417
00418 $mb add command -label [format "%s..." [msgcat::mc "Save Selection As"]] -underline 7 -command [list menus::text_only menus::save_selection_as_command]
00419 launcher::register [make_menu_cmd "File" [msgcat::mc "Save selected lines"]] [list menus::text_only menus::save_selection_as_command]
00420
00421 $mb add command -label [msgcat::mc "Save All"] -underline 6 -command [list menus::main_only gui::save_all]
00422 launcher::register [make_menu_cmd "File" [msgcat::mc "Save all files"]] [list menus::main_only gui::save_all]
00423
00424 $mb add separator
00425
00426 # Populate the export menu
00427 $mb add command -label [format "%s..." [msgcat::mc "Export"]] -command [list menus::text_only menus::export_command]
00428 launcher::register [make_menu_cmd "File" [msgcat::mc "Export file contents"]] [list menus::text_only menus::export_command]
00429
00430 $mb add separator
00431
00432 $mb add cascade -label [msgcat::mc "Encoding"] -menu [gui::create_encoding_menu $mb.encode]
00433 $mb add cascade -label [msgcat::mc "Line Ending"] -menu [make_menu $mb.eolPopup -tearoff 0 -postcommand [list menus::file_eol_posting $mb.eolPopup]]
00434
00435 $mb add separator
00436
00437 $mb add command -label [msgcat::mc "Rename"] -underline 4 -command [list menus::text_only menus::rename_command]
00438 launcher::register [make_menu_cmd "File" [msgcat::mc "Rename current file"]] [list menus::text_only menus::rename_command]
00439
00440 $mb add command -label [msgcat::mc "Duplicate"] -underline 1 -command [list menus::text_only menus::duplicate_command]
00441 launcher::register [make_menu_cmd "File" [msgcat::mc "Duplicate current file"]] [list menus::text_only menus::duplicate_command]
00442
00443 $mb add command -label [msgcat::mc "Delete"] -underline 0 -command [list menus::text_only menus::delete_command]
00444 launcher::register [make_menu_cmd "File" [msgcat::mc "Delete current file"]] [list menus::text_only menus::delete_command]
00445
00446 $mb add separator
00447
00448 $mb add command -label [msgcat::mc "Lock"] -underline 0 -command [list menus::text_only menus::lock_command $mb]
00449 launcher::register [make_menu_cmd "File" [msgcat::mc "Lock file"]] [list menus::text_only menus::lock_command $mb]
00450 launcher::register [make_menu_cmd "File" [msgcat::mc "Unlock file"]] [list menus::text_only menus::unlock_command $mb]
00451
00452 $mb add command -label [msgcat::mc "Favorite"] -underline 0 -command [list menus::text_only menus::favorite_command $mb]
00453 launcher::register [make_menu_cmd "File" [msgcat::mc "Favorite file"]] [list menus::text_only menus::favorite_command $mb]
00454 launcher::register [make_menu_cmd "File" [msgcat::mc "Unfavorite file"]] [list menus::text_only menus::unfavorite_command $mb]
00455
00456 $mb add separator
00457
00458 $mb add command -label [msgcat::mc "Close"] -underline 0 -command [list menus::text_only menus::close_command]
00459 launcher::register [make_menu_cmd "File" [msgcat::mc "Close current tab"]] [list menus::text_only menus::close_command]
00460
00461 $mb add command -label [msgcat::mc "Close All"] -underline 6 -command [list menus::main_only menus::close_all_command]
00462 launcher::register [make_menu_cmd "File" [msgcat::mc "Close all tabs"]] [list menus::main_only menus::close_all_command]
00463
00464 # Only add the quit menu to File if we are not running in aqua
00465 if {[tk windowingsystem] ne "aqua"} {
00466 $mb add separator
00467 $mb add command -label [msgcat::mc "Quit"] -underline 0 -command [list menus::exit_command]
00468 }
00469 launcher::register [make_menu_cmd "File" [msgcat::mc "Quit application"]] [list menus::exit_command]
00470
00471 # Populate the end-of-line menu
00472 $mb.eolPopup add radiobutton -label "Windows" -variable menus::line_ending -value "crlf" -command [list menus::text_only gui::set_current_eol_translation crlf]
00473 launcher::register [make_menu_cmd "File" [msgcat::mc "Set current file line ending to CRLF for Windows"]] [list menus::text_only gui::set_current_eol_translation crlf]
00474
00475 $mb.eolPopup add radiobutton -label "Unix" -variable menus::line_ending -value "lf" -command [list menus::text_only gui::set_current_eol_translation lf]
00476 launcher::register [make_menu_cmd "File" [msgcat::mc "Set current file line ending to LF for Unix"]] [list menus::text_only gui::set_current_eol_translation lf]
00477
00478 $mb.eolPopup add radiobutton -label [msgcat::mc "Classic Mac"] -variable menus::line_ending -value "cr" -command [list menus::text_only gui::set_current_eol_translation cr]
00479 launcher::register [make_menu_cmd "File" [msgcat::mc "Set current file line ending to CR for Classic Mac"]] [list menus::text_only gui::set_current_eol_translation cr]
00480
00481 }
00482
00483 ######################################################################
00484 # Called prior to the file menu posting.
00485 proc file_posting {mb} {
00486
00487 # Get information for current file
00488 if {![catch { gui::get_info {} current fileindex fname readonly lock diff buffer modified remote }]} {
00489
00490 # Get state if the file is a buffer
00491 set buffer_state [expr {($buffer || $diff) ? "disabled" : "normal"}]
00492
00493 # Get the state if the current editing buffer is a difference buffer
00494 set diff_state [expr {$diff ? "disabled" : "normal"}]
00495
00496 # Get the state for items that are not valid for remote files
00497 set no_remote_state [expr {($remote eq "") ? $buffer_state : "disabled"}]
00498
00499 # Get the current favorite status
00500 set favorite [favorites::is_favorite $fname]
00501
00502 # Configure the Lock/Unlock menu item
00503 if {$lock} {
00504 if {![catch { $mb index [msgcat::mc "Lock"] } index]} {
00505 $mb entryconfigure $index -label [msgcat::mc "Unlock"] -state $diff_state -command [list menus::text_only menus::unlock_command $mb]
00506 }
00507 $mb entryconfigure [msgcat::mc "Unlock"] -state [expr {$readonly ? "disabled" : $diff_state}]
00508 } else {
00509 if {![catch { $mb index [msgcat::mc "Unlock"] } index]} {
00510 $mb entryconfigure $index -label [msgcat::mc "Lock"] -state $diff_state -command [list menus::text_only menus::lock_command $mb]
00511 }
00512 $mb entryconfigure [msgcat::mc "Lock"] -state [expr {$readonly ? "disabled" : $diff_state}]
00513 }
00514
00515 # Configure the Favorite/Unfavorite menu item
00516 if {$favorite} {
00517 if {![catch { $mb index [msgcat::mc "Favorite"] } index]} {
00518 $mb entryconfigure $index -label [msgcat::mc "Unfavorite"] -command [list menus::text_only menus::unfavorite_command $mb]
00519 }
00520 $mb entryconfigure [msgcat::mc "Unfavorite"] -state [expr {(($fname ne "") && !$diff) ? $no_remote_state : "disabled"}]
00521 } else {
00522 if {![catch { $mb index [msgcat::mc "Unfavorite"] } index]} {
00523 $mb entryconfigure $index -label [msgcat::mc "Favorite"] -command [list menus::text_only menus::favorite_command $mb]
00524 }
00525 $mb entryconfigure [msgcat::mc "Favorite"] -state [expr {(($fname ne "") && !$diff) ? $no_remote_state : "disabled"}]
00526 }
00527
00528 # Configure the Delete/Move To Trash
00529 if {($remote eq "") && [preferences::get General/UseMoveToTrash]} {
00530 if {![catch { $mb index [msgcat::mc "Delete"] } index]} {
00531 $mb entryconfigure $index -label [msgcat::mc "Move To Trash"] -command [list menus::text_only menus::move_to_trash_command]
00532 }
00533 $mb entryconfigure [msgcat::mc "Move To Trash"] -state $buffer_state
00534 } else {
00535 if {![catch { $mb index [msgcat::mc "Move To Trash"] } index]} {
00536 $mb entryconfigure $index -label [msgcat::mc "Delete"] -command [list menus::text_only menus::delete_command]
00537 }
00538 $mb entryconfigure [msgcat::mc "Delete"] -state $buffer_state
00539 }
00540
00541 # Make sure that the file-specific items are enabled
00542 $mb entryconfigure [msgcat::mc "Reopen File"] -state $buffer_state
00543 $mb entryconfigure [msgcat::mc "Show File Difference"] -state $no_remote_state
00544 $mb entryconfigure [msgcat::mc "Save"] -state [expr {$modified ? $diff_state : "disabled"}]
00545 $mb entryconfigure [format "%s..." [msgcat::mc "Save As"]] -state $diff_state
00546 $mb entryconfigure [format "%s..." [msgcat::mc "Save As Remote"]] -state $diff_state
00547 $mb entryconfigure [format "%s..." [msgcat::mc "Save As Template"]] -state $diff_state
00548 $mb entryconfigure [format "%s..." [msgcat::mc "Save Selection As"]] -state [expr {[gui::selected] ? "normal" : "disabled"}]
00549 $mb entryconfigure [msgcat::mc "Save All"] -state normal
00550 $mb entryconfigure [format "%s..." [msgcat::mc "Export"]] -state $diff_state
00551 $mb entryconfigure [msgcat::mc "Line Ending"] -state $diff_state
00552 $mb entryconfigure [msgcat::mc "Rename"] -state $buffer_state
00553 $mb entryconfigure [msgcat::mc "Duplicate"] -state $buffer_state
00554 $mb entryconfigure [msgcat::mc "Close"] -state normal
00555 $mb entryconfigure [msgcat::mc "Close All"] -state normal
00556
00557 } else {
00558
00559 # Disable file menu items associated with current tab (since one doesn't currently exist)
00560 $mb entryconfigure [msgcat::mc "Reopen File"] -state disabled
00561 $mb entryconfigure [msgcat::mc "Show File Difference"] -state disabled
00562 $mb entryconfigure [msgcat::mc "Save"] -state disabled
00563 $mb entryconfigure [format "%s..." [msgcat::mc "Save As"]] -state disabled
00564 $mb entryconfigure [format "%s..." [msgcat::mc "Save As Remote"]] -state disabled
00565 $mb entryconfigure [format "%s..." [msgcat::mc "Save As Template"]] -state disabled
00566 $mb entryconfigure [format "%s..." [msgcat::mc "Save Selection As"]] -state disabled
00567 $mb entryconfigure [msgcat::mc "Save All"] -state disabled
00568 $mb entryconfigure [format "%s..." [msgcat::mc "Export"]] -state disabled
00569 $mb entryconfigure [msgcat::mc "Line Ending"] -state disabled
00570 $mb entryconfigure [msgcat::mc "Rename"] -state disabled
00571 $mb entryconfigure [msgcat::mc "Duplicate"] -state disabled
00572 $mb entryconfigure [msgcat::mc "Delete"] -state disabled
00573 $mb entryconfigure [msgcat::mc "Lock"] -state disabled
00574 $mb entryconfigure [msgcat::mc "Favorite"] -state disabled
00575 $mb entryconfigure [msgcat::mc "Close"] -state disabled
00576 $mb entryconfigure [msgcat::mc "Close All"] -state disabled
00577
00578 }
00579
00580 $mb entryconfigure [format "%s..." [msgcat::mc "New From Template"]] -state [expr {[templates::valid] ? "normal" : "disabled"}]
00581
00582 # Configure the Open Recent menu
00583 if {([preferences::get View/ShowRecentlyOpened] == 0) || (([llength [gui::get_last_opened]] == 0) && ([llength [sidebar::get_last_opened]] == 0))} {
00584 $mb entryconfigure [msgcat::mc "Open Recent"] -state disabled
00585 } else {
00586 $mb entryconfigure [msgcat::mc "Open Recent"] -state normal
00587 }
00588
00589 # Configure the Open Favorite menu
00590 if {[llength [favorites::get_list]] == 0} {
00591 $mb entryconfigure [msgcat::mc "Open Favorite"] -state disabled
00592 } else {
00593 $mb entryconfigure [msgcat::mc "Open Favorite"] -state normal
00594 }
00595
00596 }
00597
00598 ######################################################################
00599 # Sets up the "Open Recent" menu prior to it being posted.
00600 proc file_recent_posting {mb} {
00601
00602 # Clear the menu
00603 $mb delete 0 end
00604
00605 # Populate the menu with the directories
00606 if {[llength [set sdirs [sidebar::get_last_opened]]] > 0} {
00607 $mb add command -label [msgcat::mc "Recent Directories"] -state disabled
00608 foreach sdir [lrange $sdirs 0 [expr [preferences::get View/ShowRecentlyOpened] - 1]] {
00609 $mb add command -label [format " %s" $sdir] -command [list sidebar::add_directory $sdir]
00610 }
00611 $mb add separator
00612 }
00613
00614 # Populate the menu with the filenames
00615 if {[llength [set fnames [gui::get_last_opened]]] > 0} {
00616 $mb add command -label [msgcat::mc "Recent Files"] -state disabled
00617 foreach fname [lrange $fnames 0 [expr [preferences::get View/ShowRecentlyOpened] - 1]] {
00618 $mb add command -label [format " %s" $fname] -command [list gui::add_file end $fname]
00619 }
00620 $mb add separator
00621 }
00622
00623 # Add "Clear All" menu option
00624 $mb add command -label [msgcat::mc "Clear All"] -command [list menus::main_only menus::clear_last_opened]
00625
00626 }
00627
00628 ######################################################################
00629 # Clears the last opened files and directories.
00630 proc clear_last_opened {} {
00631
00632 sidebar::clear_last_opened
00633 gui::clear_last_opened
00634
00635 }
00636
00637 ######################################################################
00638 # Updates the "Open Favorite" menu prior to it being posted.
00639 proc file_favorites_posting {mb} {
00640
00641 # Clear the menu
00642 $mb delete 0 end
00643
00644 # Populate the menu with the filenames from the favorite list
00645 foreach path [favorites::get_list] {
00646 if {[file isdirectory $path]} {
00647 $mb add command -label " $path" -command "sidebar::add_directory $path"
00648 } else {
00649 $mb add command -label " $path" -command "gui::add_file end $path"
00650 }
00651 }
00652
00653 }
00654
00655 ######################################################################
00656 # Called when the export file menu is posted.
00657 proc file_export_posting {mb} {
00658
00659 # TBD
00660
00661 }
00662
00663 ######################################################################
00664 # Called just prior to the EOL menu being posted.
00665 proc file_eol_posting {mb} {
00666
00667 variable line_ending
00668
00669 # Set the line_ending to the current line ending to use
00670 set line_ending [gui::get_info {} current eol]
00671
00672 }
00673
00674 ######################################################################
00675 # Starts a new session (window)
00676 proc new_window_command {} {
00677
00678 # Execute the restart command
00679 if {[file tail [info nameofexecutable]] eq "tke.exe"} {
00680 exec -ignorestderr [info nameofexecutable] -n &
00681 } else {
00682 array set frame [info frame 1]
00683 exec -ignorestderr [info nameofexecutable] $::argv0 -- -n &
00684 }
00685
00686 }
00687
00688 ######################################################################
00689 # Implements the "create new file" command.
00690 proc new_file_command {} {
00691
00692 gui::add_new_file end -sidebar 1
00693
00694 }
00695
00696 ######################################################################
00697 # Displays the templates in the command launcher.
00698 proc new_file_from_template {} {
00699
00700 templates::show_templates load_abs
00701
00702 }
00703
00704 ######################################################################
00705 # Opens a new file and adds a new tab for the file.
00706 proc open_command {} {
00707
00708 # Get the directory of the current file
00709 set dirname [gui::get_browse_directory]
00710
00711 if {[set ofiles [tk_getOpenFile -parent . -initialdir $dirname -filetypes [syntax::get_filetypes] -defaultextension .tcl -multiple 1]] ne ""} {
00712 foreach ofile $ofiles {
00713 gui::add_file end $ofile
00714 }
00715 }
00716
00717 }
00718
00719 ######################################################################
00720 # Opens a directory in the sidebar.
00721 proc open_dir_command {} {
00722
00723 # Get the directory of the current file
00724 set dirname [gui::get_browse_directory]
00725
00726 if {[set odir [tk_chooseDirectory -parent . -initialdir $dirname -mustexist 1]] ne ""} {
00727 sidebar::add_directory $odir
00728 }
00729
00730 }
00731
00732 ######################################################################
00733 # Opens one or more remote files in editing buffer(s).
00734 proc open_remote_command {} {
00735
00736 # Get the directory or file
00737 lassign [remote::create open] conn_name ofiles
00738
00739 # Add the files to the editing area
00740 foreach ofile $ofiles {
00741 if {[lassign $ofile fname]} {
00742 sidebar::add_directory $fname -remote $conn_name
00743 } else {
00744 gui::add_file end $fname -remote $conn_name
00745 }
00746 }
00747
00748 }
00749
00750 ######################################################################
00751 # Change the current working directory to a specified value.
00752 proc change_working_directory {} {
00753
00754 if {[set dir [tk_chooseDirectory -parent . -initialdir [gui::get_browse_directory] -mustexist 1]] ne ""} {
00755 gui::change_working_directory $dir
00756 }
00757
00758 }
00759
00760 ######################################################################
00761 # Displays the difference of the current file.
00762 proc show_file_diff {} {
00763
00764 # Get the current filename
00765 gui::get_info {} current fname
00766
00767 # Display the current file as a difference
00768 gui::add_file end $fname -diff 1 -other [preferences::get View/ShowDifferenceInOtherPane]
00769
00770 }
00771
00772 ######################################################################
00773 # Saves the current tab file.
00774 proc save_command {} {
00775
00776 gui::save_current -force 1
00777
00778 }
00779
00780 ######################################################################
00781 # Saves the current tab file as a new filename.
00782 proc save_as_command {} {
00783
00784 # Get some of the save options
00785 if {[set sfile [gui::prompt_for_save]] ne ""} {
00786 gui::save_current -force 1 -save_as $sfile
00787 }
00788
00789 }
00790
00791 ######################################################################
00792 # Saves the current tab file as a new filename on a remote server.
00793 proc save_as_remote_command {} {
00794
00795 set fname [file tail [gui::get_info {} current fname]]
00796
00797 lassign [remote::create save $fname] connection sfile
00798
00799 if {$sfile ne ""} {
00800 gui::save_current -force 1 -save_as $sfile -remote $connection
00801 }
00802
00803 }
00804
00805 ######################################################################
00806 # Saves the currently selected text to a new file.
00807 proc save_selection_as_command {} {
00808
00809 # Get the filename
00810 if {[set sfile [gui::prompt_for_save]] ne ""} {
00811
00812 # Get the current text widget
00813 set txt [gui::current_txt]
00814
00815 # Save the current selection
00816 edit::save_selection $txt [$txt index sel.first] [$txt index sel.last] 1 $sfile
00817
00818 }
00819
00820 }
00821
00822 ######################################################################
00823 # If the current editing buffer is using the Markdown language, exports
00824 # the contents of the buffer to HTML using the Markdown parser.
00825 proc export_command {} {
00826
00827 # Get the directory of the current file
00828 set dirname [gui::get_browse_directory]
00829
00830 # Get the current editing buffer
00831 set txt [gui::current_txt]
00832
00833 # Get the current editing buffer language
00834 set lang [syntax::get_language $txt]
00835
00836 # Create additional options to the getSaveFile call
00837 set opts [list]
00838 if {$lang eq "Markdown"} {
00839 if {[set ext [preferences::get General/DefaultMarkdownExportExtension]] ne ""} {
00840 set ext ".$ext"
00841 }
00842 lappend opts -initialfile [file rootname [file tail [gui::get_info $txt txt fname]]]$ext
00843 }
00844
00845 # Get the name of the file to output
00846 if {[set fname [tk_getSaveFile -parent . -title [msgcat::mc "Export As"] -initialdir $dirname {*}$opts]] eq ""} {
00847 return
00848 }
00849
00850 # Get the scrubbed contents of the current buffer
00851 set contents [gui::scrub_text $txt]
00852
00853 # Export the string contents
00854 if {[catch { utils::export $contents $lang $fname } rc]} {
00855 gui::set_error_message [msgcat::mc "Unable to write export file"]
00856 return
00857 }
00858
00859 # Let the user know that the operation has completed
00860 gui::set_info_message [msgcat::mc "Export complete"]
00861
00862 }
00863
00864 ######################################################################
00865 # Renames the current file.
00866 proc rename_command {} {
00867
00868 # Get the current name
00869 gui::get_info {} current fname remote
00870
00871 set old_name $fname
00872 set new_name $fname
00873 set selrange [utils::basename_range $fname]
00874
00875 # Get the new name from the user
00876 if {[gui::get_user_response [msgcat::mc "File Name:"] new_name -allow_vars 1 -selrange $selrange]} {
00877
00878 # If the value of the cell hasn't changed or is empty, do nothing else.
00879 if {($old_name eq $new_name) || ($new_name eq "")} {
00880 return
00881 }
00882
00883 if {[catch { files::rename_file $old_name $new_name $remote } new_name]} {
00884 gui::set_error_message [msgcat::mc "Unable to rename file"] $new_name
00885 return
00886 }
00887
00888 # Add the file directory
00889 sidebar::update_directory [sidebar::add_directory [file dirname $new_name] -remote $remote]
00890
00891 # Update the old directory
00892 if {[set sidebar_index [sidebar::get_index [file dirname $old_name] $remote]] ne ""} {
00893 sidebar::update_directory $sidebar_index
00894 }
00895
00896 }
00897
00898 }
00899
00900 ######################################################################
00901 # Duplicates the current file and adds the duplicated file to the editor.
00902 proc duplicate_command {} {
00903
00904 # Get the filename of the current selection
00905 gui::get_info {} current fname remote
00906
00907 # Create the default name of the duplicate file
00908 if {[catch { files::duplicate_file $fname $remote } dup_fname]} {
00909 gui::set_error_message "Unable to duplicate file" $dup_fname
00910 return
00911 }
00912
00913 # Add the file to the editor
00914 gui::add_file end $dup_fname -remote $remote
00915
00916 # Update the old directory
00917 if {[set sidebar_index [sidebar::get_index [file dirname $dup_fname] $remote]] ne ""} {
00918 sidebar::update_directory $sidebar_index
00919 }
00920
00921 }
00922
00923 ######################################################################
00924 # Deletes the current file from the file system and removes it from
00925 # editor.
00926 proc delete_command {} {
00927
00928 # Get the full pathname
00929 gui::get_info {} current fname remote
00930
00931 # Get confirmation from the user
00932 if {[tk_messageBox -parent . -type yesno -default yes -message [format "%s %s?" [msgcat::mc "Delete"] $fname]] eq "yes"} {
00933
00934 # Delete the file
00935 if {[catch { files::delete_file $fname $remote } rc]} {
00936 gui::set_error_message [msgcat::mc "Unable to delete file"] $rc
00937 return
00938 }
00939
00940 # Update the old directory
00941 if {[set sidebar_index [sidebar::get_index [file dirname $fname] $remote]] ne ""} {
00942 sidebar::update_directory $sidebar_index
00943 }
00944
00945 }
00946
00947 }
00948
00949 ######################################################################
00950 # Moves the current file to the trash.
00951 proc move_to_trash_command {} {
00952
00953 # Get the full pathname
00954 gui::get_info {} current fname
00955
00956 # Move the file to the trash
00957 if {[catch { files::move_to_trash $fname 0 }]} {
00958 return
00959 }
00960
00961 # Update the old directory
00962 if {[set sidebar_index [sidebar::get_index [file dirname $fname] ""]] ne ""} {
00963 sidebar::update_directory $sidebar_index
00964 }
00965
00966 }
00967
00968 ######################################################################
00969 # Locks the current file.
00970 proc lock_command {mb} {
00971
00972 # Lock the current file
00973 if {[gui::set_current_file_lock 1]} {
00974
00975 # Set the menu up to display the unlock file menu option
00976 $mb entryconfigure [msgcat::mc "Lock"] -label [msgcat::mc "Unlock"] -command [list menus::text_only menus::unlock_command $mb]
00977
00978 }
00979
00980 }
00981
00982 ######################################################################
00983 # Unlocks the current file.
00984 proc unlock_command {mb} {
00985
00986 # Unlock the current file
00987 if {[gui::set_current_file_lock 0]} {
00988
00989 # Set the menu up to display the lock file menu option
00990 $mb entryconfigure [msgcat::mc "Unlock"] -label [msgcat::mc "Lock"] -command [list menus::text_only menus::lock_command $mb]
00991
00992 }
00993
00994 }
00995
00996 ######################################################################
00997 # Marks the current file as a favorite.
00998 proc favorite_command {mb} {
00999
01000 # Get current file information
01001 gui::get_info {} current fileindex fname
01002
01003 # Get the current file index (if one exists)
01004 if {$fileindex != -1} {
01005
01006 # Add the file as a favorite
01007 if {[favorites::add $fname]} {
01008
01009 # Set the menu up to display the unfavorite file menu option
01010 $mb entryconfigure [msgcat::mc "Favorite"] -label [msgcat::mc "Unfavorite"] -command [list menus::text_only menus::unfavorite_command $mb]
01011
01012 }
01013
01014 }
01015
01016 }
01017
01018 ######################################################################
01019 # Marks the current file as not favorited.
01020 proc unfavorite_command {mb} {
01021
01022 # Get current file information
01023 gui::get_info {} current fileindex fname
01024
01025 # Get the current file index (if one exists)
01026 if {$fileindex != -1} {
01027
01028 # Remove the file as a favorite
01029 if {[favorites::remove $fname]} {
01030
01031 $mb entryconfigure [msgcat::mc "Unfavorite"] -label [msgcat::mc "Favorite"] -command [list menus::text_only menus::favorite_command $mb]
01032
01033 }
01034
01035 }
01036
01037 }
01038
01039 ######################################################################
01040 # Closes the current tab.
01041 proc close_command {} {
01042
01043 gui::close_current
01044
01045 }
01046
01047 ######################################################################
01048 # Closes all opened tabs.
01049 proc close_all_command {} {
01050
01051 gui::close_all -force 1
01052
01053 }
01054
01055 ######################################################################
01056 # Cleans up the application to prepare it for being exited.
01057 proc exit_cleanup {} {
01058
01059 # Close the themer if it is open
01060 themer::close_window 1
01061
01062 # Save the session information if we are not told to exit on close
01063 sessions::save "last"
01064
01065 # Close all of the tabs
01066 gui::close_all -exiting 1
01067
01068 # Force any panels that are waiting to stop waiting
01069 set gui::user_exit_status 0
01070
01071 # Save the clipboard history
01072 cliphist::save
01073
01074 # Close the opened remote connections
01075 remote::disconnect_all
01076
01077 # Handle on_quit plugins
01078 plugins::handle_on_quit
01079
01080 # Turn off profiling (if it was turned on)
01081 if {[::tke_development]} {
01082 stop_profiling_command .menubar.tools 0
01083 }
01084
01085 # Stop the logger
01086 logger::on_exit
01087
01088 }
01089
01090 ######################################################################
01091 # Exits the application.
01092 proc exit_command {} {
01093
01094 # Clean up the application (if there are any errors, ignore them)
01095 catch { exit_cleanup }
01096
01097 # If we are doing code coverage, call cleanup directly
01098 if {[namespace exists ::_instrument_]} {
01099 ::_instrument_::cleanup
01100 }
01101
01102 # Destroy the interface
01103 destroy .
01104
01105 }
01106
01107 ######################################################################
01108 # Adds the edit menu.
01109 proc add_edit {mb} {
01110
01111 # Add edit menu commands
01112 $mb add command -label [msgcat::mc "Undo"] -underline 0 -command [list menus::text_only gui::undo]
01113 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Undo"]] [list menus::text_only gui::undo]
01114
01115 $mb add command -label [msgcat::mc "Redo"] -underline 0 -command [list menus::text_only gui::redo]
01116 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Redo"]] [list menus::text_only gui::redo]
01117
01118 $mb add separator
01119
01120 $mb add command -label [msgcat::mc "Cut"] -underline 0 -command [list menus::text_only gui::cut]
01121 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Cut text"]] [list menus::text_only gui::cut]
01122
01123 $mb add command -label [msgcat::mc "Copy"] -underline 1 -command [list menus::text_only gui::copy]
01124 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Copy text"]] [list menus::text_only gui::copy]
01125
01126 $mb add command -label [msgcat::mc "Paste"] -underline 0 -command [list menus::text_only gui::paste]
01127 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Paste text from clipboard"]] [list menus::text_only gui::paste]
01128
01129 $mb add command -label [msgcat::mc "Paste and Format"] -underline 10 -command [list menus::text_only gui::paste_and_format]
01130 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Paste and format text from clipboard"]] [list menus::text_only gui::paste_and_format]
01131
01132 $mb add separator
01133
01134 $mb add cascade -label [msgcat::mc "Select"] -underline 0 -menu [make_menu $mb.selectPopup -tearoff 0 -postcommand [list menus::edit_select_posting $mb.selectPopup]]
01135
01136 $mb add command -label [msgcat::mc "Select Mode"] -underline 7 -command [list menus::text_only menus::select_mode]
01137 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Enter selection mode"]] [list menus::text_only menus::select_mode]
01138
01139 $mb add separator
01140
01141 $mb add checkbutton -label [msgcat::mc "Vim Mode"] -underline 0 -variable preferences::prefs(Editor/VimMode) -command [list menus::main_only vim::set_vim_mode_all]
01142 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Enable Vim mode"]] [list menus::main_only vim::set_vim_mode_all 1]
01143 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Disable Vim mode"]] [list menus::main_only vim::set_vim_mode_all 0]
01144
01145 $mb add separator
01146
01147 $mb add command -label [msgcat::mc "Toggle Comment"] -underline 0 -command [list menus::text_only edit::comment_toggle]
01148 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Toggle comment"]] [list menus::text_only edit::comment_toggle]
01149
01150 $mb add cascade -label [msgcat::mc "Indentation"] -underline 0 -menu [make_menu $mb.indentPopup -tearoff 0 -postcommand [list menus::edit_indent_posting $mb.indentPopup]]
01151 $mb add cascade -label [msgcat::mc "Cursor"] -underline 1 -menu [make_menu $mb.cursorPopup -tearoff 0 -postcommand [list menus::edit_cursor_posting $mb.cursorPopup]]
01152
01153 $mb add separator
01154
01155 $mb add cascade -label [msgcat::mc "Insert"] -menu [make_menu $mb.insertPopup -tearoff 0 -postcommand [list menus::edit_insert_posting $mb.insertPopup]]
01156 $mb add cascade -label [msgcat::mc "Transform"] -menu [make_menu $mb.transformPopup -tearoff 0 -postcommand [list menus::edit_transform_posting $mb.transformPopup]]
01157 $mb add cascade -label [msgcat::mc "Format"] -menu [make_menu $mb.formatPopup -tearoff 0 -postcommand [list menus::edit_format_posting $mb.formatPopup]]
01158
01159 $mb add separator
01160
01161 $mb add cascade -label [msgcat::mc "Snippets"] -menu [make_menu $mb.snipPopup -tearoff 0 -postcommand [list menus::edit_snippets_posting $mb.snipPopup]]
01162 $mb add cascade -label [msgcat::mc "Templates"] -menu [make_menu $mb.tempPopup -tearoff 0 -postcommand [list menus::edit_templates_posting $mb.tempPopup]]
01163 $mb add cascade -label "Emmet" -menu [make_menu $mb.emmetPopup -tearoff 0 -postcommand [list menus::edit_emmet_posting $mb.emmetPopup]]
01164
01165 $mb add separator
01166
01167 $mb add cascade -label [msgcat::mc "Preferences"] -menu [make_menu $mb.prefPopup -tearoff 0 -postcommand [list menus::edit_preferences_posting $mb.prefPopup]]
01168
01169 #########################
01170 # Populate selection menu
01171 #########################
01172
01173 $mb.selectPopup add command -label [msgcat::mc "All"] -underline 0 -command [list menus::text_only select::quick_select all]
01174 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Select all text"]] [list menus::text_only select::quick_select all]
01175
01176 $mb.selectPopup add command -label [msgcat::mc "Current Line"] -underline 8 -command [list menus::text_only select::quick_select line]
01177 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Select current line"]] [list menus::text_only select::quick_select line]
01178
01179 $mb.selectPopup add command -label [msgcat::mc "Current Word"] -underline 8 -command [list menus::text_only select::quick_select word]
01180 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Select current word"]] [list menus::text_only select::quick_select word]
01181
01182 $mb.selectPopup add command -label [msgcat::mc "Current Sentence"] -underline 8 -command [list menus::text_only select::quick_select sentence]
01183 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Select current sentence"]] [list menus::text_only select::quick_select sentence]
01184
01185 $mb.selectPopup add command -label [msgcat::mc "Current Paragraph"] -underline 8 -command [list menus::text_only select::quick_select paragraph]
01186 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Select current paragraph"]] [list menus::text_only select::quick_select paragraph]
01187
01188 $mb.selectPopup add command -label [msgcat::mc "Current Bounded Text"] -underline 8 -command [list menus::text_only select::quick_select bracket]
01189 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Select current bracketed text, strings or comment block"]] [list menus::text_only select::quick_select bracket]
01190
01191 $mb.selectPopup add separator
01192
01193 $mb.selectPopup add command -label [msgcat::mc "Add Next Line"] -underline 4 -command [list menus::text_only select::quick_add_line next]
01194 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Add next line to selection"]] [list menus::text_only select::quick_add_line next]
01195
01196 $mb.selectPopup add command -label [msgcat::mc "Add Previous Line"] -underline 5 -command [list menus::text_only select::quick_add_line prev]
01197 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Add previous line to selection"]] [list menus::text_only select::quick_add_line prev]
01198
01199 ###########################
01200 # Populate indentation menu
01201 ###########################
01202
01203 $mb.indentPopup add command -label [msgcat::mc "Indent"] -underline 0 -command [list menus::text_only menus::indent_command]
01204 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Indent selected text"]] [list menus::text_only menus::indent_command]
01205
01206 $mb.indentPopup add command -label [msgcat::mc "Unindent"] -underline 1 -command [list menus::text_only menus::unindent_command]
01207 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Unindent selected text"]] [list menus::text_only menus::unindent_command]
01208
01209 $mb.indentPopup add separator
01210
01211 $mb.indentPopup add command -label [msgcat::mc "Format Text"] -command [list menus::text_only gui::format_text]
01212 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Format indentation for text"]] [list menus::text_only gui::format_text]
01213
01214 $mb.indentPopup add separator
01215
01216 $mb.indentPopup add radiobutton -label [msgcat::mc "Indent Off"] -variable menus::indent_mode -value "OFF" -command [list menus::text_only indent::set_current_indent_mode OFF]
01217 launcher::register [make_menu_cmd "Edit" [format "%s %s" [msgcat::mc "Set indent mode to"] "OFF"]] [list menus::text_only indent::set_current_indent_mode OFF]
01218
01219 $mb.indentPopup add radiobutton -label [msgcat::mc "Auto-Indent"] -variable menus::indent_mode -value "IND" -command [list menus::text_only indent::set_current_indent_mode IND]
01220 launcher::register [make_menu_cmd "Edit" [format "%s %s" [msgcat::mc "Set indent mode to"] "IND"]] [list menus::text_only indent::set_current_indent_mode IND]
01221
01222 $mb.indentPopup add radiobutton -label [msgcat::mc "Smart Indent"] -variable menus::indent_mode -value "IND+" -command [list menus::text_only indent::set_current_indent_mode IND+]
01223 launcher::register [make_menu_cmd "Edit" [format "%s %s" [msgcat::mc "Set indent mode to"] "IND+"]] [list menus::text_only indent::set_current_indent_mode IND+]
01224
01225 ######################
01226 # Populate cursor menu
01227 ######################
01228
01229 $mb.cursorPopup add command -label [msgcat::mc "Move to First Line"] -command [list menus::text_only menus::edit_cursor_move first]
01230 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move cursor to first line"]] [list menus::text_only menus::edit_cursor_move first]
01231
01232 $mb.cursorPopup add command -label [msgcat::mc "Move to Last Line"] -command [list menus::text_only menus::edit_cursor_move last]
01233 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move cursor to last line"]] [list menus::text_only menus::edit_cursor_move last]
01234
01235 $mb.cursorPopup add command -label [msgcat::mc "Move to Next Page"] -command [list menus::text_only menus::edit_cursor_move_by_page next]
01236 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move cursor to next page"]] [list menus::text_only menus::edit_cursor_move_by_page next]
01237
01238 $mb.cursorPopup add command -label [msgcat::mc "Move to Previous Page"] -command [list menus::text_only menus::edit_cursor_move_by_page prior]
01239 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move cursor to previous page"]] [list menus::text_only menus::edit_cursor_move_by_page prior]
01240
01241 $mb.cursorPopup add separator
01242
01243 $mb.cursorPopup add command -label [msgcat::mc "Move to Screen Top"] -command [list menus::text_only menus::edit_cursor_move screentop]
01244 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move cursor to top of screen"]] [list menus::text_only menus::edit_cursor_move screentop]
01245
01246 $mb.cursorPopup add command -label [msgcat::mc "Move to Screen Middle"] -command [list menus::text_only menus::edit_cursor_move screenmid]
01247 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move cursor to middle of screen"]] [list menus::text_only menus::edit_cursor_move screenmid]
01248
01249 $mb.cursorPopup add command -label [msgcat::mc "Move to Screen Bottom"] -command [list menus::text_only menus::edit_cursor_move screenbot]
01250 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move cursor to bottom of screen"]] [list menus::text_only menus::edit_cursor_move screenbot]
01251
01252 $mb.cursorPopup add separator
01253
01254 $mb.cursorPopup add command -label [msgcat::mc "Move to Line Start"] -command [list menus::text_only menus::edit_cursor_move linestart]
01255 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move cursor to start of current line"]] [list menus::text_only menus::edit_cursor_move linestart]
01256
01257 $mb.cursorPopup add command -label [msgcat::mc "Move to Line End"] -command [list menus::text_only menus::edit_cursor_move lineend]
01258 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move cursor to end of current line"]] [list menus::text_only menus::edit_cursor_move lineend]
01259
01260 $mb.cursorPopup add command -label [msgcat::mc "Move to Next Word"] -command [list menus::text_only menus::edit_cursor_move wordstart -dir next]
01261 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move cursor to next word"]] [list menus::text_only menus::edit_cursor_move wordstart -dir next]
01262
01263 $mb.cursorPopup add command -label [msgcat::mc "Move to Previous Word"] -command [list menus::text_only menus::edit_cursor_move wordstart -dir prev]
01264 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move cursor to previous word"]] [list menus::text_only menus::edit_cursor_move wordstart -dir prev]
01265
01266 $mb.cursorPopup add separator
01267
01268 $mb.cursorPopup add command -label [msgcat::mc "Move Cursors Up"] -command [list menus::text_only menus::edit_cursors_move up]
01269 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move multicursors up one line"]] [list menus::text_only menus::edit_cursors_move up]
01270
01271 $mb.cursorPopup add command -label [msgcat::mc "Move Cursors Down"] -command [list menus::text_only menus::edit_cursors_move down]
01272 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move multicursors down one line"]] [list menus::text_only menus::edit_cursors_move down]
01273
01274 $mb.cursorPopup add command -label [msgcat::mc "Move Cursors Left"] -command [list menus::text_only menus::edit_cursors_move left]
01275 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move multicursors left one line"]] [list menus::text_only menus::edit_cursors_move left]
01276
01277 $mb.cursorPopup add command -label [msgcat::mc "Move Cursors Right"] -command [list menus::text_only menus::edit_cursors_move right]
01278 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Move multicursors right one line"]] [list menus::text_only menus::edit_cursors_move right]
01279
01280 $mb.cursorPopup add separator
01281
01282 $mb.cursorPopup add command -label [msgcat::mc "Align Cursors Only"] -command [list menus::text_only edit::align_cursors]
01283 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Align cursors only"]] [list menus::text_only edit::align_cursors]
01284
01285 $mb.cursorPopup add command -label [msgcat::mc "Align Cursors and Text"] -command [list menus::text_only edit::align_cursors_and_text]
01286 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Align cursors and text"]] [list menus::text_only edit::align_cursors_and_text]
01287
01288 #########################
01289 # Populate insertion menu
01290 #########################
01291
01292 $mb.insertPopup add command -label [msgcat::mc "Line Above Current"] -command [list menus::text_only menus::edit_insert_line_above]
01293 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert line above current line"]] [list menus::text_only menus::edit_insert_line_above]
01294
01295 $mb.insertPopup add command -label [msgcat::mc "Line Below Current"] -command [list menus::text_only menus::edit_insert_line_below]
01296 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert line below current line"]] [list menus::text_only menus::edit_insert_line_below]
01297
01298 $mb.insertPopup add separator
01299
01300 $mb.insertPopup add command -label [msgcat::mc "File Contents"] -command [list menus::text_only menus::edit_insert_file_after_current_line]
01301 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert file contents after current line"]] [list menus::text_only menus::edit_insert_file_after_current_line]
01302
01303 $mb.insertPopup add command -label [msgcat::mc "Command Result"] -command [list menus::text_only menus::edit_insert_command_after_current_line]
01304 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert command result after current line"]] [list menus::text_only menus::edit_insert_command_after_current_line]
01305
01306 $mb.insertPopup add separator
01307
01308 $mb.insertPopup add command -label [msgcat::mc "From Clipboard"] -command [list menus::text_only cliphist::show_cliphist]
01309 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert from clipboard"]] [list menus::text_only cliphist::show_cliphist]
01310
01311 $mb.insertPopup add command -label [msgcat::mc "Snippet"] -command [list menus::text_only snippets::show_snippets]
01312 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert snippet"]] [list menus::text_only snippets::show_snippets]
01313
01314 $mb.insertPopup add separator
01315
01316 $mb.insertPopup add command -label [msgcat::mc "Enumeration"] -underline 7 -command [list menus::text_only edit::insert_enumeration]
01317 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert enumeration"]] [list menus::text_only edit::insert_enumeration]
01318
01319 #########################
01320 # Populate transform menu
01321 #########################
01322
01323 $mb.transformPopup add command -label [msgcat::mc "Toggle Case"] -command [list menus::text_only menus::edit_transform_toggle_case]
01324 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Toggle case of current character"]] [list menus::text_only menus::edit_transform_toggle_case]
01325
01326 $mb.transformPopup add command -label [msgcat::mc "Lower Case"] -command [list menus::text_only menus::edit_transform_to_lower_case]
01327 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Convert case to lower"]] [list menus::text_only menus::edit_transform_to_lower_case]
01328
01329 $mb.transformPopup add command -label [msgcat::mc "Upper Case"] -command [list menus::text_only menus::edit_transform_to_upper_case]
01330 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Convert case to upper"]] [list menus::text_only menus::edit_transform_to_upper_case]
01331
01332 $mb.transformPopup add command -label [msgcat::mc "Title Case"] -command [list menus::text_only menus::edit_transform_to_title_case]
01333 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Convert case to title"]] [list menus::text_only menus::edit_transform_to_title_case]
01334
01335 $mb.transformPopup add separator
01336
01337 $mb.transformPopup add command -label [msgcat::mc "Join Lines"] -command [list menus::text_only menus::edit_transform_join_lines]
01338 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Join lines"]] [list menus::text_only menus::edit_transform_join_lines]
01339
01340 $mb.transformPopup add separator
01341
01342 $mb.transformPopup add command -label [msgcat::mc "Bubble Up"] -command [list menus::text_only menus::edit_transform_bubble_up]
01343 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Bubble lines up one line"]] [list menus::text_only menus::edit_transform_bubble_up]
01344
01345 $mb.transformPopup add command -label [msgcat::mc "Bubble Down"] -command [list menus::text_only menus::edit_transform_bubble_down]
01346 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Bubble lines down one line"]] [list menus::text_only menus::edit_transform_bubble_down]
01347
01348 $mb.transformPopup add separator
01349
01350 $mb.transformPopup add command -label [msgcat::mc "Replace Line With Script"] -command [list menus::text_only edit::replace_line_with_script]
01351 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Replace line with script"]] [list menus::text_only edit::replace_line_with_script]
01352
01353 ##########################
01354 # Populate formatting menu
01355 ##########################
01356
01357 set fmtstr [msgcat::mc "formatting"]
01358
01359 $mb.formatPopup add command -label [msgcat::mc "Bold"] -command [list menus::text_only menus::edit_format bold]
01360 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert bold formatting"]] [list menus::text_only menus::edit_format bold]
01361
01362 $mb.formatPopup add command -label [msgcat::mc "Italics"] -command [list menus::text_only menus::edit_format italics]
01363 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert italics formatting"]] [list menus::text_only menus::edit_format italics]
01364
01365 $mb.formatPopup add command -label [msgcat::mc "Underline"] -command [list menus::text_only menus::edit_format underline]
01366 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert underline formatting"]] [list menus::text_only menus::edit_format underline]
01367
01368 $mb.formatPopup add command -label [msgcat::mc "Strikethrough"] -command [list menus::text_only menus::edit_format strikethrough]
01369 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert strikethrough formatting"]] [list menus::text_only menus::edit_format strikethrough]
01370
01371 $mb.formatPopup add command -label [msgcat::mc "Highlight"] -command [list menus::text_only menus::edit_format highlight]
01372 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert highlight formatting"]] [list menus::text_only menus::edit_format highlight]
01373
01374 $mb.formatPopup add command -label [msgcat::mc "Superscript"] -command [list menus::text_only menus::edit_format superscript]
01375 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert superscript formatting"]] [list menus::text_only menus::edit_format superscript]
01376
01377 $mb.formatPopup add command -label [msgcat::mc "Subscript"] -command [list menus::text_only menus::edit_format subscript]
01378 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert subscript formatting"]] [list menus::text_only menus::edit_format subscript]
01379
01380 $mb.formatPopup add command -label [msgcat::mc "Code"] -command [list menus::text_only menus::edit_format code]
01381 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert code formatting"]] [list menus::text_only menus::edit_format code]
01382
01383 $mb.formatPopup add separator
01384
01385 $mb.formatPopup add command -label [format "%s 1" [msgcat::mc "Header"]] -command [list menus::text_only menus::edit_format header1]
01386 launcher::register [make_menu_cmd "Edit" [format "%s 1 %s" [msgcat::mc "Insert header style"] $fmtstr]] [list menus::text_only menus::edit_format header1]
01387
01388 $mb.formatPopup add command -label [format "%s 2" [msgcat::mc "Header"]] -command [list menus::text_only menus::edit_format header2]
01389 launcher::register [make_menu_cmd "Edit" [format "%s 2 %s" [msgcat::mc "Insert header style"] $fmtstr]] [list menus::text_only menus::edit_format header2]
01390
01391 $mb.formatPopup add command -label [format "%s 3" [msgcat::mc "Header"]] -command [list menus::text_only menus::edit_format header3]
01392 launcher::register [make_menu_cmd "Edit" [format "%s 3 %s" [msgcat::mc "Insert header style"] $fmtstr]] [list menus::text_only menus::edit_format header3]
01393
01394 $mb.formatPopup add command -label [format "%s 4" [msgcat::mc "Header"]] -command [list menus::text_only menus::edit_format header4]
01395 launcher::register [make_menu_cmd "Edit" [format "%s 4 %s" [msgcat::mc "Insert header style"] $fmtstr]] [list menus::text_only menus::edit_format header4]
01396
01397 $mb.formatPopup add command -label [format "%s 5" [msgcat::mc "Header"]] -command [list menus::text_only menus::edit_format header5]
01398 launcher::register [make_menu_cmd "Edit" [format "%s 5 %s" [msgcat::mc "Insert header style"] $fmtstr]] [list menus::text_only menus::edit_format header5]
01399
01400 $mb.formatPopup add command -label [format "%s 6" [msgcat::mc "Header"]] -command [list menus::text_only menus::edit_format header6]
01401 launcher::register [make_menu_cmd "Edit" [format "%s 6 %s" [msgcat::mc "Insert header style"] $fmtstr]] [list menus::text_only menus::edit_format header6]
01402
01403 $mb.formatPopup add separator
01404
01405 $mb.formatPopup add command -label [msgcat::mc "Unordered Bullet"] -command [list menus::text_only menus::edit_format unordered]
01406 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert unordered list formatting"]] [list menus::text_only menus::edit_format unordered]
01407
01408 $mb.formatPopup add command -label [msgcat::mc "Ordered Bullet"] -command [list menus::text_only menus::edit_format ordered]
01409 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert ordered list formatting"]] [list menus::text_only menus::edit_format ordered]
01410
01411 $mb.formatPopup add command -label [msgcat::mc "Checkbox"] -command [list menus::text_only menus::edit_format checkbox]
01412 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert checklist formatting"]] [list menus::text_only menus::edit_format checkbox]
01413
01414 $mb.formatPopup add separator
01415
01416 $mb.formatPopup add command -label [msgcat::mc "Link"] -command [list menus::text_only menus::edit_format link]
01417 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert link formatting"]] [list menus::text_only menus::edit_format link]
01418
01419 $mb.formatPopup add command -label [msgcat::mc "Image"] -command [list menus::text_only menus::edit_format image]
01420 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Insert image formatting"]] [list menus::text_only menus::edit_format image]
01421
01422 $mb.formatPopup add separator
01423
01424 $mb.formatPopup add command -label [msgcat::mc "Remove Formatting"] -command [list menus::text_only menus::edit_format_remove]
01425 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Remove formatting from selected text"]] [list menus::text_only menus::edit_format_remove]
01426
01427 ###########################
01428 # Populate preferences menu
01429 ###########################
01430
01431 $mb.prefPopup add command -label [format "%s - %s" [msgcat::mc "Edit User"] [msgcat::mc "Global"]] -command [list menus::edit_user_global]
01432 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Edit user global preferences"]] [list menus::edit_user_global]
01433
01434 $mb.prefPopup add command -label [format "%s - %s" [msgcat::mc "Edit User"] [msgcat::mc "Language"]] -command [list menus::edit_user_language]
01435 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Edit user current language preferences"]] [list menus::edit_user_language]
01436
01437 $mb.prefPopup add separator
01438
01439 $mb.prefPopup add command -label [format "%s - %s" [msgcat::mc "Delete User"] [msgcat::mc "Language"]] -command [list menus::delete_user_language]
01440
01441 $mb.prefPopup add separator
01442
01443 $mb.prefPopup add command -label [format "%s - %s" [msgcat::mc "Edit Session"] [msgcat::mc "Global"]] -command [list menus::edit_session_global]
01444 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Edit session global preferences"]] [list menus::edit_session_global]
01445
01446 $mb.prefPopup add command -label [format "%s - %s" [msgcat::mc "Edit Session"] [msgcat::mc "Language"]] -command [list menus::edit_session_language]
01447 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Edit session current language preferences"]] [list menus::edit_session_language]
01448
01449 $mb.prefPopup add separator
01450
01451 $mb.prefPopup add command -label [format "%s - %s" [msgcat::mc "Delete Session"] [msgcat::mc "Language"]] -command [list menus::delete_session_language]
01452
01453 ########################
01454 # Populate snippets menu
01455 ########################
01456
01457 $mb.snipPopup add command -label [msgcat::mc "Edit User"] -command [list menus::main_only menus::add_new_snippet user]
01458 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Edit user snippets"]] [list menus::main_only menus::add_new_snippet user]
01459
01460 $mb.snipPopup add command -label [msgcat::mc "Edit Language"] -command [list menus::main_only menus::add_new_snippet lang]
01461 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Edit language snippets"]] [list menus::main_only menus::add_new_snippet lang]
01462
01463 $mb.snipPopup add separator
01464
01465 $mb.snipPopup add command -label [msgcat::mc "Reload"] -command [list menus::main_only snippets::reload_snippets]
01466 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Reload snippets"]] [list menus::main_only snippets::reload_snippets]
01467
01468 #########################
01469 # Populate templates menu
01470 #########################
01471
01472 $mb.tempPopup add command -label [msgcat::mc "Edit"] -command [list menus::main_only templates::show_templates edit]
01473 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Edit template"]] [list menus::main_only templates::show_templates edit]
01474
01475 $mb.tempPopup add command -label [msgcat::mc "Delete"] -command [list menus::main_only templates::show_templates delete]
01476 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Delete template"]] [list menus::main_only templates::show_templates delete]
01477
01478 $mb.tempPopup add separator
01479
01480 $mb.tempPopup add command -label [msgcat::mc "Reload"] -command [list menus::main_only templates::preload]
01481 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Reload template information"]] [list menus::main_only templates::preload]
01482
01483 #####################
01484 # Populate Emmet menu
01485 #####################
01486
01487 $mb.emmetPopup add command -label [msgcat::mc "Expand Abbreviation"] -command [list menus::text_only emmet::expand_abbreviation]
01488 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Expand Emmet abbreviation"]] [list menus::text_only emmet::expand_abbreviation]
01489
01490 $mb.emmetPopup add command -label [msgcat::mc "Wrap With Abbreviation"] -command [list menus::text_only emmet::wrap_with_abbreviation]
01491 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Wrap tag with Emmet abbreviation"]] [list menus::text_only emmet::wrap_with_abbreviation]
01492
01493 $mb.emmetPopup add separator
01494
01495 $mb.emmetPopup add command -label [msgcat::mc "Balance Outward"] -command [list menus::text_only emmet::balance_outward]
01496 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Balance tag pair moving outward"]] [list menus::text_only emmet::balance_outward]
01497
01498 $mb.emmetPopup add command -label [msgcat::mc "Balance Inward"] -command [list menus::text_only emmet::balance_inward]
01499 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Balance tag pair moving inward"]] [list menus::text_only emmet::balance_inward]
01500
01501 $mb.emmetPopup add command -label [msgcat::mc "Go to Matching Pair"] -command [list menus::text_only emmet::go_to_matching_pair]
01502 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Go to matching tag pair"]] [list menus::text_only emmet::go_to_matching_pair]
01503
01504 $mb.emmetPopup add separator
01505
01506 $mb.emmetPopup add command -label [msgcat::mc "Toggle Comment"] -command [list menus::text_only emmet::toggle_comment]
01507 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Toggle tag/rule comment"]] [list menus::text_only emmet::toggle_comment]
01508
01509 $mb.emmetPopup add command -label [msgcat::mc "Split/Join Tag"] -command [list menus::text_only emmet::split_join_tag]
01510 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Split/Join tag"]] [list menus::text_only emmet::split_join_tag]
01511
01512 $mb.emmetPopup add command -label [msgcat::mc "Remove Tag"] -command [list menus::text_only emmet::remove_tag]
01513 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Remove tag"]] [list menus::text_only emmet::remove_tag]
01514
01515 $mb.emmetPopup add command -label [msgcat::mc "Merge Lines"] -command [list menus::text_only emmet::merge_lines]
01516 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Merge Lines"]] [list menus::text_only emmet::merge_lines]
01517
01518 $mb.emmetPopup add command -label [msgcat::mc "Update Image Size"] -command [list menus::text_only emmet::update_image_size]
01519 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Update img tag width and height attributes"]] [list menus::text_only emmet::update_image_size]
01520
01521 $mb.emmetPopup add command -label [msgcat::mc "Encode/Decode Image to Data:URL"] -command [list menus::text_only emmet::encode_decode_image_to_data_url]
01522 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Encode/Decode image to data:URL"]] [list menus::text_only emmet::encode_decode_image_to_data_url]
01523
01524 $mb.emmetPopup add command -label [msgcat::mc "Reflect CSS Value"] -command [list menus::text_only emmet_css::reflect_css_value]
01525 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Reflect current CSS value"]] [list menus::text_only emmet_css::reflect_css_value]
01526
01527 $mb.emmetPopup add separator
01528
01529 $mb.emmetPopup add command -label [msgcat::mc "Next Edit Point"] -command [list menus::text_only emmet::go_to_edit_point next]
01530 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Go to next edit point"]] [list menus::text_only emmet::go_to_edit_point next]
01531
01532 $mb.emmetPopup add command -label [msgcat::mc "Previous Edit Point"] -command [list menus::text_only emmet::go_to_edit_point prev]
01533 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Go to previous edit point"]] [list menus::text_only emmet::go_to_edit_point prev]
01534
01535 $mb.emmetPopup add separator
01536
01537 $mb.emmetPopup add command -label [msgcat::mc "Select Next Item"] -command [list menus::text_only emmet::select_item next]
01538 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Select next tag item"]] [list menus::text_only emmet::select_item next]
01539
01540 $mb.emmetPopup add command -label [msgcat::mc "Select Previous Item"] -command [list menus::text_only emmet::select_item prev]
01541 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Select previous tag item"]] [list menus::text_only emmet::select_item prev]
01542
01543 $mb.emmetPopup add separator
01544
01545 $mb.emmetPopup add command -label [msgcat::mc "Evaluate Math Expression"] -command [list menus::text_only emmet::evaluate_math_expression]
01546 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Evaluate the current math expression"]] [list menus::text_only emmet::evaluate_math_expression]
01547
01548 $mb.emmetPopup add separator
01549
01550 $mb.emmetPopup add command -label [msgcat::mc "Increment by 10"] -command [list menus::text_only emmet::change_number 10]
01551 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Increment number by 10"]] [list menus::text_only emmet::change_number 10]
01552
01553 $mb.emmetPopup add command -label [msgcat::mc "Increment by 1"] -command [list menus::text_only emmet::change_number 1]
01554 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Increment number by 1"]] [list menus::text_only emmet::change_number 1]
01555
01556 $mb.emmetPopup add command -label [msgcat::mc "Increment by 0.1"] -command [list menus::text_only emmet::change_number 0.1]
01557 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Increment number by 0.1"]] [list menus::text_only emmet::change_number 0.1]
01558
01559 $mb.emmetPopup add command -label [msgcat::mc "Decrement by 10"] -command [list menus::text_only emmet::change_number -10]
01560 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Decrement number by 10"]] [list menus::text_only emmet::change_number -10]
01561
01562 $mb.emmetPopup add command -label [msgcat::mc "Decrement by 1"] -command [list menus::text_only emmet::change_number -1]
01563 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Decrement number by 1"]] [list menus::text_only emmet::change_number -1]
01564
01565 $mb.emmetPopup add command -label [msgcat::mc "Decrement by 0.1"] -command [list menus::text_only emmet::change_number -0.1]
01566 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Decrement number by 0.1"]] [list menus::text_only emmet::change_number -0.1]
01567
01568 $mb.emmetPopup add separator
01569
01570 $mb.emmetPopup add command -label [msgcat::mc "Edit Custom Abbreviations"] -command [list menus::main_only emmet::edit_abbreviations]
01571 launcher::register [make_menu_cmd "Edit" [msgcat::mc "Edit custom Emmet abbreviations"]] [list menus::main_only emmet::edit_abbreviations]
01572
01573 $mb.emmetPopup add separator
01574
01575 $mb.emmetPopup add command -label [msgcat::mc "View Emmet Reference Guide"] -command [list menus::main_only emmet::view_reference]
01576 launcher::register [make_menu_cmd "Edit" [msgcat::mc "View the Emmet reference guide"]] [list menus::main_only emmet::view_reference]
01577
01578 }
01579
01580 ######################################################################
01581 # Called just prior to posting the edit menu. Sets the state of all
01582 # menu items to match the proper state of the UI.
01583 proc edit_posting {mb} {
01584
01585 if {[catch { gui::get_info {} current txt readonly diff }]} {
01586 $mb entryconfigure [msgcat::mc "Undo"] -state disabled
01587 $mb entryconfigure [msgcat::mc "Redo"] -state disabled
01588 $mb entryconfigure [msgcat::mc "Cut"] -state disabled
01589 $mb entryconfigure [msgcat::mc "Copy"] -state disabled
01590 $mb entryconfigure [msgcat::mc "Paste"] -state disabled
01591 $mb entryconfigure [msgcat::mc "Paste and Format"] -state disabled
01592 $mb entryconfigure [msgcat::mc "Select Mode"] -state disabled
01593 $mb entryconfigure [msgcat::mc "Vim Mode"] -state disabled
01594 $mb entryconfigure [msgcat::mc "Toggle Comment"] -state disabled
01595 $mb entryconfigure [msgcat::mc "Indentation"] -state disabled
01596 $mb entryconfigure [msgcat::mc "Cursor"] -state disabled
01597 $mb entryconfigure [msgcat::mc "Insert"] -state disabled
01598 $mb entryconfigure [msgcat::mc "Transform"] -state disabled
01599 $mb entryconfigure [msgcat::mc "Format"] -state disabled
01600 } else {
01601 set readonly_state [expr {($readonly || $diff) ? "disabled" : "normal"}]
01602 if {[gui::undoable]} {
01603 $mb entryconfigure [msgcat::mc "Undo"] -state $readonly_state
01604 } else {
01605 $mb entryconfigure [msgcat::mc "Undo"] -state disabled
01606 }
01607 if {[gui::redoable]} {
01608 $mb entryconfigure [msgcat::mc "Redo"] -state $readonly_state
01609 } else {
01610 $mb entryconfigure [msgcat::mc "Redo"] -state disabled
01611 }
01612 $mb entryconfigure [msgcat::mc "Cut"] -state $readonly_state
01613 $mb entryconfigure [msgcat::mc "Copy"] -state normal
01614 if {[gui::pastable]} {
01615 $mb entryconfigure [msgcat::mc "Paste"] -state $readonly_state
01616 $mb entryconfigure [msgcat::mc "Paste and Format"] -state $readonly_state
01617 } else {
01618 $mb entryconfigure [msgcat::mc "Paste"] -state disabled
01619 $mb entryconfigure [msgcat::mc "Paste and Format"] -state disabled
01620 }
01621 $mb entryconfigure [msgcat::mc "Select Mode"] -state normal
01622 $mb entryconfigure [msgcat::mc "Vim Mode"] -state $readonly_state
01623 if {[lindex [syntax::get_comments [gui::current_txt]] 0] eq ""} {
01624 $mb entryconfigure [msgcat::mc "Toggle Comment"] -state disabled
01625 } else {
01626 $mb entryconfigure [msgcat::mc "Toggle Comment"] -state $readonly_state
01627 }
01628 $mb entryconfigure [msgcat::mc "Indentation"] -state $readonly_state
01629 $mb entryconfigure [msgcat::mc "Cursor"] -state $readonly_state
01630 if {[gui::editable]} {
01631 $mb entryconfigure [msgcat::mc "Insert"] -state $readonly_state
01632 $mb entryconfigure [msgcat::mc "Transform"] -state $readonly_state
01633 } else {
01634 $mb entryconfigure [msgcat::mc "Insert"] -state disabled
01635 $mb entryconfigure [msgcat::mc "Transform"] -state disabled
01636 }
01637 if {[gui::editable] && ([llength [syntax::get_formatting $txt]] > 0)} {
01638 $mb entryconfigure [msgcat::mc "Format"] -state $readonly_state
01639 } else {
01640 $mb entryconfigure [msgcat::mc "Format"] -state disabled
01641 }
01642 }
01643
01644 }
01645
01646 ######################################################################
01647 # Called just prior to posting the edit/selection menu option. Sets
01648 # the menu option states to match the current UI state.
01649 proc edit_select_posting {mb} {
01650
01651 set txt [gui::current_txt]
01652 set state [expr {($txt eq "") ? "disabled" : "normal"}]
01653 set sel_state [expr {(($txt eq "") || ([$txt tag ranges sel] eq "")) ? "disabled" : "normal"}]
01654
01655 $mb entryconfigure [msgcat::mc "All"] -state $state
01656 $mb entryconfigure [msgcat::mc "Current Line"] -state $state
01657 $mb entryconfigure [msgcat::mc "Current Word"] -state $state
01658 $mb entryconfigure [msgcat::mc "Current Sentence"] -state $state
01659 $mb entryconfigure [msgcat::mc "Current Paragraph"] -state $state
01660 $mb entryconfigure [msgcat::mc "Current Bounded Text"] -state $state
01661 $mb entryconfigure [msgcat::mc "Add Next Line"] -state $sel_state
01662 $mb entryconfigure [msgcat::mc "Add Previous Line"] -state $sel_state
01663
01664 }
01665
01666 ######################################################################
01667 # Called just prior to posting the edit/indentation menu option. Sets
01668 # the menu option states to match the current UI state.
01669 proc edit_indent_posting {mb} {
01670
01671 variable indent_mode
01672
01673 set state "disabled"
01674
01675 # Set the indentation mode for the current editor
01676 if {[set txt [gui::current_txt]] ne ""} {
01677 set indent_mode [indent::get_indent_mode $txt]
01678 set state "normal"
01679 }
01680
01681 $mb entryconfigure [msgcat::mc "Unindent"] -state $state
01682 $mb entryconfigure [msgcat::mc "Indent"] -state $state
01683 $mb entryconfigure [msgcat::mc "Indent Off"] -state $state
01684 $mb entryconfigure [msgcat::mc "Auto-Indent"] -state $state
01685 $mb entryconfigure [msgcat::mc "Smart Indent"] -state $state
01686
01687 }
01688
01689 ######################################################################
01690 # Called just prior to posting the edit/cursor menu option. Sets the
01691 # menu option states to match the current UI state.
01692 proc edit_cursor_posting {mb} {
01693
01694 set mstate "disabled"
01695 set sstate "disabled"
01696
01697 # Get the current text widget
01698 if {[set txt [gui::current_txt]] ne ""} {
01699 if {[multicursor::enabled $txt]} {
01700 set mstate "normal"
01701 } else {
01702 set sstate "normal"
01703 }
01704 }
01705
01706 $mb entryconfigure [msgcat::mc "Move to First Line"] -state $sstate
01707 $mb entryconfigure [msgcat::mc "Move to Last Line"] -state $sstate
01708 $mb entryconfigure [msgcat::mc "Move to Next Page"] -state $sstate
01709 $mb entryconfigure [msgcat::mc "Move to Previous Page"] -state $sstate
01710 $mb entryconfigure [msgcat::mc "Move to Screen Top"] -state $sstate
01711 $mb entryconfigure [msgcat::mc "Move to Screen Middle"] -state $sstate
01712 $mb entryconfigure [msgcat::mc "Move to Screen Bottom"] -state $sstate
01713 $mb entryconfigure [msgcat::mc "Move to Line Start"] -state $sstate
01714 $mb entryconfigure [msgcat::mc "Move to Line End"] -state $sstate
01715 $mb entryconfigure [msgcat::mc "Move to Next Word"] -state $sstate
01716 $mb entryconfigure [msgcat::mc "Move to Previous Word"] -state $sstate
01717
01718 $mb entryconfigure [msgcat::mc "Move Cursors Up"] -state $mstate
01719 $mb entryconfigure [msgcat::mc "Move Cursors Down"] -state $mstate
01720 $mb entryconfigure [msgcat::mc "Move Cursors Left"] -state $mstate
01721 $mb entryconfigure [msgcat::mc "Move Cursors Right"] -state $mstate
01722 $mb entryconfigure [msgcat::mc "Align Cursors Only"] -state $mstate
01723 $mb entryconfigure [msgcat::mc "Align Cursors and Text"] -state $mstate
01724
01725 }
01726
01727 ######################################################################
01728 # Called just prior to posting the edit/insert menu option. Sets the
01729 # menu option states to match the current UI state.
01730 proc edit_insert_posting {mb} {
01731
01732 set tstate "disabled"
01733 set mstate "disabled"
01734
01735 if {[set txt [gui::current_txt]] ne ""} {
01736 set tstate "normal"
01737 if {[multicursor::enabled $txt]} {
01738 set mstate "normal"
01739 }
01740 }
01741
01742 $mb entryconfigure [msgcat::mc "Line Above Current"] -state $tstate
01743 $mb entryconfigure [msgcat::mc "Line Below Current"] -state $tstate
01744 $mb entryconfigure [msgcat::mc "File Contents"] -state $tstate
01745 $mb entryconfigure [msgcat::mc "Command Result"] -state $tstate
01746
01747 if {[llength [cliphist::get_history]] > 0} {
01748 $mb entryconfigure [msgcat::mc "From Clipboard"] -state normal
01749 } else {
01750 $mb entryconfigure [msgcat::mc "From Clipboard"] -state disabled
01751 }
01752
01753 if {[llength [snippets::get_current_snippets]] > 0} {
01754 $mb entryconfigure [msgcat::mc "Snippet"] -state normal
01755 } else {
01756 $mb entryconfigure [msgcat::mc "Snippet"] -state disabled
01757 }
01758
01759 $mb entryconfigure [msgcat::mc "Enumeration"] -state $mstate
01760
01761 }
01762
01763 ######################################################################
01764 # Called just prior to posting the edit/transform menu option. Sets
01765 # the menu option states to match the current UI state.
01766 proc edit_transform_posting {mb} {
01767
01768 # Get the state
01769 set state [expr {([gui::current_txt] eq "") ? "disabled" : "normal"}]
01770
01771 $mb entryconfigure [msgcat::mc "Toggle Case"] -state $state
01772 $mb entryconfigure [msgcat::mc "Lower Case"] -state $state
01773 $mb entryconfigure [msgcat::mc "Upper Case"] -state $state
01774 $mb entryconfigure [msgcat::mc "Title Case"] -state $state
01775 $mb entryconfigure [msgcat::mc "Join Lines"] -state $state
01776 $mb entryconfigure [msgcat::mc "Bubble Up"] -state $state
01777 $mb entryconfigure [msgcat::mc "Bubble Down"] -state $state
01778 $mb entryconfigure [msgcat::mc "Replace Line With Script"] -state $state
01779
01780 if {[edit::current_line_empty]} {
01781 $mb entryconfigure [msgcat::mc "Replace Line With Script"] -state disabled
01782 }
01783
01784 }
01785
01786 ######################################################################
01787 # Called just prior to posting the edit/format menu option. Sets the
01788 # menu option states to match the current UI state.
01789 proc edit_format_posting {mb} {
01790
01791 set txt [gui::get_info {} current txt]
01792
01793 # Place the contents of the formatting information in the array
01794 array set formatting [syntax::get_formatting $txt]
01795
01796 $mb entryconfigure [msgcat::mc "Bold"] -state [expr {[info exists formatting(bold)] ? "normal" : "disabled"}]
01797 $mb entryconfigure [msgcat::mc "Italics"] -state [expr {[info exists formatting(italics)] ? "normal" : "disabled"}]
01798 $mb entryconfigure [msgcat::mc "Underline"] -state [expr {[info exists formatting(underline)] ? "normal" : "disabled"}]
01799 $mb entryconfigure [msgcat::mc "Strikethrough"] -state [expr {[info exists formatting(strikethrough)] ? "normal" : "disabled"}]
01800 $mb entryconfigure [msgcat::mc "Highlight"] -state [expr {[info exists formatting(highlight)] ? "normal" : "disabled"}]
01801 $mb entryconfigure [msgcat::mc "Superscript"] -state [expr {[info exists formatting(superscript)] ? "normal" : "disabled"}]
01802 $mb entryconfigure [msgcat::mc "Subscript"] -state [expr {[info exists formatting(subscript)] ? "normal" : "disabled"}]
01803 $mb entryconfigure [msgcat::mc "Code"] -state [expr {[info exists formatting(code)] ? "normal" : "disabled"}]
01804 $mb entryconfigure [format "%s 1" [msgcat::mc "Header"]] -state [expr {[info exists formatting(header1)] ? "normal" : "disabled"}]
01805 $mb entryconfigure [format "%s 2" [msgcat::mc "Header"]] -state [expr {[info exists formatting(header2)] ? "normal" : "disabled"}]
01806 $mb entryconfigure [format "%s 3" [msgcat::mc "Header"]] -state [expr {[info exists formatting(header3)] ? "normal" : "disabled"}]
01807 $mb entryconfigure [format "%s 4" [msgcat::mc "Header"]] -state [expr {[info exists formatting(header4)] ? "normal" : "disabled"}]
01808 $mb entryconfigure [format "%s 5" [msgcat::mc "Header"]] -state [expr {[info exists formatting(header5)] ? "normal" : "disabled"}]
01809 $mb entryconfigure [format "%s 6" [msgcat::mc "Header"]] -state [expr {[info exists formatting(header6)] ? "normal" : "disabled"}]
01810 $mb entryconfigure [msgcat::mc "Unordered Bullet"] -state [expr {[info exists formatting(unordered)] ? "normal" : "disabled"}]
01811 $mb entryconfigure [msgcat::mc "Ordered Bullet"] -state [expr {[info exists formatting(ordered)] ? "normal" : "disabled"}]
01812 $mb entryconfigure [msgcat::mc "Checkbox"] -state [expr {[info exists formatting(checkbox)] ? "normal" : "disabled"}]
01813 $mb entryconfigure [msgcat::mc "Link"] -state [expr {[info exists formatting(link)] ? "normal" : "disabled"}]
01814 $mb entryconfigure [msgcat::mc "Image"] -state [expr {[info exists formatting(image)] ? "normal" : "disabled"}]
01815
01816 }
01817
01818 ######################################################################
01819 # Called just prior to posting the edit/preferences menu option. Sets
01820 # the menu option states to match the current UI state.
01821 proc edit_preferences_posting {mb} {
01822
01823 if {[set txt [gui::current_txt]] eq ""} {
01824 $mb entryconfigure [format "%s - %s" [msgcat::mc "Edit User"] [msgcat::mc "Language"]] -state disabled
01825 $mb entryconfigure [format "%s - %s" [msgcat::mc "Delete User"] [msgcat::mc "Language"]] -state disabled
01826 $mb entryconfigure [format "%s - %s" [msgcat::mc "Edit Session"] [msgcat::mc "Language"]] -state disabled
01827 $mb entryconfigure [format "%s - %s" [msgcat::mc "Delete Session"] [msgcat::mc "Language"]] -state disabled
01828 } else {
01829 $mb entryconfigure [format "%s - %s" [msgcat::mc "Edit User"] [msgcat::mc "Language"]] -state normal
01830 if {[preferences::language_exists "" [syntax::get_language $txt]]} {
01831 $mb entryconfigure [format "%s - %s" [msgcat::mc "Delete User"] [msgcat::mc "Language"]] -state normal
01832 } else {
01833 $mb entryconfigure [format "%s - %s" [msgcat::mc "Delete User"] [msgcat::mc "Language"]] -state disabled
01834 }
01835 if {[set session [sessions::current]] eq ""} {
01836 $mb entryconfigure [format "%s - %s" [msgcat::mc "Edit Session"] [msgcat::mc "Global"]] -state disabled
01837 $mb entryconfigure [format "%s - %s" [msgcat::mc "Edit Session"] [msgcat::mc "Language"]] -state disabled
01838 $mb entryconfigure [format "%s - %s" [msgcat::mc "Delete Session"] [msgcat::mc "Language"]] -state disabled
01839 } else {
01840 $mb entryconfigure [format "%s - %s" [msgcat::mc "Edit Session"] [msgcat::mc "Global"]] -state normal
01841 $mb entryconfigure [format "%s - %s" [msgcat::mc "Edit Session"] [msgcat::mc "Language"]] -state normal
01842 if {[preferences::language_exists $session [syntax::get_language $txt]]} {
01843 $mb entryconfigure [format "%s - %s" [msgcat::mc "Delete Session"] [msgcat::mc "Language"]] -state normal
01844 } else {
01845 $mb entryconfigure [format "%s - %s" [msgcat::mc "Delete Session"] [msgcat::mc "Language"]] -state disabled
01846 }
01847 }
01848 }
01849
01850 }
01851
01852 ######################################################################
01853 # Called just prior to posting the edit/menu bindings menu option.
01854 # Sets the menu option states to match the current UI state.
01855 proc edit_snippets_posting {mb} {
01856
01857 $mb entryconfigure [msgcat::mc "Edit User"] -state normal
01858
01859 if {[gui::current_txt] eq ""} {
01860 $mb entryconfigure [msgcat::mc "Edit Language"] -state disabled
01861 } else {
01862 $mb entryconfigure [msgcat::mc "Edit Language"] -state normal
01863 }
01864
01865 }
01866
01867 ######################################################################
01868 # Called just prior to posting the edit/templates bindings menu option.
01869 # Sets the menu option states to match the current UI state.
01870 proc edit_templates_posting {mb} {
01871
01872 set state [expr {[templates::valid] ? "normal" : "disabled"}]
01873
01874 $mb entryconfigure [msgcat::mc "Edit"] -state $state
01875 $mb entryconfigure [msgcat::mc "Delete"] -state $state
01876
01877 }
01878
01879 ######################################################################
01880 # Called just prior to posting the edit/emmet bindings menu option.
01881 # Sets the menu option states to match the current UI state.
01882 proc edit_emmet_posting {mb} {
01883
01884 if {[catch { gui::get_info {} current txt lang }]} {
01885
01886 $mb entryconfigure [msgcat::mc "Expand Abbreviation"] -state disabled
01887 $mb entryconfigure [msgcat::mc "Wrap With Abbreviation"] -state disabled
01888 $mb entryconfigure [msgcat::mc "Balance Outward"] -state disabled
01889 $mb entryconfigure [msgcat::mc "Balance Inward"] -state disabled
01890 $mb entryconfigure [msgcat::mc "Go to Matching Pair"] -state disabled
01891 $mb entryconfigure [msgcat::mc "Toggle Comment"] -state disabled
01892 $mb entryconfigure [msgcat::mc "Split/Join Tag"] -state disabled
01893 $mb entryconfigure [msgcat::mc "Remove Tag"] -state disabled
01894 $mb entryconfigure [msgcat::mc "Merge Lines"] -state disabled
01895 $mb entryconfigure [msgcat::mc "Update Image Size"] -state disabled
01896 $mb entryconfigure [msgcat::mc "Encode/Decode Image to Data:URL"] -state disabled
01897 $mb entryconfigure [msgcat::mc "Reflect CSS Value"] -state disabled
01898 $mb entryconfigure [msgcat::mc "Next Edit Point"] -state disabled
01899 $mb entryconfigure [msgcat::mc "Previous Edit Point"] -state disabled
01900 $mb entryconfigure [msgcat::mc "Select Next Item"] -state disabled
01901 $mb entryconfigure [msgcat::mc "Select Previous Item"] -state disabled
01902 $mb entryconfigure [msgcat::mc "Evaluate Math Expression"] -state disabled
01903 $mb entryconfigure [msgcat::mc "Increment by 10"] -state disabled
01904 $mb entryconfigure [msgcat::mc "Increment by 1"] -state disabled
01905 $mb entryconfigure [msgcat::mc "Increment by 0.1"] -state disabled
01906 $mb entryconfigure [msgcat::mc "Decrement by 10"] -state disabled
01907 $mb entryconfigure [msgcat::mc "Decrement by 1"] -state disabled
01908 $mb entryconfigure [msgcat::mc "Decrement by 0.1"] -state disabled
01909
01910 } else {
01911
01912 set intag [emmet::inside_tag $txt -allow010 1]
01913 set innode [emmet::get_node_range $txt]
01914 set inurl [emmet_css::in_url $txt]
01915 set intag_mode [expr {($intag eq "") ? "disabled" : "normal"}]
01916 set innode_mode [expr {($innode eq "") ? "disabled" : "normal"}]
01917 set inurl_mode [expr {$inurl ? "normal" : "disabled"}]
01918 set sel_mode [expr {([llength [$txt tag ranges sel]] == 2) ? "normal" : $intag_mode}]
01919 set html_mode [expr {($lang eq "HTML") ? "normal" : "disabled"}]
01920 set css_mode [expr {($lang eq "CSS") ? "normal" : "disabled"}]
01921 set html_or_css [expr {(($lang eq "HTML") || ($lang eq "CSS")) ? "normal" : "disabled"}]
01922 set url_mode [expr {($lang eq "HTML") ? $intag_mode : $inurl_mode}]
01923
01924 $mb entryconfigure [msgcat::mc "Expand Abbreviation"] -state normal
01925 $mb entryconfigure [msgcat::mc "Wrap With Abbreviation"] -state $sel_mode
01926 $mb entryconfigure [msgcat::mc "Balance Outward"] -state $intag_mode
01927 $mb entryconfigure [msgcat::mc "Balance Inward"] -state $intag_mode
01928 $mb entryconfigure [msgcat::mc "Go to Matching Pair"] -state $intag_mode
01929 $mb entryconfigure [msgcat::mc "Toggle Comment"] -state $html_or_css
01930 $mb entryconfigure [msgcat::mc "Split/Join Tag"] -state $innode_mode
01931 $mb entryconfigure [msgcat::mc "Remove Tag"] -state $intag_mode
01932 $mb entryconfigure [msgcat::mc "Merge Lines"] -state $innode_mode
01933 $mb entryconfigure [msgcat::mc "Update Image Size"] -state $url_mode
01934 $mb entryconfigure [msgcat::mc "Encode/Decode Image to Data:URL"] -state $url_mode
01935 $mb entryconfigure [msgcat::mc "Reflect CSS Value"] -state $css_mode
01936 $mb entryconfigure [msgcat::mc "Next Edit Point"] -state $html_mode
01937 $mb entryconfigure [msgcat::mc "Previous Edit Point"] -state $html_mode
01938 $mb entryconfigure [msgcat::mc "Select Next Item"] -state $html_or_css
01939 $mb entryconfigure [msgcat::mc "Select Previous Item"] -state $html_or_css
01940 $mb entryconfigure [msgcat::mc "Evaluate Math Expression"] -state normal
01941 $mb entryconfigure [msgcat::mc "Increment by 10"] -state normal
01942 $mb entryconfigure [msgcat::mc "Increment by 1"] -state normal
01943 $mb entryconfigure [msgcat::mc "Increment by 0.1"] -state normal
01944 $mb entryconfigure [msgcat::mc "Decrement by 10"] -state normal
01945 $mb entryconfigure [msgcat::mc "Decrement by 1"] -state normal
01946 $mb entryconfigure [msgcat::mc "Decrement by 0.1"] -state normal
01947
01948 }
01949
01950 }
01951
01952 ######################################################################
01953 # Enables the selection mode.
01954 proc select_mode {} {
01955
01956 select::set_select_mode [gui::current_txt].t 1
01957
01958 }
01959
01960 ######################################################################
01961 # Indents the current line or current selection.
01962 proc indent_command {} {
01963
01964 edit::indent [gui::current_txt].t
01965
01966 }
01967
01968 ######################################################################
01969 # Unindents the current line or current selection.
01970 proc unindent_command {} {
01971
01972 edit::unindent [gui::current_txt].t
01973
01974 }
01975
01976 ######################################################################
01977 # Moves the current cursor by the given modifier for the current
01978 # text widget.
01979 proc edit_cursor_move {modifier args} {
01980
01981 # Get the current text widget
01982 set txtt [gui::current_txt].t
01983
01984 # Move the cursor if we are not in multicursor mode
01985 if {![multicursor::enabled $txtt]} {
01986 edit::move_cursor $txtt $modifier {*}$args
01987 }
01988
01989 }
01990
01991 ######################################################################
01992 # Moves the current cursor by the given page direction for the current
01993 # text widget.
01994 proc edit_cursor_move_by_page {dir} {
01995
01996 # Get the current text widget
01997 set txtt [gui::current_txt].t
01998
01999 # Move the cursor if we are not in multicursor mode
02000 if {![multicursor::enabled $txtt]} {
02001 edit::move_cursor_by_page $txtt $dir
02002 }
02003
02004 }
02005
02006 ######################################################################
02007 # Moves multicursors
02008 proc edit_cursors_move {modifier} {
02009
02010 # Get the current text widget
02011 set txtt [gui::current_txt].t
02012
02013 # If we are in multicursor mode, move the cursors in the direction given by modifier
02014 if {[multicursor::enabled $txtt]} {
02015 edit::move_cursors $txtt $modifier
02016 }
02017
02018 }
02019
02020 ######################################################################
02021 # Inserts a new line above the current line.
02022 proc edit_insert_line_above {} {
02023
02024 edit::insert_line_above_current [gui::current_txt].t
02025
02026 }
02027
02028 ######################################################################
02029 # Inserts a new line below the current line.
02030 proc edit_insert_line_below {} {
02031
02032 edit::insert_line_below_current [gui::current_txt].t
02033
02034 }
02035
02036 ######################################################################
02037 # Get the name of a file from the user using the open file chooser.
02038 # Inserts the contents of the file after the current line.
02039 proc edit_insert_file_after_current_line {} {
02040
02041 if {[set fname [tk_getOpenFile -parent . -initialdir [gui::get_browse_directory] -multiple 1]] ne ""} {
02042 edit::insert_file [gui::current_txt].t $fname
02043 gui::set_txt_focus [gui::current_txt]
02044 }
02045
02046 }
02047
02048 ######################################################################
02049 # Gets a shell command from the user via the user input field. Executes
02050 # the command and output the results after the current line.
02051 proc edit_insert_command_after_current_line {} {
02052
02053 set cmd ""
02054
02055 if {[gui::get_user_response [format "%s:" [msgcat::mc "Command"]] cmd -allow_vars 1]} {
02056 edit::insert_file [gui::current_txt].t "|$cmd"
02057 }
02058
02059 }
02060
02061 ######################################################################
02062 # Perform a case toggle operation.
02063 proc edit_transform_toggle_case {} {
02064
02065 set txtt [gui::current_txt].t
02066
02067 if {[catch { $txtt tag ranges sel } sel]} {
02068 foreach {startpos endpos} $sel {
02069 edit::transform_toggle_case $txtt $startpos $endpos
02070 }
02071 } else {
02072 edit::transform_toggle_case $txtt insert "insert+1c"
02073 }
02074
02075 }
02076
02077 ######################################################################
02078 # Perform a lowercase conversion.
02079 proc edit_transform_to_lower_case {} {
02080
02081 set txtt [gui::current_txt].t
02082
02083 if {[catch { $txtt tag ranges sel } sel]} {
02084 foreach {startpos endpos} $sel {
02085 edit::transform_to_lower_case $txtt $startpos $endpos
02086 }
02087 } else {
02088 edit::transform_to_lower_case $txtt insert "insert+1c"
02089 }
02090
02091 }
02092
02093 ######################################################################
02094 # Perform an uppercase conversion.
02095 proc edit_transform_to_upper_case {} {
02096
02097 set txtt [gui::current_txt].t
02098
02099 if {[catch { $txtt tag ranges sel } sel]} {
02100 foreach {startpos endpos} $sel {
02101 edit::transform_to_upper_case $txtt $startpos $endpos
02102 }
02103 } else {
02104 edit::transform_to_upper_case $txtt insert "insert+1c"
02105 }
02106
02107 }
02108
02109 ######################################################################
02110 # Perform a title case conversion.
02111 proc edit_transform_to_title_case {} {
02112
02113 set txtt [gui::current_txt].t
02114
02115 if {[catch { $txtt tag ranges sel } sel]} {
02116 foreach {startpos endpos} $sel {
02117 edit::transform_to_title_case $txtt $startpos $endpos
02118 }
02119 } else {
02120 edit::transform_to_title_case $txtt insert "insert+1c"
02121 }
02122
02123 }
02124
02125 ######################################################################
02126 # Joins selected lines or the line beneath the current lines.
02127 proc edit_transform_join_lines {} {
02128
02129 edit::transform_join_lines [gui::current_txt].t
02130
02131 }
02132
02133 ######################################################################
02134 # Moves selected lines or the current line up by one line.
02135 proc edit_transform_bubble_up {} {
02136
02137 edit::transform_bubble_up [gui::current_txt].t
02138
02139 }
02140
02141 ######################################################################
02142 # Moves selected lines or the current line down by one line.
02143 proc edit_transform_bubble_down {} {
02144
02145 edit::transform_bubble_down [gui::current_txt].t
02146
02147 }
02148
02149 ######################################################################
02150 # Adds the specified formatting around the selected text.
02151 proc edit_format {type} {
02152
02153 # Perform the editing
02154 edit::format [gui::current_txt].t $type
02155
02156 }
02157
02158 ######################################################################
02159 # Removes all formatting within the selected text.
02160 proc edit_format_remove {} {
02161
02162 # Unapply any formatting found in the selected text
02163 edit::unformat [gui::current_txt].t
02164
02165 }
02166
02167 ######################################################################
02168 # Edits the user global preference settings.
02169 proc edit_user_global {} {
02170
02171 # preferences::edit_global
02172 pref_ui::create "" ""
02173
02174 }
02175
02176 ######################################################################
02177 # Edits the user current language preference settings.
02178 proc edit_user_language {} {
02179
02180 pref_ui::create "" [syntax::get_language [gui::current_txt]]
02181
02182 }
02183
02184 ######################################################################
02185 # Delete the current language preferences file.
02186 proc delete_user_language {} {
02187
02188 set message [msgcat::mc "Delete language preferences?"]
02189 set detail [msgcat::mc "All language-specific settings will be removed and the global settings will be applied for the specified language."]
02190
02191 if {[tk_messageBox -parent . -type yesno -default no -message $message -detail $detail] eq "yes"} {
02192 preferences::delete_language_prefs "" [syntax::get_language [gui::current_txt]]
02193 }
02194
02195 }
02196
02197 ######################################################################
02198 # Edits the session global preference settings.
02199 proc edit_session_global {} {
02200
02201 pref_ui::create [sessions::current] ""
02202
02203 }
02204
02205 ######################################################################
02206 # Edits the session current language preference settings.
02207 proc edit_session_language {} {
02208
02209 pref_ui::create [sessions::current] [syntax::get_language [gui::current_txt]]
02210
02211 }
02212
02213 ######################################################################
02214 # Delete the current session/language preferences file.
02215 proc delete_session_language {} {
02216
02217 set message [msgcat::mc "Delete session language preferences?"]
02218 set detail [msgcat::mc "All language-specific settings for the current session will be removed and the global settings will be applied for the specified language."]
02219
02220 if {[tk_messageBox -parent . -type yesno -default no -message $message -detail $detail] eq "yes"} {
02221 preferences::delete_language_prefs [sessions::current] [syntax::get_language [gui::current_txt]]
02222 }
02223
02224 }
02225
02226 ######################################################################
02227 # Adds a new snippet via the preferences GUI or text editor.
02228 proc add_new_snippet {language} {
02229
02230 if {$language eq "user"} {
02231 pref_ui::create "" "" snippets
02232 } else {
02233 pref_ui::create "" [syntax::get_language [gui::current_txt]] snippets
02234 }
02235
02236 }
02237
02238 ######################################################################
02239 # Add the find menu.
02240 proc add_find {mb} {
02241
02242 # Add find menu commands
02243 $mb add command -label [msgcat::mc "Find"] -underline 0 -command [list menus::text_only gui::search]
02244 launcher::register [make_menu_cmd "Find" [msgcat::mc "Find"]] [list menus::text_only gui::search]
02245
02246 $mb add command -label [msgcat::mc "Find Next"] -underline 7 -command [list menus::text_only menus::find_next_command]
02247 launcher::register [make_menu_cmd "Find" [msgcat::mc "Find next occurrence"]] [list menus::text_only menus::find_next_command]
02248
02249 $mb add command -label [msgcat::mc "Find Previous"] -underline 7 -command [list menus::text_only menus::find_prev_command]
02250 launcher::register [make_menu_cmd "Find" [msgcat::mc "Find previous occurrence"]] [list menus::text_only menus::find_prev_command]
02251
02252 $mb add separator
02253
02254 $mb add command -label [msgcat::mc "Select Current Match"] -underline 1 -command [list menus::text_only menus::find_select_current_command]
02255 launcher::register [make_menu_cmd "Find" [msgcat::mc "Append current find text to selection"]] [list menus::text_only menus::find_select_current_command]
02256
02257 $mb add command -label [msgcat::mc "Select All Matches"] -underline 7 -command [list menus::text_only menus::find_select_all_command]
02258 launcher::register [make_menu_cmd "Find" [msgcat::mc "Select all find matches"]] [list menus::text_only menus::find_select_all_command]
02259
02260 $mb add separator
02261
02262 $mb add command -label [msgcat::mc "Find and Replace"] -underline 9 -command [list menus::text_only gui::search_and_replace]
02263 launcher::register [make_menu_cmd "Find" [msgcat::mc "Find and Replace"]] [list menus::text_only gui::search_and_replace]
02264
02265 $mb add separator
02266
02267 $mb add command -label [msgcat::mc "Jump Backward"] -underline 5 -command [list menus::text_only gui::jump_to_cursor -1 1]
02268 launcher::register [make_menu_cmd "Find" [msgcat::mc "Jump backward"]] [list menus::text_only gui::jump_to_cursor -1 1]
02269
02270 $mb add command -label [msgcat::mc "Jump Forward"] -underline 5 -command [list menus::text_only gui::jump_to_cursor 1 1]
02271 launcher::register [make_menu_cmd "Find" [msgcat::mc "Jump forward"]] [list menus::text_only gui::jump_to_cursor 1 1]
02272
02273 $mb add command -label [msgcat::mc "Jump To Line"] -underline 8 -command [list menus::text_only menus::jump_to_line]
02274 launcher::register [make_menu_cmd "Find" [msgcat::mc "Jump to line"]] [list menus::text_only menus::jump_to_line]
02275
02276 $mb add separator
02277
02278 $mb add command -label [msgcat::mc "Next Difference"] -underline 0 -command [list menus::text_only gui::jump_to_difference 1 1]
02279 launcher::register [make_menu_cmd "Find" [msgcat::mc "Goto next difference"]] [list menus::text_only gui::jump_to_difference 1 1]
02280
02281 $mb add command -label [msgcat::mc "Previous Difference"] -underline 0 -command [list menus::text_only gui::jump_to_difference -1 1]
02282 launcher::register [make_menu_cmd "Find" [msgcat::mc "Goto previous difference"]] [list menus::text_only gui::jump_to_difference -1 1]
02283
02284 $mb add command -label [msgcat::mc "Show Selected Line Change"] -underline 19 -command [list menus::text_only gui::show_difference_line_change 1]
02285 launcher::register [make_menu_cmd "Find" [msgcat::mc "Show selected line change"]] [list menus::text_only gui::show_difference_line_change 1]
02286
02287 $mb add separator
02288
02289 $mb add cascade -label [msgcat::mc "Markers"] -underline 5 -menu [make_menu $mb.markerPopup -tearoff 0 -postcommand [list menus::find_marker_posting $mb.markerPopup]]
02290
02291 $mb add separator
02292
02293 $mb add command -label [msgcat::mc "Find Matching Bracket"] -underline 5 -command [list menus::text_only gui::show_match_pair]
02294 launcher::register [make_menu_cmd "Find" [msgcat::mc "Find matching character pair"]] [list menus::text_only gui::show_match_pair]
02295
02296 $mb add separator
02297
02298 $mb add command -label [msgcat::mc "Find Next Bracket Mismatch"] -command [list menus::text_only gui::goto_mismatch next]
02299 launcher::register [make_menu_cmd "Find" [msgcat::mc "Find next mismatching bracket"]] [list menus::text_only gui::goto_mismatch next]
02300
02301 $mb add command -label [msgcat::mc "Find Previous Bracket Mismatch"] -command [list menus::text_only gui::goto_mismatch prev]
02302 launcher::register [make_menu_cmd "Find" [msgcat::mc "Find previous mismatching bracket"]] [list menus::text_only gui::goto_mismatch prev]
02303
02304 $mb add separator
02305
02306 $mb add command -label [msgcat::mc "Find In Files"] -underline 5 -command [list menus::main_only search::fif_start]
02307 launcher::register [make_menu_cmd "Find" [msgcat::mc "Find in files"]] [list menus::main_only search::fif_start]
02308
02309 # Add marker popup launchers
02310 launcher::register [make_menu_cmd "Find" [msgcat::mc "Create marker at current line"]] [list menus::text_only gui::create_current_marker]
02311 launcher::register [make_menu_cmd "Find" [msgcat::mc "Remove marker from current line"]] [list menus::text_only gui::remove_current_marker]
02312 launcher::register [make_menu_cmd "Find" [msgcat::mc "Remove all markers from current buffer"]] [list menus::text_only gui::remove_current_markers]
02313 launcher::register [make_menu_cmd "Find" [msgcat::mc "Remove all markers"]] [list gui::remove_all_markers]
02314
02315 }
02316
02317 ######################################################################
02318 # Called just prior to posting the find menu. Sets the state of the menu
02319 # items to match the current UI state.
02320 proc find_posting {mb} {
02321
02322 if {[catch { gui::get_info {} current txt readonly diff }]} {
02323 $mb entryconfigure [msgcat::mc "Find"] -state disabled
02324 $mb entryconfigure [msgcat::mc "Find and Replace"] -state disabled
02325 $mb entryconfigure [msgcat::mc "Find Next"] -state disabled
02326 $mb entryconfigure [msgcat::mc "Find Previous"] -state disabled
02327 $mb entryconfigure [msgcat::mc "Select Current Match"] -state disabled
02328 $mb entryconfigure [msgcat::mc "Select All Matches"] -state disabled
02329 $mb entryconfigure [msgcat::mc "Jump Backward"] -state disabled
02330 $mb entryconfigure [msgcat::mc "Jump Forward"] -state disabled
02331 $mb entryconfigure [msgcat::mc "Next Difference"] -state disabled
02332 $mb entryconfigure [msgcat::mc "Previous Difference"] -state disabled
02333 $mb entryconfigure [msgcat::mc "Show Selected Line Change"] -state disabled
02334 $mb entryconfigure [msgcat::mc "Markers"] -state disabled
02335 $mb entryconfigure [msgcat::mc "Find Matching Bracket"] -state disabled
02336 $mb entryconfigure [msgcat::mc "Find Next Bracket Mismatch"] -state disabled
02337 $mb entryconfigure [msgcat::mc "Find Previous Bracket Mismatch"] -state disabled
02338 } else {
02339 set readonly_state [expr {($readonly || $diff) ? "disabled" : "normal"}]
02340 set found_state [expr {[search::enable_find_view $txt] ? "normal" : "disabled"}]
02341 set sel_curr_state [expr {[search::enable_select_current $txt] ? "normal" : "disabled"}]
02342 set jump_forw_state [expr {[gui::jump_to_cursor -1 0] ? "normal" : "disabled"}]
02343 set jump_back_state [expr {[gui::jump_to_cursor 1 0] ? "normal" : "disabled"}]
02344 set jump_diff_state [expr {[gui::jump_to_difference 1 0] ? "normal" : "disabled"}]
02345 set show_line_state [expr {[gui::show_difference_line_change 0] ? "normal" : "disabled"}]
02346 set next_mism_state [expr {[gui::goto_mismatch next -check 1] ? "normal" : "disabled"}]
02347 set prev_mism_state [expr {[gui::goto_mismatch prev -check 1] ? "normal" : "disabled"}]
02348 $mb entryconfigure [msgcat::mc "Find"] -state normal
02349 $mb entryconfigure [msgcat::mc "Find and Replace"] -state $readonly_state
02350 $mb entryconfigure [msgcat::mc "Find Next"] -state $found_state
02351 $mb entryconfigure [msgcat::mc "Find Previous"] -state $found_state
02352 $mb entryconfigure [msgcat::mc "Select Current Match"] -state $sel_curr_state
02353 $mb entryconfigure [msgcat::mc "Select All Matches"] -state $found_state
02354 $mb entryconfigure [msgcat::mc "Jump Backward"] -state $jump_back_state
02355 $mb entryconfigure [msgcat::mc "Jump Forward"] -state $jump_forw_state
02356 $mb entryconfigure [msgcat::mc "Next Difference"] -state $jump_diff_state
02357 $mb entryconfigure [msgcat::mc "Previous Difference"] -state $jump_diff_state
02358 $mb entryconfigure [msgcat::mc "Show Selected Line Change"] -state $show_line_state
02359 $mb entryconfigure [msgcat::mc "Find Matching Bracket"] -state $readonly_state
02360 $mb entryconfigure [msgcat::mc "Find Next Bracket Mismatch"] -state $next_mism_state
02361 $mb entryconfigure [msgcat::mc "Find Previous Bracket Mismatch"] -state $prev_mism_state
02362 $mb entryconfigure [msgcat::mc "Markers"] -state normal
02363 }
02364
02365 }
02366
02367 ######################################################################
02368 # Called when the marker menu is opened.
02369 proc find_marker_posting {mb} {
02370
02371 gui::get_info {} current tab txt
02372
02373 set line_exists [markers::exists_at_line $tab [lindex [split [$txt index insert] .] 0]]
02374 set create_state [expr {$line_exists ? "disabled" : "normal"}]
02375 set remove_state [expr {$line_exists ? "normal" : "disabled"}]
02376 set tab_state [expr {[markers::exists $tab] ? "normal" : "disabled"}]
02377 set all_state [expr {[markers::exists *] ? "normal" : "disabled"}]
02378
02379 # Clear the menu
02380 $mb delete 0 end
02381
02382 # Populate the markerPopup menu
02383 $mb add command -label [msgcat::mc "Create at Current Line"] -underline 0 -command [list menus::text_only gui::create_current_marker] -state $create_state
02384 $mb add separator
02385 $mb add command -label [msgcat::mc "Remove From Current Line"] -underline 0 -command [list menus::text_only gui::remove_current_marker] -state $remove_state
02386 $mb add command -label [msgcat::mc "Remove All From Current Buffer"] -underline 24 -command [list menus::text_only gui::remove_current_markers] -state $tab_state
02387 $mb add command -label [msgcat::mc "Remove All Markers"] -underline 7 -command [list menus::main_only gui::remove_all_markers] -state $all_state
02388
02389 if {[llength [set markers [gui::get_marker_list]]] > 0} {
02390 $mb add separator
02391 $mb add command -label [msgcat::mc "Markers"] -state disabled
02392 foreach marker $markers {
02393 lassign $marker name txt mname
02394 $mb add command -label " $name" -command [list gui::jump_to_marker $txt $mname]
02395 }
02396 }
02397
02398 }
02399
02400 ######################################################################
02401 # Finds the next occurrence of the find regular expression for the current
02402 # text widget.
02403 proc find_next_command {} {
02404
02405 search::find_next [gui::current_txt]
02406
02407 }
02408
02409 ######################################################################
02410 # Finds the previous occurrence of the find regular expression for the
02411 # current text widget.
02412 proc find_prev_command {} {
02413
02414 search::find_prev [gui::current_txt]
02415
02416 }
02417
02418 ######################################################################
02419 # Selects the current found text item to the selection.
02420 proc find_select_current_command {} {
02421
02422 search::select_current [gui::current_txt]
02423
02424 }
02425
02426 ######################################################################
02427 # Adds all matched values to the selection.
02428 proc find_select_all_command {} {
02429
02430 search::select_all [gui::current_txt]
02431
02432 }
02433
02434 ######################################################################
02435 # Jumps to a line that is entered by the user.
02436 proc jump_to_line {} {
02437
02438 set linenum ""
02439
02440 # Get the line number from the user
02441 if {[gui::get_user_response [format "%s:" [msgcat::mc "Line Number"]] linenum] && [string is integer $linenum]} {
02442 edit::jump_to_line [gui::current_txt].t $linenum.0
02443 }
02444
02445 }
02446
02447 ######################################################################
02448 # Adds the view menu commands.
02449 proc add_view {mb} {
02450
02451 if {[preferences::get View/ShowSidebar]} {
02452 $mb add command -label [msgcat::mc "Hide Sidebar"] -underline 5 -command [list menus::main_only menus::hide_sidebar_view $mb]
02453 } else {
02454 $mb add command -label [msgcat::mc "Show Sidebar"] -underline 5 -command [list menus::main_only menus::show_sidebar_view $mb]
02455 }
02456 launcher::register [make_menu_cmd "View" [msgcat::mc "Show sidebar"]] [list menus::main_only menus::show_sidebar_view $mb]
02457 launcher::register [make_menu_cmd "View" [msgcat::mc "Hide sidebar"]] [list menus::main_only menus::hide_sidebar_view $mb]
02458
02459 if {[preferences::get View/ShowTabBar]} {
02460 $mb add command -label [msgcat::mc "Hide Tab Bar"] -underline 5 -command [list menus::main_only menus::hide_tab_view $mb]
02461 } else {
02462 $mb add command -label [msgcat::mc "Show Tab Bar"] -underline 5 -command [list menus::main_only menus::show_tab_view $mb]
02463 }
02464 launcher::register [make_menu_cmd "View" [msgcat::mc "Show tab bar"]] [list menus::main_only menus::show_tab_view $mb]
02465 launcher::register [make_menu_cmd "View" [msgcat::mc "Hide tab bar"]] [list menus::main_only menus::hide_tab_view $mb]
02466
02467 if {[preferences::get View/ShowStatusBar]} {
02468 $mb add command -label [msgcat::mc "Hide Status Bar"] -underline 12 -command [list menus::main_only menus::hide_status_view $mb]
02469 } else {
02470 $mb add command -label [msgcat::mc "Show Status Bar"] -underline 12 -command [list menus::main_only menus::show_status_view $mb]
02471 }
02472 launcher::register [make_menu_cmd "View" [msgcat::mc "Show status bar"]] [list menus::main_only menus::show_status_view $mb]
02473 launcher::register [make_menu_cmd "View" [msgcat::mc "Hide status bar"]] [list menus::main_only menus::hide_status_view $mb]
02474
02475 $mb add separator
02476
02477 if {[preferences::get View/ShowLineNumbers]} {
02478 $mb add command -label [msgcat::mc "Hide Line Numbers"] -underline 5 -command [list menus::main_only menus::hide_line_numbers $mb]
02479 } else {
02480 $mb add command -label [msgcat::mc "Show Line Numbers"] -underline 5 -command [list menus::main_only menus::show_line_numbers $mb]
02481 }
02482 launcher::register [make_menu_cmd "View" [msgcat::mc "Show line numbers"]] [list menus::main_only menus::show_line_numbers $mb]
02483 launcher::register [make_menu_cmd "View" [msgcat::mc "Hide line numbers"]] [list menus::main_only menus::hide_line_numbers $mb]
02484
02485 $mb add cascade -label [msgcat::mc "Line Numbering"] -menu [make_menu $mb.numPopup -tearoff 0]
02486 $mb add checkbutton -label [msgcat::mc "Line Wrapping"] -underline 5 -variable menus::line_wrapping -command [list menus::main_only menus::set_line_wrapping]
02487
02488 $mb add separator
02489
02490 if {[preferences::get View/ShowMarkerMap]} {
02491 $mb add command -label [msgcat::mc "Hide Marker Map"] -underline 8 -command [list menus::main_only menus::hide_marker_map $mb]
02492 } else {
02493 $mb add command -label [msgcat::mc "Show Marker Map"] -underline 8 -command [list menus::main_only menus::show_marker_map $mb]
02494 }
02495 launcher::register [make_menu_cmd "View" [msgcat::mc "Show marker map"]] [list menus::main_only menus::show_marker_map $mb]
02496 launcher::register [make_menu_cmd "View" [msgcat::mc "Hide marker map"]] [list menus::main_only menus::hide_marker_map $mb]
02497
02498 $mb add command -label [msgcat::mc "Hide Meta Characters"] -underline 5 -command [list menus::main_only menus::hide_meta_chars $mb]
02499 launcher::register [make_menu_cmd "View" [msgcat::mc "Show meta characters"]] [list menus::main_only menus::show_meta_chars $mb]
02500 launcher::register [make_menu_cmd "View" [msgcat::mc "Hide meta characters"]] [list menus::main_only menus::hide_meta_chars $mb]
02501
02502 $mb add separator
02503
02504 $mb add command -label [msgcat::mc "Display Text Info"] -underline 13 -command [list menus::main_only menus::display_text_info]
02505 launcher::register [make_menu_cmd "View" [msgcat::mc "Display text information"]] [list menus::main_only menus::display_text_info]
02506
02507 $mb add separator
02508
02509 $mb add checkbutton -label [msgcat::mc "Split View"] -underline 6 -variable menus::show_split_pane -command [list menus::main_only gui::toggle_split_pane]
02510 launcher::register [make_menu_cmd "View" [msgcat::mc "Toggle split view mode"]] [list menus::main_only gui::toggle_split_pane]
02511
02512 $mb add checkbutton -label [msgcat::mc "Bird's Eye View"] -underline 0 -variable menus::show_birdseye -command [list menus::main_only gui::toggle_birdseye]
02513 launcher::register [make_menu_cmd "View" [msgcat::mc "Toggle bird's eye view mode"]] [list menus::main_only gui::toggle_birdseye]
02514
02515 $mb add command -label [msgcat::mc "Move to Other Pane"] -underline 0 -command [list menus::main_only gui::move_to_pane]
02516 launcher::register [make_menu_cmd "View" [msgcat::mc "Move to other pane"]] [list menus::main_only gui::move_to_pane]
02517
02518 $mb add separator
02519
02520 $mb add cascade -label [msgcat::mc "Panes"] -underline 0 -menu [make_menu $mb.panePopup -tearoff 0]
02521 $mb add cascade -label [msgcat::mc "Tabs"] -underline 0 -menu [make_menu $mb.tabPopup -tearoff 0 -postcommand "menus::view_tabs_posting $mb.tabPopup"]
02522 $mb add cascade -label [msgcat::mc "Folding"] -underline 0 -menu [make_menu $mb.foldPopup -tearoff 0 -postcommand "menus::view_fold_posting $mb.foldPopup"]
02523
02524 $mb add separator
02525
02526 $mb add cascade -label [msgcat::mc "Set Syntax"] -underline 9 -menu [syntax::create_menu $mb.syntax]
02527 $mb add cascade -label [msgcat::mc "Set Theme"] -underline 7 -menu [make_menu $mb.themeMenu -tearoff 0 -postcommand "themes::populate_theme_menu $mb.themeMenu"]
02528
02529 # Setup the line numbering popup menu
02530 $mb.numPopup add radiobutton -label [msgcat::mc "Absolute"] -variable menus::line_numbering -value absolute -command [list menus::main_only menus::set_line_numbering absolute]
02531 launcher::register [make_menu_cmd "View" [msgcat::mc "Absolute line numbering"]] [list menus::main_only menus::set_line_numbering absolute]
02532
02533 $mb.numPopup add radiobutton -label [msgcat::mc "Relative"] -variable menus::line_numbering -value relative -command [list menus::main_only menus::set_line_numbering relative]
02534 launcher::register [make_menu_cmd "View" [msgcat::mc "Relative line numbering"]] [list menus::main_only menus::set_line_numbering relative]
02535
02536 # Setup the pane popup menu
02537 $mb.panePopup add checkbutton -label [msgcat::mc "Enable Synchronized Scrolling"] -variable menus::sync_panes -command [list menus::main_only menus::sync_panes]
02538 launcher::register [make_menu_cmd "View" [msgcat::mc "Enable two-pane scrolling synchronization"]] [list menus::main_only gui::set_pane_sync 1]
02539 launcher::register [make_menu_cmd "View" [msgcat::mc "Disable two-pane scrolling Synchronization"]] [list menus::main_only gui::set_pane_sync 0]
02540
02541 $mb.panePopup add command -label [msgcat::mc "Align Panes"] -command [list menus::main_only gui::align_panes]
02542 launcher::register [make_menu_cmd "View" [msgcat::mc "Align current lines in both panes"]] [list menus::main_only gui::align_panes]
02543
02544 $mb.panePopup add separator
02545
02546 $mb.panePopup add command -label [msgcat::mc "Merge Panes"] -underline 3 -command [list menus::main_only gui::merge_panes]
02547 launcher::register [make_menu_cmd "View" [msgcat::mc "Merge panes"]] [list menus::main_only gui::merge_panes]
02548
02549 # Setup the tab popup menu
02550 $mb.tabPopup add command -label [msgcat::mc "Goto Next Tab"] -underline 5 -command [list menus::main_only gui::next_tab]
02551 launcher::register [make_menu_cmd "View" [msgcat::mc "Goto next tab"]] [list menus::main_only gui::next_tab]
02552
02553 $mb.tabPopup add command -label [msgcat::mc "Goto Previous Tab"] -underline 5 -command [list menus::main_only gui::previous_tab]
02554 launcher::register [make_menu_cmd "View" [msgcat::mc "Goto previous tab"]] [list menus::main_only gui::previous_tab]
02555
02556 $mb.tabPopup add command -label [msgcat::mc "Goto Last Tab"] -underline 5 -command [list menus::main_only gui::last_tab]
02557 launcher::register [make_menu_cmd "View" [msgcat::mc "Goto last tab"]] [list menus::main_only gui::last_tab]
02558
02559 $mb.tabPopup add command -label [msgcat::mc "Goto Other Pane"] -underline 11 -command [list menus::main_only gui::next_pane]
02560 launcher::register [make_menu_cmd "View" [msgcat::mc "Goto other pane"]] [list menus::main_only gui::next_pane]
02561
02562 $mb.tabPopup add separator
02563
02564 $mb.tabPopup add command -label [msgcat::mc "Sort Tabs"] -underline 0 -command [list menus::main_only gui::sort_tabs]
02565 launcher::register [make_menu_cmd "View" [msgcat::mc "Sort tabs"]] [list menus::main_only gui::sort_tabs]
02566
02567 $mb.tabPopup add separator
02568
02569 $mb.tabPopup add command -label [msgcat::mc "Hide Current Tab"] -underline 5 -command [list menus::main_only gui::hide_current]
02570 launcher::register [make_menu_cmd "View" [msgcat::mc "Hide Current Tab"]] [list menus::main_only gui::hide_current]
02571
02572 $mb.tabPopup add command -label [msgcat::mc "Hide All Tabs"] -underline 5 -command [list menus::main_only gui::hide_all]
02573 launcher::register [make_menu_cmd "View" [msgcat::mc "Hide All Tabs"]] [list menus::main_only gui::hide_all]
02574
02575 $mb.tabPopup add command -label [msgcat::mc "Show All Tabs"] -underline 0 -command [list menus::main_only gui::show_all]
02576 launcher::register [make_menu_cmd "View" [msgcat::mc "Show All Tabs"]] [list menus::main_only gui::show_all]
02577
02578 # Setup the folding popup menu
02579 $mb.foldPopup add checkbutton -label [msgcat::mc "Enable Code Folding"] -variable menus::code_folding -command [list menus::main_only menus::set_code_folding]
02580 launcher::register [make_menu_cmd "View" [msgcat::mc "Enable code folding"]] [list menus::main_only menus::set_code_folding 1]
02581 launcher::register [make_menu_cmd "View" [msgcat::mc "Disable code folding"]] [list menus::main_only menus::set_code_folding 0]
02582
02583 $mb.foldPopup add separator
02584
02585 $mb.foldPopup add command -label [msgcat::mc "Create Fold From Selection"] -command [list menus::text_only menus::add_fold_from_selection]
02586 launcher::register [make_menu_cmd "View" [msgcat::mc "Create fold from selection"]] [list menus::text_only menus::add_fold_from_selection]
02587
02588 $mb.foldPopup add separator
02589
02590 $mb.foldPopup add command -label [msgcat::mc "Delete Current Fold"] -command [list menus::text_only menus::delete_folds current]
02591 launcher::register [make_menu_cmd "View" [msgcat::mc "Delete fold at current line"]] [list menus::text_only menus::delete_folds current]
02592
02593 $mb.foldPopup add command -label [msgcat::mc "Delete Selected Folds"] -command [list menus::text_only menus::delete_folds selected]
02594 launcher::register [make_menu_cmd "View" [msgcat::mc "Delete all selected folds"]] [list menus::text_only menus::delete_folds selected]
02595
02596 $mb.foldPopup add command -label [msgcat::mc "Delete All Folds"] -command [list menus::text_only menus::delete_folds all]
02597 launcher::register [make_menu_cmd "View" [msgcat::mc "Delete all folds"]] [list menus::text_only menus::delete_folds all]
02598
02599 $mb.foldPopup add separator
02600
02601 $mb.foldPopup add cascade -label [msgcat::mc "Close Current Fold"] -menu [make_menu $mb.fcloseCurrPopup -tearoff 0]
02602
02603 $mb.foldPopup add cascade -label [msgcat::mc "Close Selected Folds"] -menu [make_menu $mb.fcloseSelPopup -tearoff 0]
02604
02605 $mb.foldPopup add command -label [msgcat::mc "Close All Folds"] -command [list menus::text_only menus::close_folds all]
02606 launcher::register [make_menu_cmd "View" [msgcat::mc "Close all folds"]] [list menus::text_only menus::close_folds all]
02607
02608 $mb.foldPopup add separator
02609
02610 $mb.foldPopup add cascade -label [msgcat::mc "Open Current Fold"] -menu [make_menu $mb.fopenCurrPopup -tearoff 0]
02611
02612 $mb.foldPopup add cascade -label [msgcat::mc "Open Selected Folds"] -menu [make_menu $mb.fopenSelPopup -tearoff 0]
02613
02614 $mb.foldPopup add command -label [msgcat::mc "Open All Folds"] -command [list menus::text_only menus::open_folds all]
02615 launcher::register [make_menu_cmd "View" [msgcat::mc "Open all folds"]] [list menus::text_only menus::open_folds all]
02616
02617 $mb.foldPopup add separator
02618
02619 $mb.foldPopup add command -label [msgcat::mc "Show Cursor"] -command [list menus::text_only menus::open_folds show]
02620 launcher::register [make_menu_cmd "View" [msgcat::mc "Open folds to show cursor"]] [list menus::text_only menus::open_folds show]
02621
02622 $mb.foldPopup add separator
02623
02624 $mb.foldPopup add command -label [msgcat::mc "Jump to Next Fold Mark"] -command [list menus::text_only menus::jump_to_fold next]
02625 launcher::register [make_menu_cmd "View" [msgcat::mc "Jump to the next fold indicator"]] [list menus::text_only menus::jump_to_fold next]
02626
02627 $mb.foldPopup add command -label [msgcat::mc "Jump to Previous Fold Mark"] -command [list menus::text_only menus::jump_to_fold prev]
02628 launcher::register [make_menu_cmd "View" [msgcat::mc "Jump to the previous fold indicator"]] [list menus::text_only menus::jump_to_fold prev]
02629
02630 # Setup the folding close current popup menu
02631 $mb.fcloseCurrPopup add command -label [msgcat::mc "One Level"] -command [list menus::text_only menus::close_folds current 1]
02632 $mb.fcloseCurrPopup add command -label [msgcat::mc "All Levels"] -command [list menus::text_only menus::close_folds current 0]
02633
02634 launcher::register [make_menu_cmd "View" [msgcat::mc "Close fold at current line - one level"]] [list menus::text_only menus::close_folds current 1]
02635 launcher::register [make_menu_cmd "View" [msgcat::mc "Close fold at current line - all levels"]] [list menus::text_only menus::close_folds current 0]
02636
02637 # Setup the folding close selected popup menu
02638 $mb.fcloseSelPopup add command -label [msgcat::mc "One Level"] -command [list menus::text_only menus::close_folds selected 1]
02639 $mb.fcloseSelPopup add command -label [msgcat::mc "All Levels"] -command [list menus::text_only menus::close_folds selected 0]
02640
02641 launcher::register [make_menu_cmd "View" [msgcat::mc "Close selected folds - one level"]] [list menus::text_only menus::close_folds selected 1]
02642 launcher::register [make_menu_cmd "View" [msgcat::mc "Close selected folds - all levels"]] [list menus::text_only menus::close_folds selected 0]
02643
02644 # Setup the folding open current popup menu
02645 $mb.fopenCurrPopup add command -label [msgcat::mc "One Level"] -command [list menus::text_only menus::open_folds current 1]
02646 $mb.fopenCurrPopup add command -label [msgcat::mc "All Levels"] -command [list menus::text_only menus::open_folds current 0]
02647
02648 launcher::register [make_menu_cmd "View" [msgcat::mc "Open fold at current line - one level"]] [list menus::text_only menus::open_folds current 1]
02649 launcher::register [make_menu_cmd "View" [msgcat::mc "Open fold at current line - all levels"]] [list menus::text_only menus::open_folds current 0]
02650
02651 # Setup the folding open selected popup menu
02652 $mb.fopenSelPopup add command -label [msgcat::mc "One Level"] -command [list menus::text_only menus::open_folds selected 1]
02653 $mb.fopenSelPopup add command -label [msgcat::mc "All Levels"] -command [list menus::text_only menus::open_folds selected 0]
02654
02655 launcher::register [make_menu_cmd "View" [msgcat::mc "Open selected folds - one level"]] [list menus::text_only menus::open_folds selected 1]
02656 launcher::register [make_menu_cmd "View" [msgcat::mc "Open selected folds - all levels"]] [list menus::text_only menus::open_folds selected 0]
02657
02658 }
02659
02660 ######################################################################
02661 # Called just prior to posting the view menu. Sets the state of the
02662 # menu options to match the current UI state.
02663 proc view_posting {mb} {
02664
02665 variable show_split_pane
02666 variable show_birdseye
02667 variable line_numbering
02668 variable line_wrapping
02669
02670 if {([gui::tabs_in_pane] < 2) && ([gui::panes] < 2)} {
02671 $mb entryconfigure [msgcat::mc "Tabs"] -state disabled
02672 } else {
02673 $mb entryconfigure [msgcat::mc "Tabs"] -state normal
02674 }
02675
02676 if {[gui::panes] < 2} {
02677 $mb entryconfigure [msgcat::mc "Panes"] -state disabled
02678 } else {
02679 $mb entryconfigure [msgcat::mc "Panes"] -state normal
02680 }
02681
02682 if {[gui::current_txt] eq ""} {
02683 catch { $mb entryconfigure [msgcat::mc "Show Line Numbers"] -state disabled }
02684 catch { $mb entryconfigure [msgcat::mc "Hide Line Numbers"] -state disabled }
02685 catch { $mb entryconfigure [msgcat::mc "Line Numbering"] -state disabled }
02686 $mb entryconfigure [msgcat::mc "Line Wrapping"] -state disabled
02687 catch { $mb entryconfigure [msgcat::mc "Show Marker Map"] -state disabled }
02688 catch { $mb entryconfigure [msgcat::mc "Hide Marker Map"] -state disabled }
02689 catch { $mb entryconfigure [msgcat::mc "Show Meta Characters"] -state disabled }
02690 catch { $mb entryconfigure [msgcat::mc "Hide Meta Characters"] -state disabled }
02691 $mb entryconfigure [msgcat::mc "Display Text Info"] -state disabled
02692 $mb entryconfigure [msgcat::mc "Split View"] -state disabled
02693 $mb entryconfigure [msgcat::mc "Bird's Eye View"] -state disabled
02694 $mb entryconfigure [msgcat::mc "Move to Other Pane"] -state disabled
02695 if {[tk windowingsystem] ne "aqua"} {
02696 $mb entryconfigure [msgcat::mc "Set Syntax"] -state disabled
02697 }
02698 $mb entryconfigure [msgcat::mc "Folding"] -state disabled
02699 } else {
02700 gui::get_info {} current tab txt
02701 catch { $mb entryconfigure [msgcat::mc "Show Line Numbers"] -state normal }
02702 catch { $mb entryconfigure [msgcat::mc "Hide Line Numbers"] -state normal }
02703 catch { $mb entryconfigure [msgcat::mc "Line Numbering"] -state normal }
02704 $mb entryconfigure [msgcat::mc "Line Wrapping"] -state normal
02705 if {[markers::exists $tab]} {
02706 catch { $mb entryconfigure [msgcat::mc "Show Marker Map"] -state normal }
02707 catch { $mb entryconfigure [msgcat::mc "Hide Marker Map"] -state normal }
02708 } else {
02709 catch { $mb entryconfigure [msgcat::mc "Show Marker Map"] -state disabled }
02710 catch { $mb entryconfigure [msgcat::mc "Hide Marker Map"] -state disabled }
02711 }
02712 if {[llength [[gui::current_txt] syntax metaclasses]] > 0} {
02713 if {[[gui::current_txt] cget -hidemeta] == 0} {
02714 set lbl [msgcat::mc "Hide Meta Characters"]
02715 set cmd [list menus::main_only menus::hide_meta_chars $mb]
02716 } else {
02717 set lbl [msgcat::mc "Show Meta Characters"]
02718 set cmd [list menus::main_only menus::show_meta_chars $mb]
02719 }
02720 catch { $mb entryconfigure [msgcat::mc "Show Meta Characters"] -label $lbl -command $cmd -state normal }
02721 catch { $mb entryconfigure [msgcat::mc "Hide Meta Characters"] -label $lbl -command $cmd -state normal }
02722 } else {
02723 catch { $mb entryconfigure [msgcat::mc "Show Meta Characters"] -state disabled }
02724 catch { $mb entryconfigure [msgcat::mc "Hide Meta Characters"] -state disabled }
02725 }
02726 $mb entryconfigure [msgcat::mc "Display Text Info"] -state normal
02727 $mb entryconfigure [msgcat::mc "Split View"] -state normal
02728 $mb entryconfigure [msgcat::mc "Bird's Eye View"] -state normal
02729 if {[gui::movable_to_other_pane]} {
02730 $mb entryconfigure [msgcat::mc "Move to Other Pane"] -state normal
02731 } else {
02732 $mb entryconfigure [msgcat::mc "Move to Other Pane"] -state disabled
02733 }
02734 if {[tk windowingsystem] ne "aqua"} {
02735 $mb entryconfigure [msgcat::mc "Set Syntax"] -state normal
02736 }
02737 $mb entryconfigure [msgcat::mc "Folding"] -state normal
02738 gui::get_info {} current txt2 beye
02739 set show_split_pane [winfo exists $txt2]
02740 set show_birdseye [winfo exists $beye]
02741
02742 # Get the current line numbering
02743 set line_numbering [[gui::current_txt] cget -linemap_type]
02744
02745 # Get the current line wrapping
02746 set line_wrapping [expr {[[gui::current_txt] cget -wrap] eq "word"}]
02747
02748 }
02749
02750 }
02751
02752 ######################################################################
02753 # Called just prior to posting the view/tabs menu. Sets the state of
02754 # the menu options to match the current UI state.
02755 proc view_tabs_posting {mb} {
02756
02757 if {[gui::tabs_in_pane] < 2} {
02758 $mb entryconfigure [msgcat::mc "Goto Next Tab"] -state disabled
02759 $mb entryconfigure [msgcat::mc "Goto Previous Tab"] -state disabled
02760 $mb entryconfigure [msgcat::mc "Goto Last Tab"] -state disabled
02761 $mb entryconfigure [msgcat::mc "Sort Tabs"] -state disabled
02762 } else {
02763 $mb entryconfigure [msgcat::mc "Goto Next Tab"] -state normal
02764 $mb entryconfigure [msgcat::mc "Goto Previous Tab"] -state normal
02765 $mb entryconfigure [msgcat::mc "Goto Last Tab"] -state normal
02766 $mb entryconfigure [msgcat::mc "Sort Tabs"] -state normal
02767 }
02768
02769 if {[gui::panes] < 2} {
02770 $mb entryconfigure [msgcat::mc "Goto Other Pane"] -state disabled
02771 } else {
02772 $mb entryconfigure [msgcat::mc "Goto Other Pane"] -state normal
02773 }
02774
02775 }
02776
02777 ######################################################################
02778 # Called just prior to posting the view/folding menu. Sets the state
02779 # fo the menu options to match the current UI state.
02780 proc view_fold_posting {mb} {
02781
02782 variable code_folding
02783
02784 # Get the current text widget
02785 set txt [gui::current_txt]
02786 set state [folding::fold_state $txt [lindex [split [$txt index insert] .] 0]]
02787 set code_folding [folding::get_enable $txt]
02788 set sel_state [expr {([$txt tag ranges sel] ne "") ? "normal" : "disabled"}]
02789
02790 if {[folding::get_method $txt] eq "manual"} {
02791 $mb entryconfigure [msgcat::mc "Create Fold From Selection"] -state $sel_state
02792 $mb entryconfigure [msgcat::mc "Delete Selected Folds"] -state $sel_state
02793 $mb entryconfigure [msgcat::mc "Delete Current Fold"] -state normal
02794 $mb entryconfigure [msgcat::mc "Delete All Folds"] -state normal
02795 } else {
02796 $mb entryconfigure [msgcat::mc "Create Fold From Selection"] -state disabled
02797 $mb entryconfigure [msgcat::mc "Delete Selected Folds"] -state disabled
02798 $mb entryconfigure [msgcat::mc "Delete Current Fold"] -state disabled
02799 $mb entryconfigure [msgcat::mc "Delete All Folds"] -state disabled
02800 }
02801
02802 $mb entryconfigure [msgcat::mc "Close Selected Folds"] -state $sel_state
02803 $mb entryconfigure [msgcat::mc "Open Selected Folds"] -state $sel_state
02804
02805 if {$state eq "open"} {
02806 $mb entryconfigure [msgcat::mc "Close Current Fold"] -state normal
02807 } else {
02808 $mb entryconfigure [msgcat::mc "Close Current Fold"] -state disabled
02809 }
02810
02811 if {$state eq "close"} {
02812 $mb entryconfigure [msgcat::mc "Open Current Fold"] -state normal
02813 } else {
02814 $mb entryconfigure [msgcat::mc "Open Current Fold"] -state disabled
02815 }
02816
02817 }
02818
02819 ######################################################################
02820 # Shows the sidebar panel.
02821 proc show_sidebar_view {mb} {
02822
02823 # Convert the menu command into the hide sidebar command
02824 if {![catch {$mb entryconfigure [msgcat::mc "Show Sidebar"] -label [msgcat::mc "Hide Sidebar"] -command [list menus::main_only menus::hide_sidebar_view $mb]}]} {
02825 gui::show_sidebar_view
02826 }
02827
02828 }
02829
02830 ######################################################################
02831 # Hides the sidebar panel.
02832 proc hide_sidebar_view {mb} {
02833
02834 # Convert the menu command into the hide sidebar command
02835 if {![catch {$mb entryconfigure [msgcat::mc "Hide Sidebar"] -label [msgcat::mc "Show Sidebar"] -command [list menus::main_only menus::show_sidebar_view $mb]}]} {
02836 gui::hide_sidebar_view
02837 }
02838
02839 }
02840
02841 ######################################################################
02842 # Shows the console.
02843 proc show_console_view {mb} {
02844
02845 # Convert the menu command into the hide console command
02846 if {![catch {$mb entryconfigure [msgcat::mc "Show Tcl Console"] -label [msgcat::mc "Hide Tcl Console"] -command [list menus::main_only menus::hide_console_view $mb]}]} {
02847 gui::show_console_view
02848 }
02849
02850 }
02851
02852 ######################################################################
02853 # Hides the console.
02854 proc hide_console_view {mb} {
02855
02856 # Convert the menu command into the show console command
02857 if {![catch {$mb entryconfigure [msgcat::mc "Hide Tcl Console"] -label [msgcat::mc "Show Tcl Console"] -command [list menus::main_only menus::show_console_view $mb]}]} {
02858 gui::hide_console_view
02859 }
02860
02861 }
02862
02863 ######################################################################
02864 # Shows the tab bar.
02865 proc show_tab_view {mb} {
02866
02867 # Convert the menu command into the hide tab bar command
02868 if {![catch {$mb entryconfigure [msgcat::mc "Show Tab Bar"] -label [msgcat::mc "Hide Tab Bar"] -command [list menus::main_only menus::hide_tab_view $mb]}]} {
02869 gui::show_tab_view
02870 }
02871
02872 }
02873
02874 ######################################################################
02875 # Hides the tab bar.
02876 proc hide_tab_view {mb} {
02877
02878 # Convert the menu command into the show tab bar command
02879 if {![catch {$mb entryconfigure [msgcat::mc "Hide Tab Bar"] -label [msgcat::mc "Show Tab Bar"] -command [list menus::main_only menus::show_tab_view $mb]}]} {
02880 gui::hide_tab_view
02881 }
02882
02883 }
02884
02885 ######################################################################
02886 # Shows the status bar.
02887 proc show_status_view {mb} {
02888
02889 # Convert the menu command into the hide status bar command
02890 if {![catch {$mb entryconfigure [msgcat::mc "Show Status Bar"] -label [msgcat::mc "Hide Status Bar"] -command [list menus::main_only menus::hide_status_view $mb]}]} {
02891 gui::show_status_view
02892 }
02893
02894 }
02895
02896 ######################################################################
02897 # Hides the status bar.
02898 proc hide_status_view {mb} {
02899
02900 # Convert the menu command into the show status bar command
02901 if {![catch {$mb entryconfigure [msgcat::mc "Hide Status Bar"] -label [msgcat::mc "Show Status Bar"] -command [list menus::main_only menus::show_status_view $mb]}]} {
02902 gui::hide_status_view
02903 }
02904
02905 }
02906
02907 ######################################################################
02908 # Shows the line numbers in the editor.
02909 proc show_line_numbers {mb} {
02910
02911 # Convert the menu command into the hide line numbers command
02912 if {![catch {$mb entryconfigure [msgcat::mc "Show Line Numbers"] -label [msgcat::mc "Hide Line Numbers"] -command [list menus::main_only menus::hide_line_numbers $mb]}]} {
02913 gui::set_line_number_view 1
02914 }
02915
02916 }
02917
02918 ######################################################################
02919 # Hides the line numbers in the editor.
02920 proc hide_line_numbers {mb} {
02921
02922 # Convert the menu command into the hide line numbers command
02923 if {![catch {$mb entryconfigure [msgcat::mc "Hide Line Numbers"] -label [msgcat::mc "Show Line Numbers"] -command [list menus::main_only menus::show_line_numbers $mb]}]} {
02924 gui::set_line_number_view 0
02925 }
02926
02927 }
02928
02929 ######################################################################
02930 # Sets the line numbering for the current editing buffer to either
02931 # 'absolute' or 'relative'.
02932 proc set_line_numbering {type} {
02933
02934 [gui::current_txt] configure -linemap_type $type
02935
02936 }
02937
02938 ######################################################################
02939 # Sets the line wrapping mode based on the configured value in the menu.
02940 proc set_line_wrapping {} {
02941
02942 variable line_wrapping
02943
02944 [gui::current_txt] configure -wrap [expr {$line_wrapping ? "word" : "none"}]
02945
02946 }
02947
02948 ######################################################################
02949 # Shows the marker map for the current edit window.
02950 proc show_marker_map {mb} {
02951
02952 # Convert the menu command into the hide marker map command
02953 if {![catch {$mb entryconfigure [msgcat::mc "Show Marker Map"] -label [msgcat::mc "Hide Marker Map"] -command [list menus::main_only menus::hide_marker_map $mb]}]} {
02954 [winfo parent [gui::current_txt]].vb configure -markhide1 0
02955 }
02956
02957 }
02958
02959 ######################################################################
02960 # Hides the marker map for the current edit window.
02961 proc hide_marker_map {mb} {
02962
02963 # Convert the menu command into the show marker map command
02964 if {![catch {$mb entryconfigure [msgcat::mc "Hide Marker Map"] -label [msgcat::mc "Show Marker Map"] -command [list menus::main_only menus::show_marker_map $mb]}]} {
02965 [winfo parent [gui::current_txt]].vb configure -markhide1 1
02966 }
02967
02968 }
02969
02970 ######################################################################
02971 # Shows the meta characters in the current edit window.
02972 proc show_meta_chars {mb} {
02973
02974 [gui::current_txt] configure -hidemeta 0
02975
02976 }
02977
02978 ######################################################################
02979 # Hides the meta characters in the current edit window.
02980 proc hide_meta_chars {mb} {
02981
02982 [gui::current_txt] configure -hidemeta 1
02983
02984 }
02985
02986 ######################################################################
02987 # Display the line and character counts in the information bar.
02988 proc display_text_info {} {
02989
02990 gui::display_file_counts [gui::current_txt].t
02991
02992 }
02993
02994 ######################################################################
02995 # Enables/disables two-pane scroll synchronization.
02996 proc sync_panes {} {
02997
02998 variable sync_panes
02999
03000 gui::set_pane_sync $sync_panes
03001
03002 }
03003
03004 ######################################################################
03005 # Disables code folding from being drawn.
03006 proc set_code_folding {{value ""}} {
03007
03008 variable code_folding
03009
03010 # Get the current text widget
03011 set txt [gui::current_txt]
03012
03013 # Set the fold enable value
03014 if {$value eq ""} {
03015 folding::set_fold_enable $txt $code_folding
03016 } else {
03017 folding::set_fold_enable $txt [set code_folding $value]
03018 }
03019
03020 }
03021
03022 ######################################################################
03023 # Create a fold for the selected code and close the fold.
03024 proc add_fold_from_selection {} {
03025
03026 folding::close_selected [gui::current_txt]
03027
03028 }
03029
03030 ######################################################################
03031 # Delete one or more folds based on type. Valid values for type are:
03032 # - current (deletes fold at the current line)
03033 # - selected (deletes any selected folds)
03034 # - all (deletes all folds)
03035 proc delete_folds {type} {
03036
03037 set txt [gui::current_txt]
03038
03039 switch $type {
03040 current { folding::delete_fold $txt [lindex [split [$txt index insert] .] 0] }
03041 all { folding::delete_all_folds $txt }
03042 selected {
03043 foreach {startpos endpos} [$txt tag ranges sel] {
03044 set startline [lindex [split $startpos .] 0]
03045 set endline [lindex [split $endpos .] 0]
03046 folding::delete_folds_in_range $txt $startline $endline
03047 }
03048 }
03049 }
03050
03051 }
03052
03053 ######################################################################
03054 # Closes one or more folds based on type and depth. Valid values for
03055 # type are:
03056 # - current (closes fold at the current line)
03057 # - selected (closes any selected folds)
03058 # - all (closes all folds)
03059 proc close_folds {type {depth 0}} {
03060
03061 set txt [gui::current_txt]
03062
03063 switch $type {
03064 current { folding::close_fold $depth $txt [lindex [split [$txt index insert] .] 0] }
03065 all { folding::close_all_folds $txt }
03066 selected {
03067 foreach {startpos endpos} [$txt tag ranges sel] {
03068 set startline [lindex [split $startpos .] 0]
03069 set endline [lindex [split $endpos .] 0]
03070 folding::close_folds_in_range $txt $startline $endline $depth
03071 }
03072 }
03073 }
03074
03075 }
03076
03077 ######################################################################
03078 # Opens one or more folds based on type and depth. Valid values for
03079 # type are:
03080 # - current (opens fold at the current line)
03081 # - selected (opens any selected folds)
03082 # - all (opens all folds)
03083 proc open_folds {type {depth 0}} {
03084
03085 set txt [gui::current_txt]
03086
03087 switch $type {
03088 current { folding::open_fold $depth $txt [lindex [split [$txt index insert] .] 0] }
03089 all { folding::open_all_folds $txt }
03090 show { folding::show_line $txt [lindex [split [$txt index insert] .] 0] }
03091 selected {
03092 foreach {startpos endpos} [$txt tag ranges sel] {
03093 set startline [lindex [split $startpos .] 0]
03094 set endline [lindex [split $endpos .] 0]
03095 folding::open_folds_in_range $txt $startline $endline $depth
03096 }
03097 }
03098 }
03099
03100 }
03101
03102 ######################################################################
03103 # Jump to the fold indicator in the given direction from the current
03104 # cursor position.
03105 proc jump_to_fold {dir} {
03106
03107 folding::jump_to [gui::current_txt] $dir
03108
03109 }
03110
03111 ######################################################################
03112 # Adds the tools menu commands.
03113 proc add_tools {mb} {
03114
03115 # Add tools menu commands
03116 $mb add command -label [msgcat::mc "Launcher"] -underline 0 -command [list menus::main_only launcher::launch]
03117
03118 $mb add command -label [msgcat::mc "Theme Editor"] -underline 0 -command [list menus::theme_edit_command]
03119 launcher::register [make_menu_cmd "Tools" [msgcat::mc "Run theme editor"]] [list menus::theme_edit_command]
03120
03121 }
03122
03123 ######################################################################
03124 # Called prior to the tools menu posting.
03125 proc tools_posting {mb} {
03126
03127 variable profile_report
03128
03129 if {[::tke_development]} {
03130
03131 catch {
03132 if {[file exists $profile_report]} {
03133 $mb entryconfigure [msgcat::mc "Show Last Profiling Report"] -state normal
03134 } else {
03135 $mb entryconfigure [msgcat::mc "Show Last Profiling Report"] -state disabled
03136 }
03137 }
03138
03139 # Handle the state of the Show/Hide Console entry (if it exists)
03140 if {[winfo exists .tkcon]} {
03141 if {[winfo ismapped .tkcon]} {
03142 catch { $mb entryconfigure [msgcat::mc "Show Tcl Console"] -label [msgcat::mc "Hide Tcl Console"] -command [list menus::main_only menus::hide_console_view $mb] }
03143 } else {
03144 catch { $mb entryconfigure [msgcat::mc "Hide Tcl Console"] -label [msgcat::mc "Show Tcl Console"] -command [list menus::main_only menus::show_console_view $mb]}
03145 }
03146 }
03147
03148 }
03149
03150 }
03151
03152 ######################################################################
03153 # Creates a new theme and reloads the themes.
03154 proc theme_edit_command {} {
03155
03156 # Edit the current theme
03157 themer::edit_current_theme
03158
03159 }
03160
03161 ######################################################################
03162 # Starts the procedure profiling.
03163 proc start_profiling_command {mb} {
03164
03165 if {[$mb entrycget [msgcat::mc "Start Profiling"] -state] eq "normal"} {
03166
03167 # Turn on procedure profiling
03168 profile {*}[preferences::get Tools/ProfileReportOptions] on
03169
03170 # Indicate that profiling mode is on
03171 $mb entryconfigure [msgcat::mc "Start Profiling"] -state disabled
03172 $mb entryconfigure [msgcat::mc "Stop Profiling"] -state normal
03173
03174 # Indicate that profiling has started in the information bar
03175 gui::set_info_message [msgcat::mc "Profiling started"]
03176
03177 }
03178
03179 }
03180
03181 ######################################################################
03182 # Stops the profiling process, generates a report and displays the
03183 # report file to a new editor tab.
03184 proc stop_profiling_command {mb show_report} {
03185
03186 variable profile_report
03187 variable profiling_info
03188
03189 if {[$mb entrycget [msgcat::mc "Stop Profiling"] -state] eq "normal"} {
03190
03191 puts "Turning profiling off!"
03192 puts [utils::stacktrace]
03193
03194 # Turn off procedure profiling
03195 profile off profiling_info
03196
03197 # Generate a report file
03198 generate_profile_report
03199 # set sortby [preferences::get Tools/ProfileReportSortby]
03200 # profrep profiling_info $sortby $profile_report "Profiling Information Sorted by $sortby"
03201
03202 # Indicate that profiling has completed
03203 gui::set_info_message [msgcat::mc "Profiling stopped"]
03204
03205 # Add the report to the tab list
03206 if {$show_report} {
03207 show_last_profiling_report
03208 }
03209
03210 # Indicate that profiling mode is off
03211 $mb entryconfigure [msgcat::mc "Stop Profiling"] -state disabled
03212 $mb entryconfigure [msgcat::mc "Start Profiling"] -state normal
03213
03214 }
03215
03216 }
03217
03218 ######################################################################
03219 # Displays the last profiling report.
03220 proc show_last_profiling_report {} {
03221
03222 variable profile_report
03223
03224 # If the profiling report exists, display it
03225 if {[file exists $profile_report]} {
03226 gui::add_file end $profile_report -lock 1 -sidebar 0
03227 }
03228
03229 }
03230
03231 ######################################################################
03232 # Generates a profiling report.
03233 proc generate_profile_report {} {
03234
03235 variable profile_report
03236 variable profiling_info
03237
03238 # Recollect the data
03239 set info_list [list]
03240 foreach info [array names profiling_info] {
03241
03242 set name [lindex $info 0]
03243
03244 # If the name matches anything that we don't want to profile,
03245 # skip to the next iteration now
03246 if {[regexp {^(((::)?(tk::|tcl::|ttk::|tablelist::|mwutil::))|<global>|::\w+$)} $name]} {
03247 continue
03248 }
03249
03250 set calls [lindex $profiling_info($info) 0]
03251 set real [lindex $profiling_info($info) 1]
03252 set cpu [lindex $profiling_info($info) 2]
03253
03254 if {[set index [lsearch -index 0 $info_list [lindex $info 0]]] == -1} {
03255 lappend info_list [list [lindex $info 0] $calls $real $cpu 0.0 0.0]
03256 } else {
03257 set info_entry [lindex $info_list $index]
03258 lset info_list $index 1 [expr [lindex $info_entry 1] + $calls]
03259 lset info_list $index 2 [expr [lindex $info_entry 2] + $real]
03260 lset info_list $index 3 [expr [lindex $info_entry 3] + $cpu]
03261 }
03262
03263 }
03264
03265 # Calculate the real/call and cpu/call values
03266 for {set i 0} {$i < [llength $info_list]} {incr i} {
03267 set info_entry [lindex $info_list $i]
03268 if {[lindex $info_entry 1] > 0} {
03269 lset info_list $i 4 [expr [lindex $info_entry 2].0 / [lindex $info_entry 1]]
03270 lset info_list $i 5 [expr [lindex $info_entry 3].0 / [lindex $info_entry 1]]
03271 }
03272 }
03273
03274 # Sort the information
03275 switch [preferences::get Tools/ProfileReportSortby] {
03276 "calls" { set info_list [lsort -decreasing -integer -index 1 $info_list] }
03277 "real" { set info_list [lsort -decreasing -integer -index 2 $info_list] }
03278 "cpu" { set info_list [lsort -decreasing -integer -index 3 $info_list] }
03279 "real_per_call" { set info_list [lsort -decreasing -real -index 4 $info_list] }
03280 "cpu_per_call" { set info_list [lsort -decreasing -real -index 5 $info_list] }
03281 default { set info_list [lsort -index 0 $info_list] }
03282 }
03283
03284 # Create the report file
03285 if {![catch "open $profile_report w" rc]} {
03286
03287 puts $rc "=============================================================================================================="
03288 puts $rc [format " %s (%s)" [msgcat::mc "Profiling Report Sorted By"] [preferences::get Tools/ProfileReportSortby]]
03289 puts $rc "=============================================================================================================="
03290 puts $rc [format "%-50s %10s %10s %10s %10s %10s" "Procedure" "Calls" "Real" "CPU" "Real/Calls" "CPU/Calls"]
03291 puts $rc "=============================================================================================================="
03292
03293 foreach info $info_list {
03294 puts $rc [format "%-50s %10d %10d %10d %10.3f %10.3f" {*}$info]
03295 }
03296
03297 close $rc
03298
03299 }
03300
03301 }
03302
03303 ######################################################################
03304 # Runs bist.
03305 proc run_bist {} {
03306
03307 # Source the bist.tcl file
03308 uplevel #0 [list source [file join $::tke_dir lib bist.tcl]]
03309
03310 # Run bist
03311 bist::create
03312
03313 }
03314
03315 ######################################################################
03316 # Restart the GUI.
03317 proc restart_command {} {
03318
03319 # Perform exit cleanup
03320 exit_cleanup
03321
03322 # Execute the restart command
03323 if {[file tail [info nameofexecutable]] eq "tke.exe"} {
03324 exec [info nameofexecutable] &
03325 } else {
03326 exec [info nameofexecutable] [file normalize $::argv0] &
03327 }
03328
03329 exit
03330
03331 }
03332
03333 ######################################################################
03334 # Adds the sessions menu options to the sessions menu.
03335 proc add_sessions {mb} {
03336
03337 # Add sessions menu commands
03338 $mb add cascade -label [msgcat::mc "Switch To"] -menu [make_menu $mb.switch -tearoff false]
03339 launcher::register [make_menu_cmd "Sessions" [msgcat::mc "Switch to session"]] [list menus::sessions_switch_launcher]
03340
03341 $mb add separator
03342
03343 $mb add command -label [msgcat::mc "Close Current"] -underline 0 -command [list menus::main_only menus::sessions_close_current]
03344 launcher::register [make_menu_cmd "Sessions" [msgcat::mc "Close current session"]] [list menus::main_only menus::sessions_close_current]
03345
03346 $mb add separator
03347
03348 $mb add command -label [msgcat::mc "Save Current"] -underline 0 -command [list menus::main_only menus::sessions_save_current]
03349 launcher::register [make_menu_cmd "Sessions" [msgcat::mc "Save current session"]] [list menus::main_only menus::sessions_save_current]
03350
03351 $mb add command -label [msgcat::mc "Save As"] -underline 5 -command [list menus::main_only menus::sessions_save_as]
03352 launcher::register [make_menu_cmd "Sessions" [msgcat::mc "Save sessions as"]] [list menus::main_only menus::sessions_save_as]
03353
03354 $mb add separator
03355
03356 $mb add cascade -label [msgcat::mc "Delete"] -menu [make_menu $mb.delete -tearoff false]
03357 launcher::register [make_menu_cmd "Sessions" [msgcat::mc "Delete session"]] [list menus::main_only menus::sessions_delete_launcher]
03358
03359 }
03360
03361 ######################################################################
03362 # Called when the sessions menu is posted.
03363 proc sessions_posting {mb} {
03364
03365 variable current_session
03366
03367 # Get the list of sessions names
03368 set names [sessions::get_names]
03369
03370 # Update the open, switch to, and delete menus
03371 $mb.switch delete 0 end
03372 $mb.delete delete 0 end
03373
03374 set current_session $sessions::current_name
03375
03376 foreach name $names {
03377 $mb.switch add radiobutton -label $name -variable sessions::current_name -value $name -command [list menus::main_only sessions::load "full" $name 0]
03378 $mb.delete add radiobutton -label $name -variable menus::current_session -value $name -command [list menus::main_only sessions::delete $name]
03379 }
03380
03381 # If the current session is not set, disable the menu item
03382 if {[sessions::current] eq ""} {
03383 $mb entryconfigure [msgcat::mc "Close Current"] -state disabled
03384 $mb entryconfigure [msgcat::mc "Save Current"] -state disabled
03385 } else {
03386 $mb entryconfigure [msgcat::mc "Close Current"] -state normal
03387 $mb entryconfigure [msgcat::mc "Save Current"] -state normal
03388 }
03389
03390 # If there are no names, disable the Open, Switch to and Delete menu commands
03391 if {[llength $names] == 0} {
03392 $mb entryconfigure [msgcat::mc "Switch To"] -state disabled
03393 $mb entryconfigure [msgcat::mc "Delete"] -state disabled
03394 } else {
03395 $mb entryconfigure [msgcat::mc "Switch To"] -state normal
03396 $mb entryconfigure [msgcat::mc "Delete"] -state normal
03397 }
03398
03399 }
03400
03401 ######################################################################
03402 # Displays the available sessions that can be switched to in the launcher.
03403 proc sessions_switch_launcher {} {
03404
03405 set i 0
03406 foreach name [sessions::get_names] {
03407 launcher::register_temp "`SESSION:$name" [list sessions::load "full" $name 0] $name $i
03408 incr i
03409 }
03410
03411 # Display the launcher in SESSION: mode
03412 launcher::launch "`SESSION:"
03413
03414 }
03415
03416 ######################################################################
03417 # Closes the current session by switching to the last session.
03418 proc sessions_close_current {} {
03419
03420 sessions::close_current
03421
03422 }
03423
03424 ######################################################################
03425 # Saves the current session as the same name.
03426 proc sessions_save_current {} {
03427
03428 sessions::save "full" [sessions::current]
03429
03430 }
03431
03432 ######################################################################
03433 # Saves the current session as.
03434 proc sessions_save_as {} {
03435
03436 sessions::save "full"
03437
03438 }
03439
03440 ######################################################################
03441 # Shows launcher with a list of available sessions to delete.
03442 proc sessions_delete_launcher {} {
03443
03444 set i 0
03445 foreach name [sessions::get_names] {
03446 launcher::register_temp "`SESSION:$name" [list sessions::delete $name] $name $i
03447 incr i
03448 }
03449
03450 # Display the launcher in SESSION: mode
03451 launcher::launch "`SESSION:"
03452
03453 }
03454
03455 ######################################################################
03456 # Add the plugins menu commands.
03457 proc add_plugins {mb} {
03458
03459 # Add plugins menu commands
03460 $mb add command -label [format "%s..." [msgcat::mc "Install"]] -underline 0 -command [list plugins::install]
03461 launcher::register [make_menu_cmd "Plugins" [msgcat::mc "Install plugin"]] [list plugins::install]
03462
03463 $mb add command -label [format "%s..." [msgcat::mc "Uninstall"]] -underline 0 -command [list plugins::uninstall]
03464 launcher::register [make_menu_cmd "Plugins" [msgcat::mc "Uninstall plugin"]] [list plugins::uninstall]
03465
03466 $mb add command -label [format "%s..." [msgcat::mc "Show Installed"]] -underline 0 -command [list plugins::show_installed]
03467 launcher::register [make_menu_cmd "Plugins" [msgcat::mc "Show installed plugins"]] [list plugins::show_installed]
03468
03469 $mb add command -label [format "%s..." [msgcat::mc "Import"]] -underline 0 -command [list plugins::import]
03470 launcher::register [make_menu_cmd "Plugins" [msgcat::mc "Import plugin bundle"]] [list plugins::import]
03471
03472 $mb add command -label [msgcat::mc "Reload"] -underline 0 -command [list plugins::reload]
03473 launcher::register [make_menu_cmd "Plugins" [msgcat::mc "Reload all plugins"]] [list plugins::reload]
03474
03475 # Allow the plugin architecture to add menu items
03476 plugins::handle_plugin_menu $mb
03477
03478 }
03479
03480 ######################################################################
03481 # Called when the plugins menu needs to be posted.
03482 proc plugins_posting {mb} {
03483
03484 if {[::tke_development]} {
03485 $mb entryconfigure [format "%s..." [msgcat::mc "Export"]] -state [expr {[plugins::export_available] ? "normal" : "disabled"}]
03486 }
03487
03488 }
03489
03490 ######################################################################
03491 # Adds the help menu commands.
03492 proc add_help {mb} {
03493
03494 $mb add command -label [msgcat::mc "User Guide"] -underline 0 -command [list menus::help_user_guide]
03495 launcher::register [make_menu_cmd "Help" [msgcat::mc "View user guide"]] [list menus::help_user_guide]
03496
03497 $mb add command -label [msgcat::mc "Tips & Tricks"] -underline 0 -command [list menus::help_tips_tricks]
03498 launcher::register [make_menu_cmd "Help" [msgcat::mc "View tips & tricks articles"]] [list menus::help_tips_tricks]
03499
03500 $mb add separator
03501
03502 $mb add cascade -label [msgcat::mc "Language Documentation"] -menu [make_menu $mb.refPopup -tearoff 0 -postcommand [list menus::help_lang_ref_posting $mb.refPopup]]
03503 $mb add command -label [msgcat::mc "Search References"] -underline 0 -command [list menus::main_only search::search_documentation]
03504 launcher::register [make_menu_cmd "Help" [msgcat::mc "Search reference documentation"]] [list menus::main_only search::search_documentation]
03505
03506 if {![string match *Win* $::tcl_platform(os)]} {
03507 $mb add separator
03508 $mb add command -label [msgcat::mc "Check for Update"] -underline 0 -command [list menus::check_for_update]
03509 launcher::register [make_menu_cmd "Help" [msgcat::mc "Check for update"]] [list menus::check_for_update]
03510 }
03511
03512 $mb add separator
03513
03514 $mb add command -label [msgcat::mc "Send Feedback"] -underline 5 -command [list menus::help_feedback_command]
03515 launcher::register [make_menu_cmd "Help" [msgcat::mc "Send feedback"]] [list menus::help_feedback_command]
03516
03517 $mb add command -label [msgcat::mc "Send Bug Report"] -underline 5 -command [list menus::help_submit_report]
03518 launcher::register [make_menu_cmd "Help" [msgcat::mc "Send bug report"]] [list menus::help_submit_report]
03519
03520 if {[tk windowingsystem] ne "aqua"} {
03521 $mb add separator
03522 $mb add command -label [format "%s %s" [msgcat::mc "About"] "TKE"] -underline 0 -command [list gui::show_about]
03523 launcher::register [make_menu_cmd "Help" [format "%s %s" [msgcat::mc "About"] "TKE"]] [list gui::show_about]
03524 }
03525
03526 # Create search popup menu
03527 menu $mb.refPopup.searchPopup -tearoff 0
03528
03529 launcher::register [make_menu_cmd "Help" [msgcat::mc "Search language reference documentation"]] [list gui::search_documentation]
03530
03531 }
03532
03533 ######################################################################
03534 # Called when the help menu is posted. Controls the state of the help
03535 # menu items.
03536 proc help_posting {mb} {
03537
03538 set docs [list {*}[syntax::get_references [gui::get_info {} current lang]] {*}[preferences::get Documentation/References]]
03539
03540 if {[lsearch -index 1 -not $docs "*{query}*"] == -1} {
03541 $mb entryconfigure [msgcat::mc "Language Documentation"] -state disabled
03542 } else {
03543 $mb entryconfigure [msgcat::mc "Language Documentation"] -state normal
03544 }
03545
03546 if {[lsearch -index 1 $docs "*{query}*"] == -1} {
03547 $mb entryconfigure [msgcat::mc "Search References"] -state disabled
03548 } else {
03549 $mb entryconfigure [msgcat::mc "Search References"] -state normal
03550 }
03551
03552 }
03553
03554 ######################################################################
03555 # Called when the language reference submenu is posted.
03556 proc help_lang_ref_posting {mb} {
03557
03558 gui::get_info {} current lang
03559
03560 # Get the documentation elements to add
03561 set syntax [lsearch -index 1 -inline -all -not [syntax::get_references $lang] "*{query}*"]
03562 set user [lsearch -index 1 -inline -all -not [preferences::get Documentation/References] "*{query}*"]
03563
03564 # Clean the menu
03565 $mb delete 0 end
03566
03567 # Add the syntax items
03568 foreach item $syntax {
03569 lassign $item name url
03570 $mb add command -label " $name" -command [list utils::open_file_externally $url 1]
03571 }
03572
03573 if {([llength $syntax] > 0) && ([llength $user] > 0)} {
03574 $mb add separator
03575 }
03576
03577 # Add the user documentation
03578 foreach item $user {
03579 lassign $item name url
03580 $mb add command -label " $name" -command [list utils::open_file_externally $url 1]
03581 }
03582
03583 }
03584
03585 ######################################################################
03586 # Displays the User Guide.
03587 proc help_user_guide {} {
03588
03589 utils::open_file_externally [file join $::tke_dir doc UserGuide.html] 1
03590
03591 }
03592
03593 ######################################################################
03594 # Displays the Developer Guide.
03595 proc help_devel_guide {} {
03596
03597 utils::open_file_externally [file join $::tke_dir doc DeveloperGuide.html] 1
03598
03599 }
03600
03601 ######################################################################
03602 # Launches the web browser, displaying the Tips & Tricks blog articles.
03603 proc help_tips_tricks {} {
03604
03605 utils::open_file_externally "http://tkeeditor.wordpress.com"
03606
03607 }
03608
03609 ######################################################################
03610 # Checks for an application update.
03611 proc check_for_update {} {
03612
03613 if {[preferences::get General/UpdateReleaseType] eq "devel"} {
03614 specl::check_for_update 0 [expr $specl::RTYPE_STABLE | $specl::RTYPE_DEVEL] -title [msgcat::mc "TKE Updater"] -cleanup_script menus::exit_cleanup
03615 } else {
03616 specl::check_for_update 0 $specl::RTYPE_STABLE -title [msgcat::mc "TKE Updater"] -cleanup_script menus::exit_cleanup
03617 }
03618
03619 }
03620
03621 ######################################################################
03622 # Generates an e-mail compose window to provide feedback.
03623 proc help_feedback_command {} {
03624
03625 utils::open_file_externally "mailto:phase1geo@gmail.com?subject=Feedback for TKE" 1
03626
03627 }
03628
03629 ######################################################################
03630 # Generates an e-mail compose window to provide a bug report. Appends
03631 # the diagnostic logfile information to the bug report.
03632 proc help_submit_report {} {
03633
03634 # Retrieve the contents of the diagnostic logfile
03635 set log_content [logger::get_log]
03636
03637 # Create the message body
03638 set body "Add bug description:\n\n\n\n\n$log_content"
03639
03640 # Send an e-mail with the logfile contents
03641 utils::open_file_externally "mailto:phase1geo@gmail.com?subject=Bug Report for TKE&body=$body" 1
03642
03643 }
03644
03645 ######################################################################
03646 # Displays the launcher with recently opened files.
03647 proc launcher {} {
03648
03649 # Add recent directories to launcher
03650 foreach sdir [lrange [sidebar::get_last_opened] 0 [expr [preferences::get View/ShowRecentlyOpened] - 1]] {
03651 launcher::register_temp "`RECENT:$sdir" [list sidebar::add_directory $sdir] $sdir
03652 }
03653
03654 # Add recent files to launcher
03655 foreach fname [lrange [gui::get_last_opened] 0 [expr [preferences::get View/ShowRecentlyOpened] - 1]] {
03656 launcher::register_temp "`RECENT:$fname" [list gui::add_file end $fname] $fname
03657 }
03658
03659 # Display the launcher in RECENT: mode
03660 launcher::launch "`RECENT:"
03661
03662 # Unregister the recents
03663 foreach sdir [lrange [sidebar::get_last_opened] 0 [expr [preferences::get View/ShowRecentlyOpened] - 1]] {
03664 launcher::unregister "`RECENT:$sdir"
03665 }
03666 foreach fname [lrange [gui::get_last_opened] 0 [expr [preferences::get View/ShowRecentlyOpened] - 1]] {
03667 launcher::unregister "`RECENT:$fname"
03668 }
03669
03670 }
03671
03672 }
03673