pub struct HistoryManager { /* private fields */ }Expand description
Manager for undo/redo history.
Maintains dual stacks for undo and redo operations with configurable memory and depth limits.
Implementations§
Source§impl HistoryManager
impl HistoryManager
Sourcepub fn new(config: HistoryConfig) -> Self
pub fn new(config: HistoryConfig) -> Self
Create a new history manager with the given configuration.
Sourcepub fn push(&mut self, cmd: Box<dyn UndoableCmd>)
pub fn push(&mut self, cmd: Box<dyn UndoableCmd>)
Push a command onto the undo stack.
This clears the redo stack (new branch) and enforces limits. The command is NOT executed - it’s assumed to have already been executed.
Sourcepub fn undo(&mut self) -> Option<Result<String, CommandError>>
pub fn undo(&mut self) -> Option<Result<String, CommandError>>
Undo the last command.
Moves the command from undo stack to redo stack and calls undo().
§Returns
Ok(description)if undo succeededErr(error)if undo failed (command remains on undo stack)Noneif no commands to undo
Sourcepub fn redo(&mut self) -> Option<Result<String, CommandError>>
pub fn redo(&mut self) -> Option<Result<String, CommandError>>
Redo the last undone command.
Moves the command from redo stack to undo stack and calls redo().
§Returns
Ok(description)if redo succeededErr(error)if redo failed (command remains on redo stack)Noneif no commands to redo
Sourcepub fn undo_depth(&self) -> usize
pub fn undo_depth(&self) -> usize
Get the undo stack depth.
Sourcepub fn redo_depth(&self) -> usize
pub fn redo_depth(&self) -> usize
Get the redo stack depth.
Sourcepub fn undo_descriptions(&self, limit: usize) -> Vec<&str>
pub fn undo_descriptions(&self, limit: usize) -> Vec<&str>
Get descriptions for undo commands (most recent first).
Sourcepub fn redo_descriptions(&self, limit: usize) -> Vec<&str>
pub fn redo_descriptions(&self, limit: usize) -> Vec<&str>
Get descriptions for redo commands (most recent first).
Sourcepub fn next_undo_description(&self) -> Option<&str>
pub fn next_undo_description(&self) -> Option<&str>
Get the description of the next undo command.
Sourcepub fn next_redo_description(&self) -> Option<&str>
pub fn next_redo_description(&self) -> Option<&str>
Get the description of the next redo command.
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Get total memory usage in bytes.
Sourcepub fn config(&self) -> &HistoryConfig
pub fn config(&self) -> &HistoryConfig
Get the current configuration.