Struct keybindings::ModalMachine
source · 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> !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