pub struct History<S> { /* private fields */ }Expand description
the undo and redo steps of a state S
Implementations§
Source§impl<S: 'static> History<S>
impl<S: 'static> History<S>
pub fn new(limit: usize) -> Self
Sourcepub fn apply(&mut self, s: &mut S, edit: Box<dyn Edit<S>>)
pub fn apply(&mut self, s: &mut S, edit: Box<dyn Edit<S>>)
run the edit and record it as the newest step (redo steps are gone)
Sourcepub fn undo(&mut self, s: &mut S) -> bool
pub fn undo(&mut self, s: &mut S) -> bool
take the newest step back -> false when there is none
Sourcepub fn redo(&mut self, s: &mut S) -> bool
pub fn redo(&mut self, s: &mut S) -> bool
do the last undone step again -> false when there is none
pub fn can_undo(&self) -> bool
pub fn can_redo(&self) -> bool
Sourcepub fn undo_label(&self) -> Option<&str>
pub fn undo_label(&self) -> Option<&str>
the label of the step undo would take back
Sourcepub fn redo_label(&self) -> Option<&str>
pub fn redo_label(&self) -> Option<&str>
the label of the step redo would do again
Sourcepub fn undo_value(&self) -> Option<&dyn Any>
pub fn undo_value(&self) -> Option<&dyn Any>
the step undo would take back as data (Edit::value; None for a group): the app can see what kind of edit it is before it runs
Sourcepub fn redo_value(&self) -> Option<&dyn Any>
pub fn redo_value(&self) -> Option<&dyn Any>
the step redo would do again as data (Edit::value)
Sourcepub fn group_begin(&mut self, label: &str)
pub fn group_begin(&mut self, label: &str)
the following edits are one step (nested groups join the outer one)
Sourcepub fn mark_saved(&mut self)
pub fn mark_saved(&mut self)
the state is saved now (dirty() false until the next change)
Sourcepub fn mark_unsaved(&mut self)
pub fn mark_unsaved(&mut self)
the state counts as unsaved until the next mark_saved (a copy recovered after a crash)
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl<S> !RefUnwindSafe for History<S>
impl<S> !Send for History<S>
impl<S> !Sync for History<S>
impl<S> !UnwindSafe for History<S>
impl<S> Forget for History<S>
impl<S> Freeze for History<S>
impl<S> Unpin for History<S>
impl<S> UnsafeUnpin for History<S>
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