pub struct Keybindings<C: BindingContext> { /* private fields */ }Expand description
Keybindings configuration with context support
Generic over the context type C which must implement BindingContext.
Implementations§
Source§impl<C: BindingContext> Keybindings<C>
impl<C: BindingContext> Keybindings<C>
Sourcepub fn add_global(&mut self, command: impl Into<String>, keys: Vec<String>)
pub fn add_global(&mut self, command: impl Into<String>, keys: Vec<String>)
Add a global keybinding
Sourcepub fn add(&mut self, context: C, command: impl Into<String>, keys: Vec<String>)
pub fn add(&mut self, context: C, command: impl Into<String>, keys: Vec<String>)
Add a context-specific keybinding
Sourcepub fn get_context_bindings(
&self,
context: C,
) -> Option<&HashMap<String, Vec<String>>>
pub fn get_context_bindings( &self, context: C, ) -> Option<&HashMap<String, Vec<String>>>
Get bindings for a specific context
Sourcepub fn get_command(&self, key: KeyEvent, context: C) -> Option<String>
pub fn get_command(&self, key: KeyEvent, context: C) -> Option<String>
Get command name for a key event in the given context
First checks context-specific bindings, then falls back to global
Sourcepub fn get_command_ref(&self, key: &KeyEvent, context: C) -> Option<&str>
pub fn get_command_ref(&self, key: &KeyEvent, context: C) -> Option<&str>
Get command name for a key event by reference
Returns a borrowed &str to avoid allocations on hot paths.
Sourcepub fn get_first_keybinding(&self, command: &str, context: C) -> Option<String>
pub fn get_first_keybinding(&self, command: &str, context: C) -> Option<String>
Get the first keybinding string for a command in the given context
First checks context-specific bindings, then falls back to global
Trait Implementations§
Source§impl<C: BindingContext> Clone for Keybindings<C>
impl<C: BindingContext> Clone for Keybindings<C>
Source§impl<C: Debug + BindingContext> Debug for Keybindings<C>
impl<C: Debug + BindingContext> Debug for Keybindings<C>
Source§impl<C: BindingContext> Default for Keybindings<C>
impl<C: BindingContext> Default for Keybindings<C>
Auto Trait Implementations§
impl<C> !Freeze for Keybindings<C>
impl<C> RefUnwindSafe for Keybindings<C>where
C: UnwindSafe + RefUnwindSafe,
impl<C> Send for Keybindings<C>where
C: Send,
impl<C> Sync for Keybindings<C>
impl<C> Unpin for Keybindings<C>where
C: Unpin,
impl<C> UnsafeUnpin for Keybindings<C>
impl<C> UnwindSafe for Keybindings<C>where
C: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more