Changeset 29541 in vbox for trunk/src/VBox/Frontends/VBoxShell
- Timestamp:
- May 17, 2010 12:39:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r29537 r29541 161 161 162 162 if g_hasreadline: 163 import string 163 164 class CompleterNG(rlcompleter.Completer): 164 165 def __init__(self, dic, ctx): … … 171 172 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496812 172 173 """ 173 if text == "":174 if False and text == "": 174 175 return ['\t',None][state] 175 176 else: 176 177 return rlcompleter.Completer.complete(self,text,state) 178 179 def canBeCommand(self, phrase, word): 180 spaceIdx = phrase.find(" ") 181 begIdx = readline.get_begidx() 182 firstWord = (spaceIdx == -1 or begIdx < spaceIdx) 183 if firstWord: 184 return True 185 if phrase.startswith('help'): 186 return True 187 return False 188 189 def canBeMachine(self,phrase,word): 190 return not self.canBeCommand(phrase, word) 177 191 178 192 def global_matches(self, text): … … 185 199 matches = [] 186 200 n = len(text) 187 188 for list in [ self.namespace ]: 189 for word in list: 190 if word[:n] == text: 191 matches.append(word) 192 201 phrase = readline.get_line_buffer() 202 203 if self.canBeCommand(phrase,text): 204 for list in [ self.namespace ]: 205 for word in list: 206 if word[:n] == text: 207 matches.append(word) 193 208 try: 194 for m in getMachines(self.ctx, False, True): 195 # although it has autoconversion, we need to cast 196 # explicitly for subscripts to work 197 word = re.sub("(?<!\\\\) ", "\\ ", str(m.name)) 198 if word[:n] == text: 199 matches.append(word) 200 word = str(m.id) 201 if word[0] == '{': 202 word = word[1:-1] 203 if word[:n] == text: 204 matches.append(word) 209 if self.canBeMachine(phrase,text): 210 for m in getMachines(self.ctx, False, True): 211 # although it has autoconversion, we need to cast 212 # explicitly for subscripts to work 213 word = re.sub("(?<!\\\\) ", "\\ ", str(m.name)) 214 if word[:n] == text: 215 matches.append(word) 216 word = str(m.id) 217 if word[0] == '{': 218 word = word[1:-1] 219 if word[:n] == text: 220 matches.append(word) 205 221 except Exception,e: 206 222 printErr(e)
Note:
See TracChangeset
for help on using the changeset viewer.