fn insert_binding()

in crates/figterm/src/interceptor.rs [146:187]


    fn insert_binding(&mut self, binding: KeyEvent, identifier: String) {
        if let Some(key) = match binding.key {
            KeyCode::UpArrow => Some(KeyCode::ApplicationUpArrow),
            KeyCode::DownArrow => Some(KeyCode::ApplicationDownArrow),
            KeyCode::LeftArrow => Some(KeyCode::ApplicationLeftArrow),
            KeyCode::RightArrow => Some(KeyCode::ApplicationRightArrow),
            _ => None,
        } {
            self.mappings.insert(
                KeyEvent {
                    key,
                    modifiers: binding.modifiers,
                },
                identifier.clone(),
            );
        };

        if let KeyCode::Char(key) = binding.key {
            // Fill in other case if there is a ctrl or alt, i.e. ctrl+r is the same as ctrl+R
            //
            // This will prevent ctrl+shift+r from being the same as ctrl+r but that is probably
            // fine since we lose context due to parsing ambiguity in the original xterm spec
            // when other modifiers are present
            if (binding.modifiers.contains(Modifiers::CTRL) || binding.modifiers.contains(Modifiers::ALT))
                && key.is_ascii_alphabetic()
            {
                self.mappings.insert(
                    KeyEvent {
                        key: KeyCode::Char(if key.is_ascii_uppercase() {
                            key.to_ascii_lowercase()
                        } else {
                            key.to_ascii_uppercase()
                        }),
                        modifiers: binding.modifiers,
                    },
                    identifier.clone(),
                );
            }
        }

        self.mappings.insert(binding, identifier);
    }