示例#1
0
文件: lock.py 项目: shalomemu/Archy
    def execute(self):
        start, end = archyState.mainText.getSelection('selection')
        
        self.theAction = behavior_editing.RemoveActionCommand("LOCK")
        self.theAction.execute()

        self.theAction2 = behavior_editing.RemoveActionCommand("FORM LOCK")
        self.theAction2.execute()
        
        self.theStyle = archyState.commandMap.findSystemCommand("Style")
        self.theStyle.setinfo(backgroundColor = (255,255,255), foregroundColor = (0,0,0))
        self.theStyle.execute()
示例#2
0
    def execute(self):
        textRange = archyState.mainText.getSelection('selection')

        theMin, theMax = textRange

        calcPos = archyState.mainText.behaviorArray.firstActionInRange(
            "CALC", *textRange)
        while calcPos:
            calcRange = archyState.mainText.behaviorArray.findActionExtent(
                "CALC", calcPos)
            storage = archyState.mainText.behaviorArray.getStorage(
                "CALC", calcPos)

            originalExpression = storage.getExpression()

            archyState.mainText.setSelection('selection', *calcRange)

            self.theAction = behavior_editing.RemoveActionCommand("CALC")
            self.theAction.execute()

            # TO DO: When UnCalc is restored, the two commands need to use the find command technique.
            #archyState.commandMap.findSystemCommand("AddText")
            #text_editing.DeleteTextCommand().execute()
            #text_editing.AddTextCommand(originalExpression).execute()

            addedStart, addedEnd = archyState.mainText.getSelection(
                'selection')
            theMin = min(theMin, addedStart)
            theMax = max(theMax, addedEnd)

            calcPos = archyState.mainText.behaviorArray.firstActionInRange(
                "CALC", *textRange)

        archyState.mainText.setSelection('selection', theMin, theMax)
示例#3
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()