Last active
April 12, 2019 12:34
-
-
Save Sean-Bradley/9f354bbaf7623ed55e966890d1cc8409 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property | |
def history(self): | |
"""Return all records in the History list""" | |
return self._history | |
def undo(self): | |
"""Undo a command if there is a command that can be undone. | |
Update the history psoition so that further UNDOs or REDOs | |
point to the correct index""" | |
if self._history_position > 0: | |
self._history_position -= 1 | |
self._commands[ | |
self._history[self._history_position][1] | |
].execute(self._history[self._history_position][2]) | |
else: | |
print("nothing to undo") | |
def redo(self): | |
"""Perform a REDO if the history_position is less than the end of the history list""" | |
if self._history_position + 1 < len(self._history): | |
self._history_position += 1 | |
self._commands[ | |
self._history[self._history_position][1] | |
].execute(self._history[self._history_position][2]) | |
else: | |
print("nothing to REDO") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment