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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! Input handling: dispatches keystrokes by current mode.
//!
//! Routes key events to the appropriate handler based on `state.mode`:
//! Navigation → `keymap::navigation`, Search → `keymap::search`,
//! Command → `command_parser::feed` (Phase 3).
use ;
use crateAction;
/// Whether a `Char` key with `modifiers` is a typed character rather than a chord.
///
/// Shift alone is text (capitals). Ctrl or Alt alone is a chord. Ctrl **and**
/// Alt together are text too: that is how Windows reports AltGr, which many
/// layouts need for `\`, `@`, `|` or `~` — on Spanish (Latin America) `\` is
/// AltGr plus the key left of `1`. The console also replays pasted text as one
/// keystroke per character with the modifiers the layout needs, so treating
/// AltGr as a chord dropped every backslash of a pasted Windows path.
///
/// ```
/// use crossterm::event::KeyModifiers;
/// use trail::input::is_text_modifiers;
///
/// assert!(is_text_modifiers(KeyModifiers::SHIFT));
/// assert!(is_text_modifiers(KeyModifiers::CONTROL | KeyModifiers::ALT));
/// assert!(!is_text_modifiers(KeyModifiers::CONTROL));
/// assert!(!is_text_modifiers(KeyModifiers::ALT));
/// ```
use crateAppState;
/// Mutable context shared with the keymap across ticks.
///
/// Holds any state that spans multiple key events (e.g. multi-key sequences)
/// without polluting `AppState` for concerns that are purely input-layer.
///
/// Multi-key sequences such as `gg`, `ya`, `yr`, `yn`, and `dd` are handled
/// through `AppState::pending_nav_key` (which the status bar can render) rather
/// than `InputCtx` fields, so this struct is currently empty. It is kept as a
/// named type so callers do not need updating if input-layer state is added
/// in the future.
/// Dispatches `key` to the appropriate mode handler.
///
/// Returns `Some(Action)` when the key maps to an action, `None` otherwise.
/// The caller is responsible for calling `actions::apply` with the returned
/// action and handling any resulting error.
///
/// Only `KeyEventKind::Press` events produce actions; `Release` and `Repeat`
/// are ignored so crossterm's Windows double-fire doesn't double-process.