Exemplo n.º 1
0
 def _onDown(self):
     history = self._getHistory()
     newLine = history.forward()
     if newLine is not None:
         self._setLine(newLine)
     else:
         term.bell()
Exemplo n.º 2
0
    def _onTab(self):
        '''
            Autocompletion logic is called here
        '''

        # TODO: autocomplete for raw menu
        if self.inRawLineMode():
            return

        line = self._getLineStr()[:self._position] # take the line before the cursor
        tokens = self._parseLine(line)
        if not line.endswith(' ') and len(tokens)>0:
            # if the cursor is after non-space, the last word is used 
            # as a hint for autocompletion
            incomplete = tokens.pop()
        else:
            incomplete = ''

        completions = self._context.suggest(tokens, incomplete)
        if completions is None:
            return
        prefix = commonPrefix(completions)
        if prefix != '':
            self._paste(prefix)
        elif len(completions) > 0:
            term.writeln()
            for variant in map(lambda c: c[1], completions):
                term.write(variant + ' ')
            term.writeln()
            
            self._showPrompt()

            self._showLine()
        else:
            term.bell()
Exemplo n.º 3
0
    def _onUp(self):
        history = self._getHistory()
        newLine = history.back(self._line)

        if newLine is not None:
            self._setLine(newLine)
        else:
            term.bell()
Exemplo n.º 4
0
 def _moveForward(self, steps=1):
     for i in range(steps):
         if self._position == len(self._line): term.bell()
     term.write(self._line[self._position])
     self._position += 1
Exemplo n.º 5
0
    def _onRight(self):
        if self._position < len(self._line):
#            self._position += 1
            self._moveForward()
        else:
            term.bell()
Exemplo n.º 6
0
 def _onLeft(self):
     if self._position > 0:
         self._position -= 1
         term.moveBack()
     else:
         term.bell()