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>
impl<Key, S> ModalMachine<Key, S>
Sourcepub fn from_bindings<B: InputBindings<Key, S> + Default>() -> Self
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>
impl<Key, S> ModalMachine<Key, S>
Sourcepub fn from_state(state: S::State) -> Self
pub fn from_state(state: S::State) -> Self
Return a new instance using an already initialized state.
Sourcepub fn add_prefix(
&mut self,
mode: S::M,
evs: &EdgePath<Key, S::Class>,
action: &Option<S>,
)
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.
Sourcepub fn add_mapping(
&mut self,
mode: S::M,
evs: &EdgePath<Key, S::Class>,
action: &S,
)
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.
Sourcepub fn execute(&mut self, input: Vec<Key>) -> InputIterator<'_, Key, S> ⓘ
pub fn execute(&mut self, input: Vec<Key>) -> InputIterator<'_, Key, S> ⓘ
Process multiple input keys.
Sourcepub fn execute_macro(
&mut self,
mstr: &str,
count: usize,
) -> Result<InputIterator<'_, Key, S>, Key::Error>
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.
Sourcepub fn mode(&self) -> S::M
pub fn mode(&self) -> S::M
Returns the mode we’ve most recently entered.
Modes reached via Fallthrough will not change what this returns.
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>
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>
Source§fn pop(&mut self) -> Option<(S::A, <S::State as InputState>::Output)>
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
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>>
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>
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>
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>,
)
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
Auto Trait Implementations§
impl<Key, S> Freeze for ModalMachine<Key, S>
impl<Key, S> !RefUnwindSafe for ModalMachine<Key, S>
impl<Key, S> Send for ModalMachine<Key, S>
impl<Key, S> !Sync for ModalMachine<Key, S>
impl<Key, S> Unpin for ModalMachine<Key, S>
impl<Key, S> !UnwindSafe for ModalMachine<Key, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more