Changeset 79259
- Timestamp:
- 06/07/11 02:38:40 (4 years ago)
- File:
-
- 1 edited
-
trunk/base/src/port/port.tcl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/base/src/port/port.tcl
r79167 r79259 3834 3834 ] 3835 3835 3836 # Expand "action". 3837 # Returns an action proc, or a list of matching action procs, or the action passed in 3838 proc find_action { action } { 3839 global action_array 3840 3841 if { ! [info exists action_array($action)] } { 3842 set guess [guess_action $action] 3843 if { [info exists action_array($guess)] } { 3844 return $guess 3845 } 3846 return $guess 3847 } 3848 3849 return $action 3850 } 3851 3852 # Expand action 3853 # If there's more than one match, return the next possibility 3836 3854 proc find_action_proc { action } { 3855 global action_array 3856 3857 set action_proc "" 3858 if { [info exists action_array($action)] } { 3859 set action_proc [lindex $action_array($action) 0] 3860 } else { 3861 set action [complete_action $action] 3862 if { [info exists action_array($action)] } { 3863 set action_proc [lindex $action_array($action) 0] 3864 } 3865 } 3866 3867 return $action_proc 3868 } 3869 3870 proc get_action_proc { action } { 3837 3871 global action_array 3838 3872 … … 4121 4155 4122 4156 # Find an action to execute 4123 set action_proc [find_action_proc $action] 4124 if { $action_proc == "" } { 4125 puts "Unrecognized action \"$action\"" 4157 set actions [find_action $action] 4158 if {[llength $actions] == 1} { 4159 set action [lindex $actions 0] 4160 set action_proc [get_action_proc $action] 4161 } else { 4162 if {[llength $actions] > 1} { 4163 puts "Ambiguous action \"$action\": could be any of {$actions}." 4164 } else { 4165 puts "Unrecognized action \"$action\"" 4166 } 4126 4167 set action_status 1 4127 4168 break … … 4213 4254 4214 4255 4256 # return text action beginning with $text 4215 4257 proc complete_action { text state } { 4216 4258 global action_array … … 4228 4270 } 4229 4271 4272 # return all actions beginning with $text 4273 proc guess_action { text } { 4274 global action_array 4275 4276 return [array names action_array "[string tolower $text]*"] 4277 4278 if { [llength $complete_choices ] == 1 } { 4279 return [lindex $complete_choices 0] 4280 } 4281 4282 return {} 4283 } 4230 4284 4231 4285 proc attempt_completion { text word start end } {
Note: See TracChangeset
for help on using the changeset viewer.

