Example #1
0
    def _addSuggestion(self):
        if self.commandText == '':
            self.suggestText = ''
            return
        start_code = '-'

        command_list = archyState.commandMap.commandList()

        #Force REDO and UNDO to autocomplete before anything else that begins with U or R.
        u_commands = map(lambda c: c[0] == 'U', command_list)
        u_index = u_commands.index(True)
        command_list.insert(u_index, 'UNDO')

        r_commands = map(lambda c: c[0] == 'R', command_list)
        r_index = r_commands.index(True)
        command_list.insert(r_index, 'REDO')
        
        command_list = start_code+start_code.join(command_list)
        found = command_list.find(start_code+self.commandText)
        if found >= 0:
            self.suggestText = command_list[found+1:].split(start_code)[0][len(self.commandText):]
        else:
            self.suggestText = ""

        messages.addToMessage( self.suggestText, 'command' )
        textLength = archyState.quasiModeText.styleArray.getLength()
        archyState.quasiModeText.styleArray.setStyleInRange(self.suggestStyle, textLength-len(self.suggestText), textLength)
Example #2
0
    def keypress(self, keycode, unicode, action):

        if action == DOWN:
            if unicode == u"":
                return
            if self.parent.left_shift == DOWN or self.parent.right_shift == DOWN:
                unicode = archy_globals.apply_shift_key_to_character(unicode)

            messages.addToMessage(unicode, 'leap')
            try:
                self.leapCommand.addChar(unicode)
                if self.leapCommand.status() == 0:
                    # I do not think an addChar can result in a 0 length target but
                    # it will not hurt to check here. -Han
                    self.restoreViewSettings()
            except commands.AbortCommandException, e:
                self.info = e.getExplanation()
                self.restoreViewSettings()
                self.playFailedLeapSound()
Example #3
0
 def keypress(self, keycode, unicode, downOrUp):
     import pygame
     if downOrUp == DOWN:
         if len(self.commandText) < 1:
             if keycode in [ord('\n'), ord('\r')]:
                 self.runLastCommand()
                 return
             else:
                 keystroke = convertToNotation( (keycode,downOrUp) )
                 if keystroke == platform_specific.Start_LEAP_Forward_Keybinding:
                     self.lastLeapForward()
                     return
                 if keystroke == platform_specific.Start_LEAP_Backward_Keybinding:
                     self.lastLeapBackward()
                     return
         upper_char_code = unicode.upper()
         self.commandText += upper_char_code
         
         self._removeSuggestion()
         messages.addToMessage( upper_char_code, 'command' )
         self._addSuggestion()