pub struct Keymap { /* private fields */ }Expand description
A component’s bindings, and the keys rebound on it.
Implementations§
Source§impl Keymap
impl Keymap
Sourcepub fn new(context: impl Into<String>) -> Keymap
pub fn new(context: impl Into<String>) -> Keymap
An empty keymap whose bindings are in context.
Sourcepub fn bind(
self,
action: impl Into<String>,
keys: impl IntoIterator<Item = Key>,
description: impl Into<String>,
) -> Keymap
pub fn bind( self, action: impl Into<String>, keys: impl IntoIterator<Item = Key>, description: impl Into<String>, ) -> Keymap
Declare that keys do action, described as description.
Sourcepub fn add(&mut self, binding: Binding)
pub fn add(&mut self, binding: Binding)
Add a binding, in whatever context it has. A binding for an action already declared in that context replaces it.
Sourcepub fn extend(&mut self, other: Keymap)
pub fn extend(&mut self, other: Keymap)
Add every binding of other after this one’s, keeping what other
rebound: how a container lists its focused child’s keys with its
own.
Sourcepub fn rebind(&mut self, action: &str, keys: impl IntoIterator<Item = Key>)
pub fn rebind(&mut self, action: &str, keys: impl IntoIterator<Item = Key>)
Make keys do action (in this keymap’s context) instead of what
was declared or installed. No keys unbinds it.
Sourcepub fn rebound(
self,
action: &str,
keys: impl IntoIterator<Item = Key>,
) -> Keymap
pub fn rebound( self, action: &str, keys: impl IntoIterator<Item = Key>, ) -> Keymap
Builder form of rebind.
Sourcepub fn apply(&mut self, overrides: &Overrides)
pub fn apply(&mut self, overrides: &Overrides)
Apply overrides on this keymap only, over anything installed.
Sourcepub fn lookup(&self, key: Key) -> Option<Binding>
pub fn lookup(&self, key: Key) -> Option<Binding>
The binding key triggers, if any: see action.
Sourcepub fn action(&self, key: Key) -> Option<&str>
pub fn action(&self, key: Key) -> Option<&str>
The action key triggers, if any: a binding whose keys were rebound
(or installed) wins over one with its declared keys, so a key moved
onto an action does it even when an earlier action declared it;
otherwise the first declared.
Sourcepub fn keys(&self, action: &str) -> Vec<Key>
pub fn keys(&self, action: &str) -> Vec<Key>
The keys that trigger action (in any context) now.