pub struct History { /* private fields */ }Expand description
Undo/redo history using invertible transactions.
Consecutive single-character edits are coalesced into groups so that undoing “typed a word” undoes the whole word, not one char at a time.
Implementations§
Source§impl History
impl History
pub fn new() -> Self
Sourcepub fn push(&mut self, tx: Transaction)
pub fn push(&mut self, tx: Transaction)
Record a transaction. Clears the redo stack. Tries to coalesce with the most recent undo entry.
Sourcepub fn undo(&mut self) -> Option<Transaction>
pub fn undo(&mut self) -> Option<Transaction>
Pop the most recent transaction for undo. Returns its inverse (which should be applied to revert the change).
Sourcepub fn redo(&mut self) -> Option<Transaction>
pub fn redo(&mut self) -> Option<Transaction>
Pop the most recent redo transaction. Returns it (which should be re-applied).
Sourcepub fn mark_clean(&mut self)
pub fn mark_clean(&mut self)
Mark the current state as clean (e.g., after save). Also forces the next edit into a new undo group so that undoing back to this point is always possible.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for History
impl RefUnwindSafe for History
impl Send for History
impl Sync for History
impl Unpin for History
impl UnsafeUnpin for History
impl UnwindSafe for History
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