Exemple #1
0
 def _onDown(self):
     history = self._get_history()
     new_line = history.forward()
     if new_line is not None:
         self._setLine(new_line)
     else:
         term.bell()
Exemple #2
0
 def _onDown(self):
     history = self._get_history()
     new_line = history.forward()
     if new_line is not None:
         self._setLine(new_line)
     else:
         term.bell()
Exemple #3
0
    def _onUp(self):
        history = self._get_history()
        new_line = history.back(self._line)

        if new_line is not None:
            self._setLine(new_line)
        else:
            term.bell()
Exemple #4
0
    def _onUp(self):
        history = self._get_history()
        new_line = history.back(self._line)

        if new_line is not None:
            self._setLine(new_line)
        else:
            term.bell()
Exemple #5
0
    def _onTab(self):
        '''
            Autocompletion logic is called here
        '''

        # TODO: autocomplete for raw menu
        if self.in_raw_line_mode():
            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()
Exemple #6
0
    def _onTab(self):
        '''
            Autocompletion logic is called here
        '''

        # TODO: autocomplete for raw menu
        if self.in_raw_line_mode():
            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()
Exemple #7
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
Exemple #8
0
    def _onRight(self):
        if self._position < len(self._line):
#            self._position += 1
            self._moveForward()
        else:
            term.bell()
Exemple #9
0
 def _onLeft(self):
     if self._position > 0:
         self._position -= 1
         term.moveBack()
     else:
         term.bell()
Exemple #10
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
Exemple #11
0
 def _onRight(self):
     if self._position < len(self._line):
         #            self._position += 1
         self._moveForward()
     else:
         term.bell()
Exemple #12
0
 def _onLeft(self):
     if self._position > 0:
         self._position -= 1
         term.moveBack()
     else:
         term.bell()