MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / InternalCommandHistory

Class InternalCommandHistory

gui/fitCommands/helpers.py:21–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19
20
21class InternalCommandHistory:
22
23 def __init__(self):
24 self.__buffer = wx.CommandProcessor()
25
26 def submit(self, command):
27 return self.__buffer.Submit(command)
28
29 def submitBatch(self, *commands):
30 for command in commands:
31 if not self.__buffer.Submit(command):
32 # Undo what we already submitted
33 for commandToUndo in reversed(self.__buffer.Commands):
34 if commandToUndo in commands:
35 self.__buffer.Undo()
36 return False
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)
57
58
59class ModuleInfo:

Callers 15

__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected