TKE  3.6
Advanced code editor for programmers
launcher Namespace Reference

Functions

 save_session
 
 load_session data
 
 load
 
 write
 
 launch ?mode? ?show_detail?
 
 configure w args
 
 handle_win_destroy
 
 handle_win_press x y
 
 handle_win_motion x y
 
 handle_win_release x y
 
 handle_entry_font name1 name2 op
 
 handle_preview_font name1 name2 op
 
 handle_last_position name1 name2 op
 
 move_up
 
 move_down
 
 select_motion w x y
 
 select row
 
 register name command ?detail_command? ?validate_cmd? ?auto_register?
 
 register_temp name command description ?order? ?detail_command? ?validate_cmd?
 
 unregister name_pattern ?command_pattern? ?temp_pattern?
 
 remove_temporary
 
 get_command_name name validate_cmd temporary
 
 okay
 
 calc_okay
 
 symbol_okay
 
 marker_okay
 
 clip_okay
 
 url_okay
 
 snip_okay
 
 file_okay
 
 lookup value mode show_detail
 
 find_matches str mode pshow_detail
 
 get_match_results regex_pattern
 
 sort_match_results results type
 
 execute
 
 execute_helper command
 
 handle_calculation str
 
 copy_calculation value
 
 open_url_and_bookmark url
 
 open_url url
 
 open_uri_and_bookmark uri
 
 open_uri uri
 
 get_share_items dir
 
 share_changed dir
 

Function Documentation

§ calc_okay()

launcher::calc_okay

Definition at line 511 of file launcher.tcl.

511  proc calc_okay {} {
512 
513  return 1
514 
515  }

§ clip_okay()

launcher::clip_okay

Definition at line 535 of file launcher.tcl.

535  proc clip_okay {} {
536 
537  return 1
538 
539  }

§ configure()

launcher::configure   w args  

Definition at line 214 of file launcher.tcl.

214  proc configure {w args} {
215 
216  array set opts {
217  -background "white"
218  -foreground "black"
219  -bordercolor "grey90"
220  -borderwidth 10
221  -textbackground "black"
222  -textforeground "white"
223  }
224  array set opts $args
225 
226  }

§ copy_calculation()

launcher::copy_calculation   value  

Definition at line 890 of file launcher.tcl.

890  proc copy_calculation {value} {
891 
892  variable last_command
893 
894  # Clear the clipboard and add the calculation
895  clipboard clear
896  clipboard append $value
897 
898  # Add the clipboard content to the clipboard history manager
900 
901  # Clear the last command so that we don't have the calculated value stuck in memory
902  set last_command ""
903 
904  }

§ execute()

launcher::execute

Definition at line 820 of file launcher.tcl.

820  proc execute {} {
821 
822  variable widgets
823  variable matches
824  variable commands
825  variable command_values
826  variable widgets
827  variable last_command
828 
829  # Get the current selection
830  set row [$widgets(lb) curselection]
831 
832  # Retrieve the command name
833  set command_name [lindex $matches $row]
834 
835  # Create the command value
836  set command_value $commands($command_name)
837  lset command_value $command_values(count) \
838  [expr [lindex $command_value $command_values(count)] + 1]
839  lset command_value $command_values(search_str) [$widgets(entry) get]
840 
841  # Store the relevance by using the new execution count and the entered search string
842  set commands($command_name) $command_value
843  set command [lindex $commands($command_name) $command_values(command)]
844 
845  # Store the last command and type
846  set last_command $command_name
847 
848  # Destroy the widget
849  destroy $widgets(win)
850 
851  # Execute the associated command
852  after 1 [list launcher::execute_helper $command]
853 
854  }

§ execute_helper()

launcher::execute_helper   command  

Definition at line 858 of file launcher.tcl.

858  proc execute_helper {command} {
859 
860  # Execute the command
861  eval "$command"
862 
863  # Write the launcher information
864  bgproc::command launcher_write launcher::write -cancelable 1
865 
866  }

