예제 #1
0
    def execute(self):
        mT = archyState.mainText
        mT.setSelection('selection', *self.wordRange)

        self.removeSpellcheck = RemoveSpellcheckCommand()
        self.delText = archyState.commandMap.findSystemCommand("DeleteText")
        self.addText = archyState.commandMap.findSystemCommand("AddText")
        self.addText.setinfo(self.suggestion)

        self.removeSpellcheck.execute()
        self.delText.execute()
        self.addText.execute()

        foundNext = 0
        pos = mT.getCursorPos()
        start = pos

        while not foundNext and pos < mT.getLength() and abs(pos -
                                                             start) < 2000:
            if mT.behaviorArray.hasAction("SPELLCHECK", pos):
                foundNext = 1
            else:
                pos += 1

        messages.unqueue('persistant')

        if foundNext <> 0:
            mT.setCursor(pos)
            mT.setSelection('selection', mT.cursorPosInText)
            messages.display()
예제 #2
0
파일: spellcheck.py 프로젝트: MySheep/Archy
    def execute(self):
        mT = archyState.mainText
        mT.setSelection('selection', *self.wordRange)
        
        self.removeSpellcheck = RemoveSpellcheckCommand()
        self.delText = archyState.commandMap.findSystemCommand("DeleteText")
        self.addText = archyState.commandMap.findSystemCommand("AddText")
        self.addText.setinfo(self.suggestion)

        self.removeSpellcheck.execute()
        self.delText.execute()
        self.addText.execute()

        foundNext = 0
        pos = mT.getCursorPos()
        start = pos

        while not foundNext and pos < mT.getLength() and abs(pos-start)<2000:
            if mT.behaviorArray.hasAction("SPELLCHECK", pos):
                foundNext = 1
            else:
                pos += 1
        
        messages.unqueue('persistant')

        if foundNext <> 0:
            mT.setCursor(pos)
            mT.setSelection('selection', mT.cursorPosInText)
            messages.display()
예제 #3
0
    def execute(self):
        c = getSpellChecker()
        c.addToDictionary(self.word)

        mT = archyState.mainText
        oldSel = mT.getSelection('selection')
        mT.setSelection('selection', *self.wordRange)

        self.removeSP = RemoveSpellcheckCommand()
        self.removeSP.execute()

        mT.setSelection('selection', *oldSel)

        foundNext = 0
        pos = mT.getCursorPos()
        start = pos

        while not foundNext and pos < mT.getLength() and abs(pos -
                                                             start) < 2000:
            if mT.behaviorArray.hasAction("SPELLCHECK", pos):
                foundNext = 1
            else:
                pos += 1

        messages.unqueue('persistant')

        if foundNext <> 0:
            mT.setCursor(pos)
            mT.setSelection('selection', mT.cursorPosInText)
            messages.display()
예제 #4
0
 def lastLeapForward(self):
     try:
         archyState.commandHistory.repeatLastLeapForward()
     except commands.AbortCommandException, e:
         messages.hide()
         messages.queue("%s: %s" % ("LEAP Forward again", e.getExplanation()))
         messages.display()
예제 #5
0
파일: spellcheck.py 프로젝트: MySheep/Archy
    def execute(self):
        c = getSpellChecker()
        c.addToDictionary(self.word)

        mT = archyState.mainText
        oldSel = mT.getSelection('selection')
        mT.setSelection('selection', *self.wordRange)
        
        self.removeSP = RemoveSpellcheckCommand()
        self.removeSP.execute()

        mT.setSelection('selection', *oldSel)

        
        foundNext = 0
        pos = mT.getCursorPos()
        start = pos

        while not foundNext and pos < mT.getLength() and abs(pos-start)<2000:
            if mT.behaviorArray.hasAction("SPELLCHECK", pos):
                foundNext = 1
            else:
                pos += 1
        
        messages.unqueue('persistant')

        if foundNext <> 0:
            mT.setCursor(pos)
            mT.setSelection('selection', mT.cursorPosInText)
            messages.display()
