Skip to main content

UndoStack

Struct UndoStack 

Source
pub struct UndoStack { /* private fields */ }
Expand description

One undo history over the stores it UndoStack::watches: units are turns (everything one event’s dispatch changed), inverted, not snapshots. Enabling it turns on standing value capture; drop the stack and the capture stops.

Implementations§

Source§

impl UndoStack

Source

pub fn new(levels: usize) -> UndoStack

A stack holding at most levels units: the bound on what history keeps in RAM.

Source

pub fn watch<T>(&self, store: Store<Keyed<T>>)
where T: ApplyField + Identified + Clone + 'static,

Bring one store under this history. Only watched stores are captured; a change in any other store passes the stack by.

Source

pub fn grouped(&self, label: &'static str, f: impl FnOnce())

Everything f changes lands as one unit named label: a multi-field commit, an inspector applying twelve properties.

Source

pub fn begin_group(&self, label: &'static str) -> UndoGroup

Keep one undo unit open across event turns, until the returned guard is dropped. Nested groups join the outer unit and retain its label. Keep the guard only for the duration of the interaction: all watched edits in that interval belong to the group.

Source

pub fn checkpoint(&self) -> UndoCheckpoint

Preserve history before an atomic persistence operation. Failed commits must restore both the database/cache and this checkpoint, including an existing redo branch.

Source

pub fn restore_checkpoint(&self, checkpoint: UndoCheckpoint)

Source

pub fn can_undo(&self) -> Signal<bool>

Source

pub fn can_redo(&self) -> Signal<bool>

Source

pub fn undo_label(&self) -> Signal<String>

The next undo unit’s display label (“Name”, or whatever the resolver makes of it), empty when there is nothing to undo. What a menu title interpolates.

Source

pub fn redo_label(&self) -> Signal<String>

Source

pub fn set_label_resolver(&self, f: impl Fn(&'static str) -> String + 'static)

How unit labels become display text (Fluent lookup, capitalization); the default capitalizes the raw label.

Source

pub fn set_transient_context( &self, capture: impl Fn() -> Rc<dyn Any> + 'static, restore: impl Fn(&(dyn Any + 'static)) + 'static, )

Ride transient UI state (a selection, a scroll position) along the history: captured, never persisted (docs/model.md “Transient UI state”).

capture runs as each unit seals, so a snapshot is the UI state at that point of document history, including any selection writes the same turn made. Undo restores the snapshot of the unit history lands on: the previous unit’s, or the base snapshot (taken here, at install) once the last unit is undone; redo restores the redone unit’s own. UI changes between units restore nowhere: they are not history, which is what makes “select A, move it, select B, move it, undo” land on A (the state as it stood when A’s move sealed) rather than on B.

restore must not write a watched store (that would fork history from inside a replay); write plain signals. A unit sealed before this call carries no snapshot and restores nothing.

Source

pub fn undo(&self) -> bool

Source

pub fn redo(&self) -> bool

Source

pub fn clear(&self)

Drop all history (a schema migration, a wholesale reload).

Trait Implementations§

Source§

impl Clone for UndoStack

Source§

fn clone(&self) -> UndoStack

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoReactive<T, StaticMark> for T
where T: Clone + 'static,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.