INNER CODE UNIT · Rust

bind

bgreenwell/doxx · src/keymap/mod.rs:22

    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
            .bindings
            .iter()
            .filter(|(_, a)| **a == action)
            .map(|(k, _)| k)
            .collect();
        bindings.sort_by_key(|k| (k.sort_priority(), k.display()));

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…