pub enum UndoBehavior {
    InsertCharacter(char),
    Backspace(Option<char>),
    Delete(Option<char>),
    MoveCursor,
    HistoryNavigation,
    CreateUndoPoint,
    UndoRedo,
}
Expand description

Every line change should come with an UndoBehavior tag, which can be used to calculate how the change should be reflected on the undo stack

Variants§

§

InsertCharacter(char)

Character insertion, tracking the character inserted

§

Backspace(Option<char>)

Backspace command, tracking the deleted character (left of cursor) Warning: this does not track the whole grapheme, just the character

§

Delete(Option<char>)

Delete command, tracking the deleted character (right of cursor) Warning: this does not track the whole grapheme, just the character

§

MoveCursor

Move the cursor position

§

HistoryNavigation

Navigated the history using up or down arrows

§

CreateUndoPoint

Catch-all for actions that should always form a unique undo point and never be grouped with later edits

§

UndoRedo

Undo/Redo actions shouldn’t be reflected on the edit stack

Implementations§

source§

impl UndoBehavior

source

pub fn create_undo_point_after(&self, previous: &UndoBehavior) -> bool

Return if the current operation should start a new undo set, or be combined with the previous operation

Trait Implementations§

source§

impl Debug for UndoBehavior

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.