From 5616c6c0e766c270712ef1794be8e062663b6a63 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 10 Sep 2013 14:45:46 +0200 Subject: implement edit reverse, direction change and add specification for push and pop to editring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/editring.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/editring.py b/src/editring.py index 4c304be..ac3db90 100644 --- a/src/editring.py +++ b/src/editring.py @@ -38,6 +38,15 @@ class Edit(): ''' self.deleted, self.inserted = deleted, inserted self.y, self.old_x, self.new_x = y, old_x, new_x + + + def reverse(self): + ''' + Create a clone of the object but create a mirror object + + @return :Edit The object's opposite + ''' + return Edit(self.inserted, self.deleted, self.y, self.new_x, self.new_y) @@ -62,4 +71,28 @@ class Editring(): @return :bool Whether the editring is empty ''' return len(self.editring) == 0 - + + + def change_direction(self): + ''' + Swap between undoing and redoing + ''' + self.editdir = -(self.editdir) + + + def push(self, edit): + ''' + Insert a new edit to the editring + + @param edit:Edit The edit to insert + ''' + pass + + + def pop(self): + ''' + Get the next undo or redo + + @return :(Edit, bool) The edit to preform (not reverse) and whether it is a undo + ''' + pass -- cgit v1.2.3-70-g09d2