etui/undo
Types
Generic undo/redo history.
present, the current value.past, previous values, most-recent first.future, values undone and available to redo, most-recent first.max_size, maximum entries kept inpast(0 = unlimited).
pub type UndoStack(a) {
UndoStack(
past: List(a),
present: a,
future: List(a),
max_size: Int,
)
}
Constructors
-
UndoStack( past: List(a), present: a, future: List(a), max_size: Int, )
Values
pub fn can_redo(stack: UndoStack(a)) -> Bool
True if there is at least one future state to redo to.
pub fn can_undo(stack: UndoStack(a)) -> Bool
True if there is at least one past state to undo to.
pub fn push(stack: UndoStack(a), new_value: a) -> UndoStack(a)
Record new_value as the new present, moving the old present into past.
Clears the future (redo history) since the branch diverged.
pub fn redo(stack: UndoStack(a)) -> UndoStack(a)
Redo: move present to past, restore the most-recent future as present. No-op if there is nothing to redo.
pub fn reset(stack: UndoStack(a), initial: a) -> UndoStack(a)
Reset to initial state, clearing all history.
pub fn undo(stack: UndoStack(a)) -> UndoStack(a)
Undo: move present to future, restore the most-recent past as present. No-op if there is nothing to undo.
pub fn undo_depth(stack: UndoStack(a)) -> Int
Number of past entries available to undo.