1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use {
    crokey::*,
    crossterm::event::{
        KeyCode,
        KeyModifiers,
    },
    once_cell::sync::Lazy,
};

pub static KEY_FORMAT: Lazy<KeyCombinationFormat> = Lazy::new(|| {
    KeyCombinationFormat::default().with_lowercase_modifiers()
});

pub fn is_reserved(key: KeyCombination) -> bool {
    key == key!(backspace) || key == key!(delete) || key == key!(esc)
}

/// Tell whether the key can only be used as a shortcut key if the
/// modal mode is active.
pub fn is_key_only_modal(
    key: KeyCombination,
) -> bool {
    matches!(key, KeyCombination {
        codes: OneToThree::One(KeyCode::Char(_)),
        modifiers: KeyModifiers::NONE | KeyModifiers::SHIFT,
    })
}