INNER CODE UNIT · Rust
get_action
bgreenwell/doxx · src/keymap/mod.rs:26
pub fn get_action(&self, key: &KeyBinding) -> Option<Action> {
self.bindings.get(key).copied()
}
/// Returns all key strings bound to `action`, sorted: plain chars first, then
/// special keys, then modifier combos.
pub fn keys_for_action(&self, action: Action) -> Vec<String> {
let mut bindings: Vec<&KeyBinding> = self
.bindings
.iter()
.filter(|(_, a)| **a == action)
.map(|(k, _)| k)
.collect();
bindings.sort_by_key(|k| (k.sort_priority(), k.display()));
bindings.iter().map(|k| k.display()).collect()
}
/// Returns the single "best" key string for `action` (first after sorting).