pub struct UndoBuffer { /* private fields */ }Expand description
Two-stack undo/redo history buffer.
Mirrors the C# UndoBuffer class: when a new action is added the redo
stack is cleared (so a new branch cannot be redone). The undo stack is
size-limited; the oldest entries are dropped when the limit is exceeded.
Implementations§
Source§impl UndoBuffer
impl UndoBuffer
Sourcepub fn with_max_undos(self, n: usize) -> Self
pub fn with_max_undos(self, n: usize) -> Self
Set the maximum number of undo steps retained.
Sourcepub fn add(&mut self, cmd: Box<dyn UndoRedoCommand>)
pub fn add(&mut self, cmd: Box<dyn UndoRedoCommand>)
Push cmd without executing it.
Use this when the action has already been applied to the state; the command only needs to know how to undo (and redo) it. Clears the redo stack.
Sourcepub fn add_and_do(&mut self, cmd: Box<dyn UndoRedoCommand>)
pub fn add_and_do(&mut self, cmd: Box<dyn UndoRedoCommand>)
Execute cmd.do_it() and push it onto the undo stack.
Use this when the action has not yet been applied.
Sourcepub fn redo(&mut self)
pub fn redo(&mut self)
Redo the most recently undone operation. No-op if the redo stack is empty.
Sourcepub fn can_undo(&self) -> bool
pub fn can_undo(&self) -> bool
Returns true if there is at least one operation that can be undone.
Sourcepub fn can_redo(&self) -> bool
pub fn can_redo(&self) -> bool
Returns true if there is at least one operation that can be redone.
Sourcepub fn undo_name(&self) -> Option<&str>
pub fn undo_name(&self) -> Option<&str>
Name of the operation that undo() would reverse, if any.
Sourcepub fn redo_name(&self) -> Option<&str>
pub fn redo_name(&self) -> Option<&str>
Name of the operation that redo() would re-apply, if any.
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Discard all undo and redo history.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UndoBuffer
impl !RefUnwindSafe for UndoBuffer
impl !Send for UndoBuffer
impl !Sync for UndoBuffer
impl Unpin for UndoBuffer
impl UnsafeUnpin for UndoBuffer
impl !UnwindSafe for UndoBuffer
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().