zng_ext_undo

Trait UndoAction

source
pub trait UndoAction: Send + Any {
    // Required methods
    fn info(&mut self) -> Arc<dyn UndoInfo>;
    fn undo(self: Box<Self>) -> Box<dyn RedoAction>;
    fn as_any(&mut self) -> &mut dyn Any;
    fn merge(
        self: Box<Self>,
        args: UndoActionMergeArgs,
    ) -> Result<Box<dyn UndoAction>, (Box<dyn UndoAction>, Box<dyn UndoAction>)>;
}
Expand description

Represents a single undo action.

Required Methods§

source

fn info(&mut self) -> Arc<dyn UndoInfo>

Gets display info about the action that registered this undo.

source

fn undo(self: Box<Self>) -> Box<dyn RedoAction>

Undo action and returns a RedoAction that redoes it.

source

fn as_any(&mut self) -> &mut dyn Any

Access dyn Any methods.

source

fn merge( self: Box<Self>, args: UndoActionMergeArgs, ) -> Result<Box<dyn UndoAction>, (Box<dyn UndoAction>, Box<dyn UndoAction>)>

Try merge the next action with the previous self.

This is called when self is the latest registered action and next is registered.

This can be used to optimize high-volume actions, but note that UNDO.undo will undo all actions within the UNDO.undo_interval of the previous, even if not merged, and merged actions always show as one action for UNDO.undo_select.

Implementors§