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_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: Clone + BindingContext> Clone for Keybindings<C>
impl<C: Clone + BindingContext> Clone for Keybindings<C>
Source§fn clone(&self) -> Keybindings<C>
fn clone(&self) -> Keybindings<C>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§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>
Source§impl<'de, C: BindingContext> Deserialize<'de> for Keybindings<C>
impl<'de, C: BindingContext> Deserialize<'de> for Keybindings<C>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<C: BindingContext> Serialize for Keybindings<C>
impl<C: BindingContext> Serialize for Keybindings<C>
Auto Trait Implementations§
impl<C> Freeze for Keybindings<C>
impl<C> RefUnwindSafe for Keybindings<C>where
C: RefUnwindSafe,
impl<C> Send for Keybindings<C>where
C: Send,
impl<C> Sync for Keybindings<C>where
C: Sync,
impl<C> Unpin for Keybindings<C>where
C: Unpin,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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