pub struct UndoStack { /* private fields */ }Expand description
A bounded undo/redo stack for text editing.
Stores up to max_history operations. When the limit is reached,
the oldest operation is dropped. Pushing a new operation clears
the redo stack.
Implementations§
Source§impl UndoStack
impl UndoStack
Sourcepub fn new(max_history: usize) -> Self
pub fn new(max_history: usize) -> Self
Create a new undo stack with the given maximum history size.
Sourcepub fn push(&mut self, op: EditOperation)
pub fn push(&mut self, op: EditOperation)
Push a new operation onto the undo stack.
This clears the redo stack. If the undo stack exceeds
max_history, the oldest operation is dropped.
Sourcepub fn undo(&mut self) -> Option<EditOperation>
pub fn undo(&mut self) -> Option<EditOperation>
Pop the most recent operation and return its inverse for undoing.
The operation is moved to the redo stack.
Sourcepub fn redo(&mut self) -> Option<EditOperation>
pub fn redo(&mut self) -> Option<EditOperation>
Pop the most recent redo operation and return it for reapplying.
The operation is moved back to the undo stack.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UndoStack
impl RefUnwindSafe for UndoStack
impl Send for UndoStack
impl Sync for UndoStack
impl Unpin for UndoStack
impl UnwindSafe for UndoStack
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
Mutably borrows from an owned value. Read more