pub struct UndoRedoManager {
pub node_stacks: Vec<NodeUndoRedoStack>,
}Expand description
Manager for undo/redo operations across all text nodes
Fields§
§node_stacks: Vec<NodeUndoRedoStack>Per-node undo/redo stacks Using Vec instead of HashMap for no_std compatibility
Implementations§
Source§impl UndoRedoManager
impl UndoRedoManager
Sourcepub fn get_or_create_stack_mut(
&mut self,
node_id: NodeId,
) -> &mut NodeUndoRedoStack
pub fn get_or_create_stack_mut( &mut self, node_id: NodeId, ) -> &mut NodeUndoRedoStack
Get or create a stack for a specific node
Sourcepub fn get_stack(&self, node_id: NodeId) -> Option<&NodeUndoRedoStack>
pub fn get_stack(&self, node_id: NodeId) -> Option<&NodeUndoRedoStack>
Get a stack for a specific node (immutable)
Sourcepub fn record_operation(
&mut self,
changeset: TextChangeset,
pre_state: NodeStateSnapshot,
)
pub fn record_operation( &mut self, changeset: TextChangeset, pre_state: NodeStateSnapshot, )
Record a text operation (push to undo stack)
This should be called AFTER a changeset has been successfully applied. The pre_state should contain the node state BEFORE the changeset was applied.
§Arguments
changeset- The changeset that was appliedpre_state- Node state before the changeset
Sourcepub fn peek_undo(&self, node_id: NodeId) -> Option<&UndoableOperation>
pub fn peek_undo(&self, node_id: NodeId) -> Option<&UndoableOperation>
Peek at the next undo operation for a node (without removing it)
This allows user callbacks to inspect what would be undone.
Sourcepub fn peek_redo(&self, node_id: NodeId) -> Option<&UndoableOperation>
pub fn peek_redo(&self, node_id: NodeId) -> Option<&UndoableOperation>
Peek at the next redo operation for a node (without removing it)
This allows user callbacks to inspect what would be redone.
Sourcepub fn pop_undo(&mut self, node_id: NodeId) -> Option<UndoableOperation>
pub fn pop_undo(&mut self, node_id: NodeId) -> Option<UndoableOperation>
Pop an operation from the undo stack
This should be called during undo processing to get the operation to revert. After reverting, the operation should be pushed to the redo stack.
§Returns
Some(operation)- The operation to undoNone- No undo history available
Sourcepub fn pop_redo(&mut self, node_id: NodeId) -> Option<UndoableOperation>
pub fn pop_redo(&mut self, node_id: NodeId) -> Option<UndoableOperation>
Pop an operation from the redo stack
This should be called during redo processing to get the operation to re-apply. After re-applying, the operation should be pushed to the undo stack.
§Returns
Some(operation)- The operation to redoNone- No redo history available
Sourcepub fn push_redo(&mut self, operation: UndoableOperation)
pub fn push_redo(&mut self, operation: UndoableOperation)
Push an operation to the redo stack (after successful undo)
This should be called AFTER an undo operation has been successfully applied.
Sourcepub fn push_undo(&mut self, operation: UndoableOperation)
pub fn push_undo(&mut self, operation: UndoableOperation)
Push an operation to the undo stack (after successful redo)
This should be called AFTER a redo operation has been successfully applied.
Sourcepub fn clear_node(&mut self, node_id: NodeId)
pub fn clear_node(&mut self, node_id: NodeId)
Clear all undo/redo history for a specific node
Sourcepub fn undo_depth(&self, node_id: NodeId) -> usize
pub fn undo_depth(&self, node_id: NodeId) -> usize
Get the total number of operations in undo stack for a node
Sourcepub fn redo_depth(&self, node_id: NodeId) -> usize
pub fn redo_depth(&self, node_id: NodeId) -> usize
Get the total number of operations in redo stack for a node
Trait Implementations§
Source§impl Clone for UndoRedoManager
impl Clone for UndoRedoManager
Source§fn clone(&self) -> UndoRedoManager
fn clone(&self) -> UndoRedoManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UndoRedoManager
impl Debug for UndoRedoManager
Source§impl Default for UndoRedoManager
impl Default for UndoRedoManager
Source§fn default() -> UndoRedoManager
fn default() -> UndoRedoManager
Auto Trait Implementations§
impl Freeze for UndoRedoManager
impl RefUnwindSafe for UndoRedoManager
impl Send for UndoRedoManager
impl Sync for UndoRedoManager
impl Unpin for UndoRedoManager
impl UnwindSafe for UndoRedoManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more