Skip to main content

History

Struct History 

Source
pub struct History<S> { /* private fields */ }
Expand description

the undo and redo steps of a state S

Implementations§

Source§

impl<S: 'static> History<S>

Source

pub fn new(limit: usize) -> Self

Source

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)

Source

pub fn record(&mut self, edit: Box<dyn Edit<S>>)

record an edit that was already applied

Source

pub fn undo(&mut self, s: &mut S) -> bool

take the newest step back -> false when there is none

Source

pub fn redo(&mut self, s: &mut S) -> bool

do the last undone step again -> false when there is none

Source

pub fn can_undo(&self) -> bool

Source

pub fn can_redo(&self) -> bool

Source

pub fn undo_label(&self) -> Option<&str>

the label of the step undo would take back

Source

pub fn redo_label(&self) -> Option<&str>

the label of the step redo would do again

Source

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

Source

pub fn redo_value(&self) -> Option<&dyn Any>

the step redo would do again as data (Edit::value)

Source

pub fn group_begin(&mut self, label: &str)

the following edits are one step (nested groups join the outer one)

Source

pub fn group_end(&mut self)

close the group of group_begin (an empty group records nothing)

Source

pub fn mark_saved(&mut self)

the state is saved now (dirty() false until the next change)

Source

pub fn mark_unsaved(&mut self)

the state counts as unsaved until the next mark_saved (a copy recovered after a crash)

Source

pub fn dirty(&self) -> bool

the state differs from the saved one

Source

pub fn clear(&mut self)

forget every step (the current state counts as saved when it was)

Source

pub fn len(&self) -> usize

the number of undo steps

Source

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>
where Vec<Box<dyn Edit<S>>>: Freeze, Vec<(String, Vec<Box<dyn Edit<S>>>)>: Freeze,

§

impl<S> Unpin for History<S>
where Vec<Box<dyn Edit<S>>>: Unpin, Vec<(String, Vec<Box<dyn Edit<S>>>)>: Unpin,

§

impl<S> UnsafeUnpin for History<S>
where Vec<Box<dyn Edit<S>>>: UnsafeUnpin, Vec<(String, Vec<Box<dyn Edit<S>>>)>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.