INNER CODE UNIT · Rust
from_preset
bgreenwell/doxx · src/keymap/mod.rs:16
pub fn from_preset(preset: KeymapPreset) -> Self {
Self {
bindings: presets::create_keymap(preset),
}
}
pub fn bind(&mut self, key: KeyBinding, action: Action) {
self.bindings.insert(key, action);
}
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