예제 #6
0
    def execute(self):
        mT = archyState.mainText

        storage = self.getStorage(archyState.mainText)
        if not storage:
            return

        word = storage.getWord()

        if storage.getSuggestions() <> []:
            suggestions = storage.getSuggestions()
        else:
            c = getSpellChecker()
            suggestions = c.suggest(word.lower())[:8]
            storage.setSuggestions(suggestions)

        suggestions = filter(lambda c: c[0].islower(), suggestions)[:8]

        if word[0].isupper():
            suggestions = map(lambda w: w.title(), suggestions)

        numberedSuggestions = zip(range(1, len(suggestions) + 1), suggestions)

        for num, sug in numberedSuggestions:
            replaceCommand = AbstractReplaceCommand()

            replaceCommand.setName(num)
            replaceCommand.setSuggestion(sug)
            replaceCommand.setRange(self.findExtent(mT))

            archyState.commandMap.unregisterCommand(replaceCommand)
            archyState.commandMap.registerCommand(replaceCommand)

        replaceCommand = AbstractReplaceCommand()
        replaceCommand.setName("K")
        replaceCommand.setSuggestion(word)
        replaceCommand.setRange(self.findExtent(mT))

        archyState.commandMap.unregisterCommand(replaceCommand)
        archyState.commandMap.registerCommand(replaceCommand)

        learnCommand = AbstractLearnCommand()
        learnCommand.setName("LEARN")
        learnCommand.setWord(word)
        learnCommand.setWordRange(self.findExtent(mT))

        archyState.commandMap.unregisterCommand(learnCommand)
        archyState.commandMap.registerCommand(learnCommand)

        message = ' '.join(
            map(lambda ns: '%s-%s' % (ns[0], ns[1]), numberedSuggestions))
        message += '\n%s - %s' % ("K", "Keeps the word")
        message += '\n%s - %s' % ("LEARN", "Learns word")
        messages.queue(message, 'persistant')
        messages.display()
예제 #7
0
파일: spellcheck.py 프로젝트: MySheep/Archy
    def execute(self):
        mT = archyState.mainText
    
        storage = self.getStorage(archyState.mainText)
        if not storage:
            return

        word = storage.getWord()
        
        if storage.getSuggestions() <> []:
            suggestions = storage.getSuggestions()
        else:
            c = getSpellChecker()
            suggestions = c.suggest(word.lower())[:8]
            storage.setSuggestions(suggestions)

        
        suggestions = filter(lambda c:c[0].islower(), suggestions)[:8]

        if word[0].isupper():
            suggestions = map(lambda w:w.title(), suggestions)

        numberedSuggestions = zip(range(1, len(suggestions)+1), suggestions)
        
        for num, sug in numberedSuggestions:
            replaceCommand = AbstractReplaceCommand()
            
            replaceCommand.setName(num)
            replaceCommand.setSuggestion(sug)
            replaceCommand.setRange( self.findExtent(mT) )
            
            archyState.commandMap.unregisterCommand(replaceCommand)
            archyState.commandMap.registerCommand(replaceCommand)
        
        replaceCommand = AbstractReplaceCommand()   
        replaceCommand.setName("K")
        replaceCommand.setSuggestion(word)
        replaceCommand.setRange( self.findExtent(mT) )
            
        archyState.commandMap.unregisterCommand(replaceCommand)
        archyState.commandMap.registerCommand(replaceCommand)
        
        learnCommand = AbstractLearnCommand()
        learnCommand.setName("LEARN")
        learnCommand.setWord(word)
        learnCommand.setWordRange( self.findExtent(mT) )

        archyState.commandMap.unregisterCommand(learnCommand)
        archyState.commandMap.registerCommand(learnCommand)

        message = ' '.join(map(lambda ns:'%s-%s' % (ns[0], ns[1]), numberedSuggestions))
        message += '\n%s - %s' % ("K", "Keeps the word")
        message += '\n%s - %s' % ("LEARN", "Learns word")
        messages.queue(message, 'persistant')
        messages.display()
예제 #8
0
 def _executeCommand(self, command, clearDisplay):
     try:
         archyState.commandHistory.executeCommand(command)
         if clearDisplay:
             messages.hide()
     except SystemExit:
         raise
     except commands.AbortCommandException, e:
         messages.hide()
         messages.queue("%s: %s" % (command.name(), e.getExplanation()))
         messages.display()
