Skip to main content

KeyBindings

Trait KeyBindings 

Source
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§

Source

fn get_current(&self) -> HashMap<KeySequence, KeyAction>

Retrieves current bindings.

Source

fn get_untranslated(&self, bytes: &[u8]) -> Option<&KeyAction>

Tries to find a binding for an untranslated byte sequence.

Source

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.
Source

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.
Source

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.
Source

fn get_macros(&self) -> HashMap<KeySequence, KeySequence>

Retrieves all defined macros.

Implementors§