示例#1
0
    def redo(self):
        ''' Redoes the last undo operation. Use can_redo to check whether a call
        to this function will have any effect.
        '''

        if not self._redos: return None
        action = self._redos.pop()
        if isinstance(action, Insert):
            self._undos.append(action)
            UnformattedDocument.insert_text(self, action.start, action.text)
            return action.end
        elif isinstance(action, Delete):
            self._undos.append(action)
            UnformattedDocument.delete_text(self, action.start, action.end)
            return action.start
        return None
示例#2
0
    def delete_text(self, start, end):
        '''Delete text from the document.

        :Parameters:
            `start` : int
                Starting character position to delete from.
            `end` : int
                Ending character position to delete to (exclusive).

        '''
        if self._undoable_action:
            action = Delete(start, self.text[start:end]) 
            if self._undos:
                last = self._undos[-1]
                if not last.merge(action):
                    self._undos.append(action)
            else:
                self._undos.append(action)
            #print self._undos
        UnformattedDocument.delete_text(self, start, end)