§ file_okay()

launcher::file_okay

Definition at line 559 of file launcher.tcl.

559  proc file_okay {} {
560 
561  return 1
562 
563  }

§ find_matches()

launcher::find_matches   str mode pshow_detail  

Definition at line 657 of file launcher.tcl.

657  proc find_matches {str mode pshow_detail} {
658 
659  upvar $pshow_detail show_detail
660 
661  variable commands
662  variable command_names
663  variable command_values
664  variable matches
665  variable curr_states
666  variable last_url
667 
668  set matches [list]
669 
670  if {$mode eq ""} {
671 
672  switch [string index $str 0] {
673  "@" {
674  if {[llength [array names commands [get_command_name * launcher::symbol_okay 1]]] == 0} {
675  unregister * * 1
676  set i 0
677  foreach {procedure pos} [gui::get_symbol_list] {
678  lappend matches [register_temp "@$procedure" [list gui::jump_to $pos] $procedure $i "" launcher::symbol_okay]
679  incr i
680  }
681  }
682  }
683  "," {
684  if {[llength [array names commands [get_command_name * launcher::marker_okay 1]]] == 0} {
685  unregister * * 1
686  set i 0
687  foreach marker [gui::get_marker_list] {
688  lassign $marker name txt mname
689  lappend matches [register_temp ",$marker" [list gui::jump_to_marker $txt $mname] $name $i "" launcher::marker_okay]
690  incr i
691  }
692  }
693  }
694  "#" {
695  if {[llength [array names commands [get_command_name * launcher::clip_okay 1]]] == 0} {
696  unregister * * 1
697  set i 0
698  foreach strs [cliphist::get_history] {
699  lassign $strs name str
700  lappend matches [register_temp "#$name" [list cliphist::add_to_clipboard $str] $name $i [list cliphist::add_detail $str] launcher::clip_okay]
701  incr i
702  }
703  set show_detail 1
704  }
705  }
706  ";" {
707  if {[llength [array names commands [get_command_name * launcher::snip_okay 1]]] == 0} {
708  unregister * * 1
709  set i 0
710  foreach snippet [snippets::get_current_snippets] {
711  lassign $snippet name value
712  lappend matches [register_temp ";$name" [list snippets::insert_snippet_into_current $value] $name $i [list snippets::add_detail $value] launcher::snip_okay]
713  incr i
714  }
715  set show_detail 1
716  }
717  }
718  ">" {
719  if {[llength [array names commands [get_command_name * launcher::file_okay 1]]] == 0} {
720  unregister * * 1
721  set i 0
722  foreach finfo [sidebar::get_shown_files] {
723  lassign $finfo name row
724  lappend matches [register_temp ">$name" [list sidebar::open_file $row] $name $i "" launcher::file_okay]
725  }
726  }
727  }
728  default {
729  unregister * * 1
730  if {([string first {\[} $str] == -1) && [handle_calculation $str]} {
731  # Nothing more to do
732  } elseif {[regexp {^((https?://)?[a-z0-9\-]+\.[a-z0-9\-\.]+(?:/|(?:/[a-zA-Z0-9!#\$%&'\*\+,\-\.:;=\?@\[\]_~]+)*))$} $str -> url]} {
733  lappend matches [register_temp "" [list launcher::open_url_and_bookmark $url] "Open URL $url" 0 "" launcher::url_okay]
734  } elseif {[regexp {^[a-zA-Z][a-zA-Z0-9+.-]*:} $str]} {
735  lappend matches [register_temp "" [list launcher::open_uri_and_bookmark $str] "Open URI $str" 0 "" launcher::url_okay]
736  }
737  }
738  }
739 
740  }
741 
742  # Get the precise match (if one exists)
743  set results [list]
744  foreach {name value} [array get commands [get_command_name * * *]] {
745  if {[lindex $value $command_values(search_str)] eq "$mode$str"} {
746  if {[eval [lindex $name $command_names(validate_cmd)]]} {
747  lappend results [list $name $value]
748  }
749  }
750  }
751 
752  # Sort the results by relevance
753  sort_match_results $results 1
754 
755  # Make the string regular expression friendly
756  set tmpstr [string map {{.} {\.} {*} {\*} {+} {\+} {?} {\?} {\[} {\[}} $str]
757 
758  if {[string index $tmpstr 0] eq ">"} {
759  set tmpstr ">.*[string range $tmpstr 1 end]"
760  }
761 
762  # Get exact matches that match the beginning of the statement
763  sort_match_results [get_match_results \{?$mode$tmpstr.*] 0
764 
765  # Get all of the exact matches within the string
766  sort_match_results [get_match_results \{?$mode.*$tmpstr.*] 0
767 
768  # Get all of the fuzzy matches
769  sort_match_results [get_match_results \{?$mode.*[join [string map {{.} {\\\.} {*} {\\\*} {+} {\\\+} {?} {\\\?} {\[} {\\\[}} [split $str {}]] .*].*] 1
770 
771  }

§ get_command_name()

launcher::get_command_name   name validate_cmd temporary  

Definition at line 487 of file launcher.tcl.

487  proc get_command_name {name validate_cmd temporary} {
488 
489  variable command_names
490 
491  # Create the command name list
492  set command_name [lrepeat [array size command_names] ""]
493  lset command_name $command_names(name) [string tolower $name]
494  lset command_name $command_names(validate_cmd) $validate_cmd
495  lset command_name $command_names(temporary) $temporary
496 
497  return $command_name
498 
499  }

§ get_match_results()

launcher::get_match_results   regex_pattern  

Definition at line 776 of file launcher.tcl.

776  proc get_match_results {regex_pattern} {
777 
778  variable commands
779  variable command_names
780  variable command_values
781  variable matches
782 
783  set results [list]
784  set pattern [subst [string map {{(} {\(} {)} {\)}} [get_command_name $regex_pattern .* .*]]]
785 
786  foreach name [array name commands -regexp $pattern] {
787  set value $commands($name)
788  if {[lsearch -exact $matches $name] == -1} {
789  set validate_cmd [lindex $name $command_names(validate_cmd)]
790  if {[eval $validate_cmd]} {
791  if {$validate_cmd ne "launcher::okay"} {
792  lset value $command_values(count) [expr [lindex $value $command_values(count)] + 1000000]
793  }
794  lappend results [list $name $value]
795  }
796  }
797  }
798 
799  return $results
800 
801  }

§ get_share_items()

launcher::get_share_items   dir  

Definition at line 960 of file launcher.tcl.

960  proc get_share_items {dir} {
961 
962  return [list launcher.dat]
963 
964  }

§ handle_calculation()

launcher::handle_calculation   str  

Definition at line 871 of file launcher.tcl.

871  proc handle_calculation {str} {
872 
873  variable matches
874 
875  # Check to see if the string is a valid Tcl expression
876  if {![catch "expr $str" rc]} {
877 
878  lappend matches [register_temp "" [list launcher::copy_calculation $rc] "Copy $rc to clipboard" 0 "" launcher::calc_okay]
879 
880  return 1
881 
882  }
883 
884  return 0
885 
886  }

§ handle_entry_font()

launcher::handle_entry_font   name1 name2 op  

Definition at line 304 of file launcher.tcl.

304  proc handle_entry_font {name1 name2 op} {
305 
306  if {[lsearch [font names] launcher_entry] != -1} {
307  font configure launcher_entry {*}[preferences::get Appearance/CommandLauncherEntryFont]
308  }
309 
310  }

§ handle_last_position()

launcher::handle_last_position   name1 name2 op  

Definition at line 324 of file launcher.tcl.

324  proc handle_last_position {name1 name2 op} {
325 
326  variable move_info
327 
328  if {[preferences::get Appearance/CommandLauncherRememberLastPosition] == 0} {
329  catch { unset move_info(save_x)}
330  catch { unset move_info(save_y)}
331  }
332 
333  }

§ handle_preview_font()

launcher::handle_preview_font   name1 name2 op  

Definition at line 314 of file launcher.tcl.

314  proc handle_preview_font {name1 name2 op} {
315 
316  if {[lsearch [font names] launcher_preview] != -1} {
317  font configure launcher_preview {*}[preferences::get Appearance/CommandLauncherPreviewFont]
318  }
319 
320  }

§ handle_win_destroy()

launcher::handle_win_destroy

Definition at line 230 of file launcher.tcl.

230  proc handle_win_destroy {} {
231 
232  variable widgets
233 
234  # Reset the original focus and grab
235  ::tk::RestoreFocusGrab $widgets(win) $widgets(entry)
236 
237  # Destroy temporary registrations
239 
240  }

§ handle_win_motion()

launcher::handle_win_motion   x y  

Definition at line 255 of file launcher.tcl.

255  proc handle_win_motion {x y} {
256 
257  variable widgets
258  variable move_info
259 
260  if {![info exists move_info(last_x)]} {
261  return
262  }
263 
264  set newx [expr [winfo x $widgets(win)] + ($x - $move_info(last_x))]
265  set newy [expr [winfo y $widgets(win)] + ($y - $move_info(last_y))]
266 
267  # If the new coordinates are valid, allow the move
268  if {($newx > 0) && (($newx + [winfo width $widgets(win)]) < [winfo width .]) && \
269  ($newy > 0) && (($newy + [winfo height $widgets(win)]) < [winfo height .])} {
270 
271  place configure $widgets(win) -x $newx -y $newy -relx 0.0 -rely 0.0
272 
273  set move_info(last_x) $x
274  set move_info(last_y) $y
275 
276  } else {
277 
278  array unset move_info
279 
280  }
281 
282  }

§ handle_win_press()

launcher::handle_win_press   x y  

Definition at line 244 of file launcher.tcl.

244  proc handle_win_press {x y} {
245 
246  variable move_info
247 
248  set move_info(last_x) $x
249  set move_info(last_y) $y
250 
251  }

§ handle_win_release()

launcher::handle_win_release   x y  

Definition at line 286 of file launcher.tcl.

286  proc handle_win_release {x y} {
287 
288  variable widgets
289  variable move_info
290 
291  array unset move_info
292 
293  # Save the command launcher position if we are supposed to
294  if {[preferences::get Appearance/CommandLauncherRememberLastPosition]} {
295  array set opts [place info $widgets(win)]
296  set move_info(save_x) $opts(-x)
297  set move_info(save_y) $opts(-y)
298  }
299 
300  }

§ launch()

launcher::launch   ?mode? ?show_detail?  

Definition at line 118 of file launcher.tcl.

118  proc launch {{mode ""} {show_detail 0}} {
119 
120  variable widgets
121  variable move_info
122 
123  if {![winfo exists .lwin]} {
124 
125  set widgets(win) .lwin
126 
127  # Get information from theme
128  array set theme [theme::get_category_options launcher 1]
129 
130  frame $widgets(win) -borderwidth 2 -bg $theme(-bordercolor) \
131  -padx $theme(-borderwidth) -pady $theme(-borderwidth)
132 
133  set widgets(entry) [entry $widgets(win).entry -bg $theme(-background) -fg $theme(-foreground) \
134  -width 50 -highlightthickness 0 -relief flat -insertbackground $theme(-foreground) \
135  -validate key -validatecommand "launcher::lookup %P {$mode} $show_detail" -invalidcommand {bell}]
136 
137  if {[lsearch [font names] launcher_entry] == -1} {
138  font create launcher_entry {*}[preferences::get Appearance/CommandLauncherEntryFont]
139  }
140 
141  $widgets(entry) configure -font launcher_entry
142 
143  set widgets(mf) [ttk::frame $widgets(win).mf]
144  frame $widgets(mf).spcr -height $theme(-spacerheight) -bg $theme(-spacercolor) -borderwidth 0
145  set widgets(lf) [ttk::frame $widgets(win).mf.lf]
146  set widgets(lb) [listbox $widgets(lf).lb -exportselection 0 \
147  -background $theme(-listbackground) -foreground $theme(-listforeground) \
148  -selectbackground $theme(-selectbackground) -selectforeground $theme(-selectforeground) \
149  -height 0 -width 35 -borderwidth 0 -highlightthickness 2 \
150  -highlightcolor $theme(-listbackground) -highlightbackground $theme(-listbackground) \
151  -yscrollcommand "utils::set_yscrollbar $widgets(lf).vb" -listvariable launcher::match_commands]
152  scroller::scroller $widgets(lf).vb -orient vertical \
153  -background $theme(-listbackground) -foreground $theme(-scrollcolor) \
154  -thickness $theme(-scrollwidth) -command [list $widgets(lb) yview]
155 
156  grid rowconfigure $widgets(lf) 0 -weight 1
157  grid columnconfigure $widgets(lf) 0 -weight 1
158  grid $widgets(lf).lb -row 0 -column 0 -sticky news
159  grid $widgets(lf).vb -row 0 -column 1 -sticky ns
160 
161  # Create a special font for the text widget
162  set widgets(txt) [text $widgets(win).mf.txt -bd 0 \
163  -highlightthickness 2 -highlightbackground $theme(-listbackground) \
164  -highlightcolor $theme(-background) \
165  -width 60 -height 15 -relief flat -wrap word -state disabled \
166  -fg $theme(-textforeground) -bg $theme(-textbackground)]
167 
168  if {[lsearch [font names] launcher_preview] == -1} {
169  font create launcher_preview {*}[preferences::get Appearance/CommandLauncherPreviewFont]
170  }
171 
172  $widgets(txt) configure -font launcher_preview
173 
174  grid rowconfigure $widgets(mf) 1 -weight 1
175  grid columnconfigure $widgets(mf) 0 -weight 1
176  grid $widgets(mf).spcr -row 0 -column 0 -sticky ew
177  grid $widgets(lf) -row 1 -column 0 -sticky news
178  grid $widgets(txt) -row 2 -column 0 -sticky news
179 
180  # Hide the text widget
181  grid remove $widgets(txt)
182 
183  pack $widgets(entry) -fill x
184 
185  # Bind the escape key to exit the window
186  bind $widgets(win) <Destroy> "launcher::handle_win_destroy"
187  bind $widgets(win) <ButtonPress-1> "launcher::handle_win_press %X %Y"
188  bind $widgets(win) <B1-Motion> "launcher::handle_win_motion %X %Y"
189  bind $widgets(win) <ButtonRelease-1> "launcher::handle_win_release %X %Y"
190  bind $widgets(entry) <Escape> "destroy $widgets(win)"
191  bind $widgets(entry) <FocusOut> "destroy $widgets(win)"
192 
193  # Position the window in the center of the main window
194  if {[info exists move_info(save_x)]} {
195  place $widgets(win) -x $move_info(save_x) -y $move_info(save_y)
196  } else {
197  place $widgets(win) -relx 0.4 -rely 0.25
198  }
199 
200  # Get current focus and grab
201  ::tk::SetFocusGrab $widgets(win) $widgets(entry)
202 
203  # If we are running in a mode, display the default results
204  if {$mode ne ""} {
205  lookup "" $mode $show_detail
206  }
207 
208  }
209 
210  }

§ load()

launcher::load

Definition at line 83 of file launcher.tcl.

83  proc load {} {
84 
85  variable read_commands
86  variable launcher_file
87 
88  if {![catch { open $launcher_file r} rc]} {
89  array set read_commands [read $rc]
90  close $rc
91  }
92 
93  # Add preferences traces
94  trace variable preferences::prefs(Appearance/CommandLauncherEntryFont) w launcher::handle_entry_font
95  trace variable preferences::prefs(Appearance/CommandLauncherPreviewFont) w launcher::handle_preview_font
96  trace variable preferences::prefs(Appearance/CommandLauncherRememberLastPosition) w launcher::handle_last_position
97 
98  }

§ load_session()

launcher::load_session   data  

Definition at line 68 of file launcher.tcl.

68  proc load_session {data} {
69 
70  variable move_info
71 
72  array set opts $data
73 
74  if {[info exists opts(win_posx)]} {
75  set move_info(save_x) $opts(win_posx)
76  set move_info(save_y) $opts(win_posy)
77  }
78 
79  }

§ lookup()

launcher::lookup   value mode show_detail  

Definition at line 567 of file launcher.tcl.

567  proc lookup {value mode show_detail} {
568 
569  variable widgets
570  variable commands
571  variable matches
572  variable options
573  variable match_commands
574  variable command_names
575  variable command_values
576 
577  if {($value ne "") || ($mode ne "")} {
578 
579  # Find all of the matches
580  find_matches $value $mode show_detail
581 
582  # Get the number of matches
583  set match_num [llength $matches]
584 
585  # Only display results if we have some to display
586  if {$match_num > 0 } {
587 
588  # Limit the match list to the top
589  if {$match_num > $options(-results)} {
590  $widgets(lb) configure -height $options(-results)
591  } else {
592  $widgets(lb) configure -height $match_num
593  }
594 
595  # If we need to show detail, display the text widget
596  if {$show_detail} {
597  grid $widgets(txt)
598  } else {
599  grid remove $widgets(txt)
600  }
601 
602  # Update the table
603  set match_commands [list]
604  for {set i 0} {$i < $match_num} {incr i} {
605  lappend match_commands [lindex $commands([lindex $matches $i]) $command_values(description)]
606  }
607 
608  # Bind up/down and return keys
609  bind $widgets(entry) <Up> "launcher::move_up; break"
610  bind $widgets(entry) <Down> "launcher::move_down; break"
611  bind $widgets(entry) <Return> "launcher::execute"
612  bind $widgets(entry) <Escape> "destroy $widgets(win)"
613  bind $widgets(lb) <Motion> "launcher::select_motion %W %x %y"
614  bind $widgets(lb) <<ListboxSelect>> "launcher::execute"
615 
616  # Set tablelist selection to the first entry
617  select 0
618 
619  # Pack the listbox, if it isn't already
620  if {[catch "pack info $widgets(mf)"]} {
621  pack $widgets(mf) -fill both -expand yes
622  }
623 
624  } else {
625 
626  # Remove the results frame
627  pack forget $widgets(mf)
628 
629  # Unbind up and down arrows
630  bind $widgets(entry) <Up> ""
631  bind $widgets(entry) <Down> ""
632  bind $widgets(entry) <Return> "destroy $widgets(win)"
633  bind $widgets(entry) <Escape> "destroy $widgets(win)"
634 
635  }
636 
637  } else {
638 
639  # Remove the results frame
640  pack forget $widgets(mf)
641 
642  # Unbind up and down arrows
643  bind $widgets(entry) <Up> ""
644  bind $widgets(entry) <Down> ""
645  bind $widgets(entry) <Return> "destroy $widgets(win)"
646  bind $widgets(entry) <Escape> "destroy $widgets(win)"
647 
648  }
649 
650  return 1
651 
652  }

§ marker_okay()

launcher::marker_okay

Definition at line 527 of file launcher.tcl.

527  proc marker_okay {} {
528 
529  return 1
530 
531  }

§ move_down()

launcher::move_down

Definition at line 351 of file launcher.tcl.

351  proc move_down {} {
352 
353  variable widgets
354 
355  set selected [$widgets(lb) curselection]
356 
357  if {$selected < [expr [$widgets(lb) size] - 1]} {
358  select [expr $selected + 1]
359  }
360 
361  }

§ move_up()

launcher::move_up

Definition at line 337 of file launcher.tcl.

337  proc move_up {} {
338 
339  variable widgets
340 
341  set selected [$widgets(lb) curselection]
342 
343  if {$selected > 0} {
344  select [expr $selected - 1]
345  }
346 
347  }

§ okay()

launcher::okay

Definition at line 503 of file launcher.tcl.

503  proc okay {} {
504 
505  return 1
506 
507  }

§ open_uri()

launcher::open_uri   uri  

Definition at line 952 of file launcher.tcl.

952  proc open_uri {uri} {
953 
954  return [utils::open_file_externally $uri]
955 
956  }

§ open_uri_and_bookmark()

launcher::open_uri_and_bookmark   uri  

Definition at line 938 of file launcher.tcl.

938  proc open_uri_and_bookmark {uri} {
939 
940  # Display the URI
941  if {[open_uri $uri] == 0} {
942 
943  # Add the URI to the bookmark list
944  register "Open bookmarked URI $uri" [list launcher::open_uri $uri]
945 
946  }
947 
948  }

§ open_url()

launcher::open_url   url  

Definition at line 923 of file launcher.tcl.

923  proc open_url {url} {
924 
925  # If the URL did not contain the http portion, add it so that the external launcher knows
926  # this is a URL.
927  if {[string range $url 0 3] ne "http"} {
928  set url "http://$url"
929  }
930 
931  # Displays the URL in the local browser
932  return [utils::open_file_externally $url]
933 
934  }

§ open_url_and_bookmark()

launcher::open_url_and_bookmark   url  

Definition at line 908 of file launcher.tcl.

908  proc open_url_and_bookmark {url} {
909 
910  # Open the URL in the local browser
911  if {[open_url $url] == 0} {
912 
913  # Add the URL to the bookmark list
914  register "Open bookmarked URL $url" [list launcher::open_url $url]
915 
916  }
917 
918  }

§ register()

launcher::register   name command ?detail_command? ?validate_cmd? ?auto_register?  

Definition at line 399 of file launcher.tcl.

399  proc register {name command {detail_command ""} {validate_cmd "launcher::okay"} {auto_register 0}} {
400 
401  variable commands
402  variable read_commands
403  variable command_names
404  variable command_values
405 
406  # If the read file has not been read, do it now and bind ourselves
407  if {[array size read_commands] == 0} {
408  load
409  }
410 
411  # Create default values
412  set count 0
413  set search_str ""
414  set command_name [get_command_name $name $validate_cmd 0]
415 
416  # Update the commands array
417  if {[llength [array names commands $command_name]] == 0} {
418  if {[info exists read_commands($command_name)]} {
419  set count [lindex $read_commands($command_name) $command_values(count)]
420  set search_str [lindex $read_commands($command_name) $command_values(search_str)]
421  }
422  }
423 
424  # Create the command list
425  set command_value [lrepeat [array size command_values] ""]
426  lset command_value $command_values(description) [string trim $name]
427  lset command_value $command_values(command) $command
428  lset command_value $command_values(auto_register) $auto_register
429  lset command_value $command_values(count) $count
430  lset command_value $command_values(search_str) $search_str
431  lset command_value $command_values(detail_command) $detail_command
432 
433  # Populate the command in the lookup table
434  set commands($command_name) $command_value
435 
436  }

§ register_temp()

launcher::register_temp   name command description ?order? ?detail_command? ?validate_cmd?  

Definition at line 441 of file launcher.tcl.

441  proc register_temp {name command description {order 0x7fffffff} {detail_command ""} {validate_cmd "launcher::okay"}} {
442 
443  variable commands
444  variable command_names
445  variable command_values
446 
447  # Create the command name list
448  set command_name [get_command_name $name $validate_cmd 1]
449 
450  # Create the command value list
451  set command_value [lrepeat [array size command_values] ""]
452  lset command_value $command_values(description) [string trim $description]
453  lset command_value $command_values(command) $command
454  lset command_value $command_values(auto_register) 0
455  lset command_value $command_values(count) [expr 0x7fffffff - $order]
456  lset command_value $command_values(search_str) $name
457  lset command_value $command_values(detail_command) $detail_command
458 
459  # Populate the command in the lookup table
460  set commands($command_name) $command_value
461 
462  return $command_name
463 
464  }

§ remove_temporary()

launcher::remove_temporary

Definition at line 478 of file launcher.tcl.

478  proc remove_temporary {} {
479 
480  # Unregister all temporary registrations
481  unregister * * 1
482 
483  }

§ save_session()

launcher::save_session

Definition at line 54 of file launcher.tcl.

54  proc save_session {} {
55 
56  variable move_info
57 
58  if {[info exists move_info(save_x)]} {
59  return [list win_posx $move_info(save_x) win_posy $move_info(save_y)]
60  } else {
61  return [list]
62  }
63 
64  }

§ select()

launcher::select   row  

Definition at line 373 of file launcher.tcl.

373  proc select {row} {
374 
375  variable widgets
376  variable commands
377  variable command_values
378  variable matches
379 
380  # Set the selection
381  $widgets(lb) selection clear 0 end
382  $widgets(lb) selection set $row
383  $widgets(lb) see $row
384 
385  # If the text widget is shown, clear it and display the current detail information
386  if {[lsearch [grid slaves $widgets(mf)] $widgets(txt)] != -1} {
387  $widgets(txt) configure -state normal
388  $widgets(txt) delete 1.0 end
389  if {[set detail_command [lindex $commands([lindex $matches $row]) $command_values(detail_command)]] ne ""} {
390  uplevel #0 "$detail_command $widgets(txt)"
391  }
392  $widgets(txt) configure -state disabled
393  }
394 
395  }

§ select_motion()

launcher::select_motion   w x y  

Definition at line 365 of file launcher.tcl.

365  proc select_motion {w x y} {
366 
367  select [$w index @$x,$y]
368 
369  }

§ share_changed()

launcher::share_changed   dir  

Definition at line 968 of file launcher.tcl.

968  proc share_changed {dir} {
969 
970  variable launcher_file
971 
972  set launcher_file [file join $dir launcher.dat]
973 
974  }

§ snip_okay()

launcher::snip_okay

Definition at line 551 of file launcher.tcl.

551  proc snip_okay {} {
552 
553  return 1
554 
555  }

§ sort_match_results()

launcher::sort_match_results   results type  

Definition at line 806 of file launcher.tcl.

806  proc sort_match_results {results type} {
807 
808  variable command_values
809  variable matches
810 
811  # Sort the results by relevance
812  foreach result [lsort -integer -index [list 1 $command_values(count)] -decreasing $results] {
813  lappend matches [lindex $result 0]
814  }
815 
816  }

§ symbol_okay()

launcher::symbol_okay

Definition at line 519 of file launcher.tcl.

519  proc symbol_okay {} {
520 
521  return 1
522 
523  }

§ unregister()

launcher::unregister   name_pattern ?command_pattern? ?temp_pattern?  

Definition at line 468 of file launcher.tcl.

468  proc unregister {name_pattern {command_pattern *} {temp_pattern *}} {
469 
470  variable commands
471 
472  array unset commands [get_command_name $name_pattern $command_pattern $temp_pattern]
473 
474  }

§ url_okay()

launcher::url_okay

Definition at line 543 of file launcher.tcl.

543  proc url_okay {} {
544 
545  return 1
546 
547  }

§ write()

launcher::write

Definition at line 102 of file launcher.tcl.

102  proc write {} {
103 
104  variable commands
105  variable launcher_file
106 
107  if {![catch { open $launcher_file w} rc]} {
108  foreach {name value} [array get commands] {
109  puts $rc "[list $name] [list $value]"
110  }
111  close $rc
112  }
113 
114  }