grapa.shared.command_recorder.CommandRecorderBase
- class grapa.shared.command_recorder.CommandRecorderBase(log_active=True)
Bases:
ABCRecords commands (actions) performed on a graph, to allow undo/redo. Each command is associated to a caller (graph, graphinfo, headers, curve, curve.data). The caller is identified automatically by inspecting the call stack.
- __init__(log_active=True)
Methods
__init__([log_active])caller_description(reference)Returns a list of Action, that can be used later to identify 'caller'
caller_reference(description)Returns e.g. reference of en object, identified from a list of Action.
deletes data corresponding to the oldest transaction in .past
is_log_active([new])is CommandRecorder active? can be paused
Return the last command in the past stack, or COMMAND_NULL if empty.
log(caller, do, undo[, tag_special, ...])Register a command, with do and undo actions.
log_special(tag[, blend_into_transaction])Log a special command with no effect, just a tag.
redo_next_transaction([revert_if_fail])Redo commands until a marked command is reached (including that one).
Redo one command from the future stack.
Set a mark on the last command in the stack past.
Return the number of commands in past and future, grouped by marks.
undo_last_transaction([revert_if_fail])Undo at least 1 command until a marked command is reached (excluding)
Undo one command from the past stack.
Attributes
COMMAND_NULLMAX_N_TRANSACTIONS- abstractmethod caller_description(reference) → List[Action]
Returns a list of Action, that can be used later to identify ‘caller’
- abstractmethod caller_reference(description: List[Action])
Returns e.g. reference of en object, identified from a list of Action.
- delete_oldest_transaction()
deletes data corresponding to the oldest transaction in .past
- is_log_active(new: bool | None = None)
is CommandRecorder active? can be paused
- last_command()
Return the last command in the past stack, or COMMAND_NULL if empty.
- log(caller, do: Tuple[str, list, dict], undo: Tuple[str, list, dict], tag_special: str = '', blend_into_transaction=False)
Register a command, with do and undo actions.
- log_special(tag: str, blend_into_transaction=True)
Log a special command with no effect, just a tag. Application example: mark save points.
- redo_next_transaction(revert_if_fail=True)
Redo commands until a marked command is reached (including that one).
- redo_once()
Redo one command from the future stack.
- tag_as_end_transaction()
Set a mark on the last command in the stack past.
- transactions_length() → Tuple[List[int], List[int]]
Return the number of commands in past and future, grouped by marks.
- undo_last_transaction(revert_if_fail=True)
Undo at least 1 command until a marked command is reached (excluding)
- undo_once()
Undo one command from the past stack.