pub trait KeyBindings: Send {
// Required methods
fn get_current(&self) -> HashMap<KeySequence, KeyAction>;
fn get_untranslated(&self, bytes: &[u8]) -> Option<&KeyAction>;
fn bind(&mut self, seq: KeySequence, action: KeyAction) -> Result<(), Error>;
fn try_unbind(&mut self, seq: KeySequence) -> bool;
fn define_macro(
&mut self,
seq: KeySequence,
target: KeySequence,
) -> Result<(), Error>;
fn get_macros(&self) -> HashMap<KeySequence, KeySequence>;
}Expand description
Encapsulates the shell’s interaction with key bindings for input.
Required Methods§
Sourcefn get_current(&self) -> HashMap<KeySequence, KeyAction>
fn get_current(&self) -> HashMap<KeySequence, KeyAction>
Retrieves current bindings.
Sourcefn get_untranslated(&self, bytes: &[u8]) -> Option<&KeyAction>
fn get_untranslated(&self, bytes: &[u8]) -> Option<&KeyAction>
Tries to find a binding for an untranslated byte sequence.
Sourcefn bind(&mut self, seq: KeySequence, action: KeyAction) -> Result<(), Error>
fn bind(&mut self, seq: KeySequence, action: KeyAction) -> Result<(), Error>
Sets or updates a binding.
§Arguments
seq- The key sequence to bind.action- The action to bind to the sequence.
Sourcefn try_unbind(&mut self, seq: KeySequence) -> bool
fn try_unbind(&mut self, seq: KeySequence) -> bool
Unbinds a key sequence. Returns true if a binding was removed.
§Arguments
seq- The key sequence to unbind.
Sourcefn define_macro(
&mut self,
seq: KeySequence,
target: KeySequence,
) -> Result<(), Error>
fn define_macro( &mut self, seq: KeySequence, target: KeySequence, ) -> Result<(), Error>
Defines a macro that remaps a key sequence to another key sequence.
§Arguments
seq- The key sequence to bind the macro to.target- The sequence that makes up the macro.
Sourcefn get_macros(&self) -> HashMap<KeySequence, KeySequence>
fn get_macros(&self) -> HashMap<KeySequence, KeySequence>
Retrieves all defined macros.