Skip to main content

CommandStack

Struct CommandStack 

Source
pub struct CommandStack { /* private fields */ }

Implementations§

Source§

impl CommandStack

Source

pub fn new(max_depth: usize) -> Self

Source

pub fn can_undo(&self) -> bool

Source

pub fn can_redo(&self) -> bool

Source

pub fn execute(&mut self, cmd: Command, score: &mut Score) -> Result<(), Error>

Source

pub fn undo(&mut self, score: &mut Score) -> Result<ChangeHint, Error>

Source

pub fn redo(&mut self, score: &mut Score) -> Result<ChangeHint, Error>

Source

pub fn history_commands(&self) -> Vec<Command>

Return the commands applied so far, in execution order. Suitable for use with [ScoreEngine::export_history].

Source

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

Label of the command that would be undone next, for UI display (e.g. “Undo: Add Note”).

Source

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

Label of the command that would be redone next, for UI display (e.g. “Redo: Add Note”).

Source

pub fn undo_key(&self) -> Option<String>

i18n key of the command that would be undone next.

Source

pub fn redo_key(&self) -> Option<String>

i18n key of the command that would be redone next.

Source

pub fn batch_execute( &mut self, cmds: Vec<Command>, score: &mut Score, ) -> Result<(), Error>

Apply a batch of commands as a single undo entry (rollback-safe).

Source

pub fn batch_execute_labeled( &mut self, cmds: Vec<Command>, label: String, score: &mut Score, ) -> Result<(), Error>

Apply a batch with an explicit undo-label, as a single rollback-safe entry.

The label appears as the command_key for undo/redo UI (e.g. "ApplyAI").

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> 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.