예제 #9
0
    def execute(self):
        self.origCursor = archyState.mainText.getCursorPos()
        moveOver = 0
        self.history = []

        startPos, endPos = self.findExtent(archyState.mainText)

        if self.origCursor == startPos:
            moveOver = 1
            archyState.mainText.setCursor(startPos)
        else:
            archyState.mainText.setCursor(endPos + 1)

        if moveOver:
            archyState.mainText.setSelection('selection', startPos, startPos)
            theAction = behavior_editing.RemoveActionCommand(
                self.behaviorName())
            addText = archyState.commandMap.findSystemCommand("AddText")
            addText.setinfo(self.newText, self.newTextStyle)
            theStyle = archyState.commandMap.findSystemCommand("Style")
            theStyle.setinfo(backgroundColor=(255, 255, 255),
                             foregroundColor=(0, 0, 0))

            theAction.execute()
            addText.execute()
            theStyle.execute()

            self.history.append(theAction)
            self.history.append(addText)
            self.history.append(theStyle)

            selStart, selEnd = archyState.mainText.getSelection('selection')
            archyState.mainText.setSelection('selection', selEnd + 1,
                                             selEnd + 1)
            self.theAction = behavior_editing.AddActionCommand(
                self.behaviorName())
            self.theAction.execute()
            self.history.append(self.theAction)

            archyState.mainText.setSelection('selection', selStart, selEnd)
        else:
            addText = archyState.commandMap.findSystemCommand("AddText")
            addText.setinfo(self.newText, self.newTextStyle)
            addText.execute()
            self.history.append(addText)
            messages.queue('You cannot type in Locked text.')
            messages.display()
예제 #10
0
파일: lock.py 프로젝트: MySheep/Archy
 def execute(self):
     self.origCursor = archyState.mainText.getCursorPos()
     moveOver = 0
     self.history = []
     
     startPos, endPos = self.findExtent(archyState.mainText)
     
     if self.origCursor == startPos:
         moveOver = 1
         archyState.mainText.setCursor(startPos)
     else:
         archyState.mainText.setCursor(endPos+1)
     
     if moveOver:
         archyState.mainText.setSelection('selection', startPos, startPos)
         theAction = behavior_editing.RemoveActionCommand(self.behaviorName())
         addText = archyState.commandMap.findSystemCommand("AddText")
         addText.setinfo(self.newText, self.newTextStyle)
         theStyle = archyState.commandMap.findSystemCommand("Style")
         theStyle.setinfo(backgroundColor = (255,255,255), foregroundColor = (0,0,0))
         
         theAction.execute()
         addText.execute()
         theStyle.execute()
         
         self.history.append(theAction)
         self.history.append(addText)
         self.history.append(theStyle)
         
         selStart, selEnd = archyState.mainText.getSelection('selection')
         archyState.mainText.setSelection('selection', selEnd+1, selEnd+1)
         self.theAction = behavior_editing.AddActionCommand(self.behaviorName())
         self.theAction.execute()
         self.history.append(self.theAction)
         
         archyState.mainText.setSelection('selection', selStart, selEnd)
     else:
         addText = archyState.commandMap.findSystemCommand("AddText")
         addText.setinfo(self.newText, self.newTextStyle)
         addText.execute()
         self.history.append(addText)
         messages.queue('You cannot type in Locked text.')
         messages.display()
예제 #11
0
            raise
        except commands.AbortCommandException, e:
            messages.hide()
            messages.queue("%s: %s" % (command.name(), e.getExplanation()))
            messages.display()
        except:
            import debug

            error_name = "Command %s did not run properly." % command.name()
            print error_name
            tb_info = debug.get_traceback()
            debug.report_bug(error_name, tb_info)

            messages.hide()
            messages.queue(error_name)
            messages.display()

    def runCommand(self, command):
        commands.save_and_load.saveChanges()
        self._executeCommand(command, clearDisplay=1)
        archyState.commandHistory.setLastCommand(command)

    def runLastCommand(self):
        lastCommand = archyState.commandHistory.getLastCommand()
        if lastCommand == None:
            return
        if lastCommand.name()[:4] == "LEAP":
            if lastCommand.name()[5:13] == 'backward':
                command = archyState.commandMap.findSystemCommand( "Repeat LEAP backward" )
                command.setinfo( lastCommand._target )
            elif lastCommand.name()[5:12] == 'forward':