VirtualBox

Changeset 29801 in vbox for trunk/src


Ignore:
Timestamp:
May 26, 2010 8:24:47 AM (15 years ago)
Author:
vboxsync
Message:

vboxshell: path completer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxShell/vboxshell.py

    r29800 r29801  
    188188        return False
    189189
     190    def canBePath(self,phrase,word):
     191        return word.startswith('/')
     192
    190193    def canBeMachine(self,phrase,word):
    191         return not self.canBeCommand(phrase, word)
     194        return not self.canBePath(phrase,word) and not self.canBeCommand(phrase, word)
     195
     196    def canBePath(self,phrase,word):
     197        return word.startswith('/')
    192198
    193199    def global_matches(self, text):
     
    199205
    200206        matches = []
    201         n = len(text)
    202207        phrase = readline.get_line_buffer()
    203208
    204         if self.canBeCommand(phrase,text):
    205             for list in [ self.namespace ]:
    206                 for word in list:
    207                     if word[:n] == text:
    208                         matches.append(word)
    209209        try:
     210            if self.canBeCommand(phrase,text):
     211                n = len(text)
     212                for list in [ self.namespace ]:
     213                    for word in list:
     214                        if word[:n] == text:
     215                            matches.append(word)
     216
    210217            if self.canBeMachine(phrase,text):
     218                n = len(text)
    211219                for m in getMachines(self.ctx, False, True):
    212220                    # although it has autoconversion, we need to cast
     
    216224                        matches.append(word)
    217225                    word = str(m.id)
    218                     if word[0] == '{':
    219                         word = word[1:-1]
    220226                    if word[:n] == text:
    221227                        matches.append(word)
     228
     229            if self.canBePath(phrase,text):
     230                (dir,rest) = os.path.split(text)
     231                n = len(rest)
     232                for word in os.listdir(dir):
     233                    if n == 0 or word[:n] == rest:
     234                        matches.append(os.path.join(dir,word))
     235
    222236        except Exception,e:
    223237            printErr(e)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette