| 37 | return True |
| 38 | |
| 39 | def undoAll(self): |
| 40 | undoneCommands = [] |
| 41 | # Undo commands one by one, starting from the last |
| 42 | for commandToUndo in reversed(self.__buffer.Commands): |
| 43 | if commandToUndo.Undo(): |
| 44 | undoneCommands.append(commandToUndo) |
| 45 | # If undoing fails, redo already undone commands, starting from the last undone |
| 46 | else: |
| 47 | for commandToRedo in reversed(undoneCommands): |
| 48 | if not commandToRedo.Do(): |
| 49 | break |
| 50 | self.__buffer.ClearCommands() |
| 51 | return False |
| 52 | self.__buffer.ClearCommands() |
| 53 | return True |
| 54 | |
| 55 | def __len__(self): |
| 56 | return len(self.__buffer.Commands) |