rekordbox_set_list_manager.controllers.undo_stack#
Generic JSON-snapshot undo/redo stack.
Classes#
Undo/redo stack that stores serialised snapshots of type T. |
Module Contents#
- class rekordbox_set_list_manager.controllers.undo_stack.UndoStack[T](max_size=_DEFAULT_MAX)[source]#
Undo/redo stack that stores serialised snapshots of type T.
Usage:
stack: UndoStack[str] = UndoStack() # Before a mutation: stack.push(current_snapshot) # Undo: prev = stack.undo(current_snapshot) # Redo: next_ = stack.redo(current_snapshot)
- Parameters:
max_size (int)
- push(snapshot)[source]#
Record snapshot before a mutation. Clears the redo stack.
- Parameters:
snapshot (T) – The serialised project state to push onto the undo history.
- Return type:
None
- undo(current)[source]#
Undo one step. Returns the previous snapshot, or None if empty.
The caller must pass the current snapshot so it can be pushed to the redo stack.
- Parameters:
current (T) – The current serialised state, saved to the redo stack.
- Returns:
The previous snapshot to restore, or
Noneif the undo stack is empty.- Return type:
T | None
- redo(current)[source]#
Redo one step. Returns the next snapshot, or None if empty.
The caller must pass the current snapshot so it can be pushed back to the undo stack.
- Parameters:
current (T) – The current serialised state, saved back to the undo stack.
- Returns:
The next snapshot to restore, or
Noneif the redo stack is empty.- Return type:
T | None