Stack-like Undo / Redo history manager: lets the app manage undoable actions.
More...
|
def | __init__ (self, histsize=1e4, cyclic=True, on_update=None, on_pop_undo=None, on_push_undo=None, on_pop_redo=None, on_push_redo=None) |
| Constructor. More...
|
|
def | canundo (self) |
| Checks if there are undoable operations in the Undo stack. More...
|
|
def | canredo (self) |
| Checks if there are redoable operations in the Redo stack. More...
|
|
def | undoable (self, pos=-1) |
| Returns an operation from the Undo stack. More...
|
|
def | redoable (self, pos=-1) |
| Returns an operation from the Redo stack. More...
|
|
def | do (self, command) |
| Executes the given command, adding it to the Undo stack so it can be undone later. More...
|
|
def | undo (self, n=1) |
| Undoes a given number of operations stored in the Undo stack. More...
|
|
def | redo (self, n=1) |
| Redoes a given number of operations stored in the Redo stack. More...
|
|
|
| histsize |
| int Undo / Redo history size More...
|
|
| cyclic |
| bool if True (default) the Undo / Redo stack will automatically remove the oldest operation when the threshold size is reached More...
|
|
| on_update |
| callable callback fired when the Undo or Redo stack is updated More...
|
|
| on_pop_undo |
| callable callback fired when an operation is removed from the Undo stack More...
|
|
| on_push_undo |
| callable callback fired when an operation is added to the Undo stack More...
|
|
| on_pop_redo |
| callable callback fired when an operation is removed from the Redo stack More...
|
|
| on_push_redo |
| callable callback fired when an operation is added to the Redo stack More...
|
|
Stack-like Undo / Redo history manager: lets the app manage undoable actions.
◆ __init__()
def pycross.utils.undo.CommandManager.__init__ |
( |
|
self, |
|
|
|
histsize = 1e4 , |
|
|
|
cyclic = True , |
|
|
|
on_update = None , |
|
|
|
on_pop_undo = None , |
|
|
|
on_push_undo = None , |
|
|
|
on_pop_redo = None , |
|
|
|
on_push_redo = None |
|
) |
| |
Constructor.
- Parameters
-
histsize | int Undo / Redo history size (max number of operations stored in each stack); default is 10k |
cyclic | bool if True (default) the Undo / Redo stack will automatically remove the oldest operation when the threshold size is reached; if False , the HistoryOverflowError excetion will be raised. |
on_update | callable callback fired when the Undo or Redo stack is updated |
on_pop_undo | callable callback fired when an operation is removed from the Undo stack |
on_push_undo | callable callback fired when an operation is added to the Undo stack |
on_pop_redo | callable callback fired when an operation is removed from the Redo stack |
on_push_redo | callable callback fired when an operation is added to the Redo stack |
◆ _pop_redo_command()
def pycross.utils.undo.CommandManager._pop_redo_command |
( |
|
self | ) |
|
|
private |
Removes the latest operation from the Redo stack and returns it.
- Returns
Operation
the removed command
◆ _pop_undo_command()
def pycross.utils.undo.CommandManager._pop_undo_command |
( |
|
self | ) |
|
|
private |
Removes the latest operation from the Undo stack and returns it.
- Returns
Operation
the removed command
◆ _push_redo_command()
def pycross.utils.undo.CommandManager._push_redo_command |
( |
|
self, |
|
|
|
command |
|
) |
| |
|
private |
Stores (appends) a command in the Redo stack.
The Redo stack adds operations removed from the Undo stack (so they can be redone later). If the max stack size is reached, the history will remove the oldest operation if CommandManager::cyclic is True
or raise the HistoryOverflowError error.
- Parameters
-
◆ _push_undo_command()
def pycross.utils.undo.CommandManager._push_undo_command |
( |
|
self, |
|
|
|
command |
|
) |
| |
|
private |
Stores (appends) a new command in the Undo stack.
If the max stack size is reached, the history will remove the oldest operation if CommandManager::cyclic is True
or raise the HistoryOverflowError error.
- Parameters
-
◆ canredo()
def pycross.utils.undo.CommandManager.canredo |
( |
|
self | ) |
|
Checks if there are redoable operations in the Redo stack.
- Returns
bool
whether there are redoable operations in the Redo stack
- See also
- CommandManager::canundo()
◆ canundo()
def pycross.utils.undo.CommandManager.canundo |
( |
|
self | ) |
|
Checks if there are undoable operations in the Undo stack.
- Returns
bool
whether there are undoable operations in the Undo stack
- See also
- CommandManager::canredo()
◆ do()
def pycross.utils.undo.CommandManager.do |
( |
|
self, |
|
|
|
command |
|
) |
| |
Executes the given command, adding it to the Undo stack so it can be undone later.
- Parameters
-
◆ redo()
def pycross.utils.undo.CommandManager.redo |
( |
|
self, |
|
|
|
n = 1 |
|
) |
| |
Redoes a given number of operations stored in the Redo stack.
- Parameters
-
n | int number of operations to redo (rewinding the stack) |
- Returns
bool
True
on success, False
on failure to redo
◆ redoable()
def pycross.utils.undo.CommandManager.redoable |
( |
|
self, |
|
|
|
pos = -1 |
|
) |
| |
Returns an operation from the Redo stack.
- Parameters
-
pos | int index of the operation |
- Returns
Command
redoable operation
◆ undo()
def pycross.utils.undo.CommandManager.undo |
( |
|
self, |
|
|
|
n = 1 |
|
) |
| |
Undoes a given number of operations stored in the Undo stack.
- Parameters
-
n | int number of operations to undo (rewinding the stack) |
- Returns
bool
True
on success, False
on failure to undo
◆ undoable()
def pycross.utils.undo.CommandManager.undoable |
( |
|
self, |
|
|
|
pos = -1 |
|
) |
| |
Returns an operation from the Undo stack.
- Parameters
-
pos | int index of the operation |
- Returns
Command
undoable operation
◆ _redo_commands
pycross.utils.undo.CommandManager._redo_commands |
|
private |
◆ _undo_commands
pycross.utils.undo.CommandManager._undo_commands |
|
private |
◆ cyclic
pycross.utils.undo.CommandManager.cyclic |
bool
if True
(default) the Undo / Redo stack will automatically remove the oldest operation when the threshold size is reached
◆ histsize
pycross.utils.undo.CommandManager.histsize |
int
Undo / Redo history size
◆ on_pop_redo
pycross.utils.undo.CommandManager.on_pop_redo |
callable
callback fired when an operation is removed from the Redo stack
◆ on_pop_undo
pycross.utils.undo.CommandManager.on_pop_undo |
callable
callback fired when an operation is removed from the Undo stack
◆ on_push_redo
pycross.utils.undo.CommandManager.on_push_redo |
callable
callback fired when an operation is added to the Redo stack
◆ on_push_undo
pycross.utils.undo.CommandManager.on_push_undo |
callable
callback fired when an operation is added to the Undo stack
◆ on_update
pycross.utils.undo.CommandManager.on_update |
callable
callback fired when the Undo or Redo stack is updated
The documentation for this class was generated from the following file: