pub struct ModalMachine<Key: InputKey, S: Step<Key>> { /* private fields */ }
Expand description

Manage and process modal keybindings.

Implementations§

source§

impl<Key, S> ModalMachine<Key, S>
where Key: InputKey, S: Step<Key>, S::State: Default,

source

pub fn empty() -> Self

Return a new instance without any bindings.

source

pub fn from_bindings<B: InputBindings<Key, S> + Default>() -> Self

Return an instance that contains default bindings provided by B.

source§

impl<Key, S> ModalMachine<Key, S>
where Key: InputKey, S: Step<Key>,

source

pub fn from_state(state: S::State) -> Self

Return a new instance using an already initialized state.

source

pub fn add_prefix( &mut self, mode: S::M, evs: &EdgePath<Key, S::Class>, action: &Option<S> )

Prefix a mode with the key sequence described by EdgePath.

source

pub fn add_mapping( &mut self, mode: S::M, evs: &EdgePath<Key, S::Class>, action: &S )

Map a sequence of keys to an action in the given mode.

source

pub fn execute(&mut self, input: Vec<Key>) -> InputIterator<'_, Key, S>

Process multiple input keys.

source

pub fn execute_macro( &mut self, mstr: &str, count: usize ) -> Result<InputIterator<'_, Key, S>, Key::Error>

Interpret the given string as a macro, and process the keys it represents a given number of times.

source

pub fn mode(&self) -> S::M

Returns the mode we’ve most recently entered.

Modes reached via Fallthrough will not change what this returns.

source

pub fn state(&mut self) -> &mut S::State

Get a mutable reference to the keybinding state.

Trait Implementations§

source§

impl<Key, S> BindingMachine<Key, <S as Step<Key>>::A, <S as Step<Key>>::Sequence, <<S as Step<Key>>::State as InputState>::Output> for ModalMachine<Key, S>
where Key: InputKey, S: Step<Key>,

source§

fn input_key(&mut self, input: Key)

Process a typed key.
source§

fn pop(&mut self) -> Option<(S::A, <S::State as InputState>::Output)>

Fetch the next action produced by previously typed keys.
source§

fn context(&mut self) -> <S::State as InputState>::Output

Get current output context after the most recent keypress.
source§

fn show_dialog(&mut self, max_rows: usize, max_cols: usize) -> Vec<Cow<'_, str>>

Returns the message to display for the current interactive dialog, if there is one. Read more
source§

fn show_mode(&self) -> Option<String>

Returns a user-friendly string to display for the current mode.
source§

fn get_cursor_indicator(&self) -> Option<char>

Returns a character to show for the cursor.
source§

fn repeat( &mut self, seq: S::Sequence, ctx: Option<<S::State as InputState>::Output> )

Repeat a recent sequence of tracked actions, and optionally override their original contexts using InputState::merge. The repeated sequence will be inserted at the beginning of the action queue, before any other pending actions. Read more
source§

fn run_dialog(&mut self, dialog: Box<dyn Dialog<S::A>>)

Start an interactive user dialog.

Auto Trait Implementations§

§

impl<Key, S> !RefUnwindSafe for ModalMachine<Key, S>

§

impl<Key, S> Send for ModalMachine<Key, S>
where Key: Send, S: Sync + Send, <S as Step<Key>>::A: Send, <S as Step<Key>>::Class: Send, <S as Step<Key>>::M: Send, <<S as Step<Key>>::State as InputState>::Output: Send, <S as Step<Key>>::Sequence: Send, <S as Step<Key>>::State: Send,

§

impl<Key, S> !Sync for ModalMachine<Key, S>

§

impl<Key, S> Unpin for ModalMachine<Key, S>
where Key: Unpin, <S as Step<Key>>::A: Unpin, <S as Step<Key>>::Class: Unpin, <S as Step<Key>>::M: Unpin, <<S as Step<Key>>::State as InputState>::Output: Unpin, <S as Step<Key>>::Sequence: Unpin, <S as Step<Key>>::State: Unpin,

§

impl<Key, S> !UnwindSafe for ModalMachine<Key, S>

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

§

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

§

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.