rpi-tui 0.1.5

Terminal User Interface for pi-rust
Documentation
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
//! Keybinding system for TUI.
//!
//! Provides configurable keyboard shortcuts for TUI actions.
//! This is a 1:1 port of the TypeScript keybindings.ts

use std::collections::HashMap;

use crossterm::event::{KeyCode, KeyModifiers};

/// A keybinding identifier.
pub type KeybindingId = &'static str;

/// A key combination.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct KeyCombo {
    pub code: KeyCode,
    pub modifiers: KeyModifiers,
}

impl KeyCombo {
    /// Create a new key combination.
    pub fn new(code: KeyCode, modifiers: KeyModifiers) -> Self {
        Self { code, modifiers }
    }

    /// Create from just a key code (no modifiers).
    pub fn from_code(code: KeyCode) -> Self {
        Self {
            code,
            modifiers: KeyModifiers::NONE,
        }
    }

    /// Add Ctrl modifier.
    pub fn ctrl(self) -> Self {
        Self {
            modifiers: self.modifiers | KeyModifiers::CONTROL,
            ..self
        }
    }

    /// Add Shift modifier.
    pub fn shift(self) -> Self {
        Self {
            modifiers: self.modifiers | KeyModifiers::SHIFT,
            ..self
        }
    }

    /// Add Alt modifier.
    pub fn alt(self) -> Self {
        Self {
            modifiers: self.modifiers | KeyModifiers::ALT,
            ..self
        }
    }

    /// Add Super modifier.
    pub fn super_key(self) -> Self {
        Self {
            modifiers: self.modifiers | KeyModifiers::SUPER,
            ..self
        }
    }
}

/// Keybinding definition.
#[derive(Debug, Clone)]
pub struct KeybindingDefinition {
    pub default_keys: Vec<KeyCombo>,
    pub description: Option<&'static str>,
}

/// Keybinding conflict.
#[derive(Debug, Clone)]
pub struct KeybindingConflict {
    pub key: KeyCombo,
    pub keybindings: Vec<KeybindingId>,
}

/// Keybindings manager.
pub struct Keybindings {
    definitions: HashMap<KeybindingId, KeybindingDefinition>,
    user_bindings: HashMap<KeybindingId, Vec<KeyCombo>>,
    keys_by_id: HashMap<KeybindingId, Vec<KeyCombo>>,
    conflicts: Vec<KeybindingConflict>,
}

impl Keybindings {
    /// Create a new keybindings manager with default bindings.
    pub fn new() -> Self {
        let definitions = Self::default_definitions();
        let keys_by_id = definitions
            .iter()
            .map(|(id, def)| (*id, def.default_keys.clone()))
            .collect();
        Self {
            definitions,
            user_bindings: HashMap::new(),
            keys_by_id,
            conflicts: Vec::new(),
        }
    }

    /// Get default keybinding definitions.
    fn default_definitions() -> HashMap<KeybindingId, KeybindingDefinition> {
        use KeyCode::*;
        use KeyModifiers as M;

        let mut map = HashMap::new();

        // Editor navigation and editing
        map.insert(
            "tui.editor.cursorUp",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Up, M::NONE)],
                description: Some("Move cursor up"),
            },
        );
        map.insert(
            "tui.editor.cursorDown",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Down, M::NONE)],
                description: Some("Move cursor down"),
            },
        );
        map.insert(
            "tui.editor.historyPrevious",
            KeybindingDefinition {
                default_keys: vec![],
                description: Some("Select previous prompt history entry"),
            },
        );
        map.insert(
            "tui.editor.historyNext",
            KeybindingDefinition {
                default_keys: vec![],
                description: Some("Select next prompt history entry"),
            },
        );
        map.insert(
            "tui.editor.cursorLeft",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Left, M::NONE),
                    KeyCombo::new(Char('b'), M::CONTROL),
                ],
                description: Some("Move cursor left"),
            },
        );
        map.insert(
            "tui.editor.cursorRight",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Right, M::NONE),
                    KeyCombo::new(Char('f'), M::CONTROL),
                ],
                description: Some("Move cursor right"),
            },
        );
        map.insert(
            "tui.editor.cursorWordLeft",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Left, M::ALT),
                    KeyCombo::new(Left, M::CONTROL),
                    KeyCombo::new(Char('b'), M::ALT),
                ],
                description: Some("Move cursor word left"),
            },
        );
        map.insert(
            "tui.editor.cursorWordRight",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Right, M::ALT),
                    KeyCombo::new(Right, M::CONTROL),
                    KeyCombo::new(Char('f'), M::ALT),
                ],
                description: Some("Move cursor word right"),
            },
        );
        map.insert(
            "tui.editor.cursorLineStart",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Home, M::NONE),
                    KeyCombo::new(Home, M::CONTROL),
                    KeyCombo::new(Char('a'), M::CONTROL),
                ],
                description: Some("Move to line start"),
            },
        );
        map.insert(
            "tui.editor.cursorLineEnd",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(End, M::NONE),
                    KeyCombo::new(End, M::CONTROL),
                    KeyCombo::new(Char('e'), M::CONTROL),
                ],
                description: Some("Move to line end"),
            },
        );
        map.insert(
            "tui.editor.jumpForward",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Char(']'), M::CONTROL)],
                description: Some("Jump forward to character"),
            },
        );
        map.insert(
            "tui.editor.jumpBackward",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Char(']'), M::CONTROL | M::ALT)],
                description: Some("Jump backward to character"),
            },
        );
        map.insert(
            "tui.editor.pageUp",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(PageUp, M::NONE),
                    KeyCombo::new(PageUp, M::CONTROL),
                ],
                description: Some("Page up"),
            },
        );
        map.insert(
            "tui.editor.pageDown",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(PageDown, M::NONE),
                    KeyCombo::new(PageDown, M::CONTROL),
                ],
                description: Some("Page down"),
            },
        );
        map.insert(
            "tui.editor.deleteCharBackward",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Backspace, M::NONE)],
                description: Some("Delete character backward"),
            },
        );
        map.insert(
            "tui.editor.deleteCharForward",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Delete, M::NONE),
                    KeyCombo::new(Char('d'), M::CONTROL),
                ],
                description: Some("Delete character forward"),
            },
        );
        map.insert(
            "tui.editor.deleteWordBackward",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Char('w'), M::CONTROL),
                    KeyCombo::new(Backspace, M::ALT),
                ],
                description: Some("Delete word backward"),
            },
        );
        map.insert(
            "tui.editor.deleteWordForward",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Char('d'), M::ALT),
                    KeyCombo::new(Delete, M::ALT),
                ],
                description: Some("Delete word forward"),
            },
        );
        map.insert(
            "tui.editor.deleteToLineStart",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Char('u'), M::CONTROL)],
                description: Some("Delete to line start"),
            },
        );
        map.insert(
            "tui.editor.deleteToLineEnd",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Char('k'), M::CONTROL)],
                description: Some("Delete to line end"),
            },
        );
        map.insert(
            "tui.editor.yank",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Char('y'), M::CONTROL)],
                description: Some("Yank"),
            },
        );
        map.insert(
            "tui.editor.yankPop",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Char('y'), M::ALT)],
                description: Some("Yank pop"),
            },
        );
        map.insert(
            "tui.editor.undo",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Char('-'), M::CONTROL)],
                description: Some("Undo"),
            },
        );

        // Generic input actions
        map.insert(
            "tui.input.newLine",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Enter, M::SHIFT),
                    KeyCombo::new(Char('j'), M::CONTROL),
                ],
                description: Some("Insert newline"),
            },
        );
        map.insert(
            "tui.input.submit",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Enter, M::NONE)],
                description: Some("Submit input"),
            },
        );
        map.insert(
            "tui.input.tab",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Tab, M::NONE)],
                description: Some("Tab / autocomplete"),
            },
        );
        map.insert(
            "tui.input.copy",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Char('c'), M::CONTROL)],
                description: Some("Copy selection"),
            },
        );

        // Generic selection actions
        map.insert(
            "tui.select.up",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Up, M::NONE)],
                description: Some("Move selection up"),
            },
        );
        map.insert(
            "tui.select.down",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Down, M::NONE)],
                description: Some("Move selection down"),
            },
        );
        map.insert(
            "tui.select.pageUp",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(PageUp, M::NONE)],
                description: Some("Selection page up"),
            },
        );
        map.insert(
            "tui.select.pageDown",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(PageDown, M::NONE)],
                description: Some("Selection page down"),
            },
        );
        map.insert(
            "tui.select.confirm",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Enter, M::NONE)],
                description: Some("Confirm selection"),
            },
        );
        map.insert(
            "tui.select.cancel",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Esc, M::NONE),
                    KeyCombo::new(Char('c'), M::CONTROL),
                ],
                description: Some("Cancel selection"),
            },
        );

        // Alternate-screen viewport navigation
        map.insert(
            "tui.altScreen.pageUp",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(PageUp, M::NONE)],
                description: Some("Scroll viewport up one page"),
            },
        );
        map.insert(
            "tui.altScreen.pageDown",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(PageDown, M::NONE)],
                description: Some("Scroll viewport down one page"),
            },
        );
        map.insert(
            "tui.altScreen.halfPageUp",
            KeybindingDefinition {
                default_keys: vec![],
                description: Some("Scroll viewport up half a page"),
            },
        );
        map.insert(
            "tui.altScreen.halfPageDown",
            KeybindingDefinition {
                default_keys: vec![],
                description: Some("Scroll viewport down half a page"),
            },
        );
        map.insert(
            "tui.altScreen.lineUp",
            KeybindingDefinition {
                default_keys: vec![],
                description: Some("Scroll viewport up one line"),
            },
        );
        map.insert(
            "tui.altScreen.lineDown",
            KeybindingDefinition {
                default_keys: vec![],
                description: Some("Scroll viewport down one line"),
            },
        );
        map.insert(
            "tui.altScreen.previousPrompt",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Up, M::CONTROL | M::SHIFT)],
                description: Some("Jump to previous semantic prompt"),
            },
        );
        map.insert(
            "tui.altScreen.nextPrompt",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Down, M::CONTROL | M::SHIFT)],
                description: Some("Jump to next semantic prompt"),
            },
        );
        map.insert(
            "tui.altScreen.search",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Char('f'), M::CONTROL | M::SHIFT)],
                description: Some("Search the primary scroll view"),
            },
        );
        map.insert(
            "tui.altScreen.searchNext",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Enter, M::NONE),
                    KeyCombo::new(Char('g'), M::CONTROL),
                ],
                description: Some("Select the next search match"),
            },
        );
        map.insert(
            "tui.altScreen.searchPrevious",
            KeybindingDefinition {
                default_keys: vec![
                    KeyCombo::new(Enter, M::SHIFT),
                    KeyCombo::new(Char('g'), M::CONTROL | M::SHIFT),
                ],
                description: Some("Select the previous search match"),
            },
        );
        map.insert(
            "tui.altScreen.searchClose",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Esc, M::NONE)],
                description: Some("Close transcript search"),
            },
        );
        map.insert(
            "tui.altScreen.top",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(Home, M::NONE)],
                description: Some("Scroll viewport to top"),
            },
        );
        map.insert(
            "tui.altScreen.bottom",
            KeybindingDefinition {
                default_keys: vec![KeyCombo::new(End, M::NONE)],
                description: Some("Scroll viewport to bottom"),
            },
        );

        map
    }

    /// Check if a key event matches a keybinding.
    pub fn matches(&self, event: &crossterm::event::KeyEvent, binding_id: KeybindingId) -> bool {
        if let Some(combos) = self.keys_by_id.get(binding_id) {
            let combo = KeyCombo::new(event.code, event.modifiers);
            return combos.contains(&combo);
        }
        false
    }

    /// Get the keybinding ID for a key event.
    pub fn get_binding(&self, event: &crossterm::event::KeyEvent) -> Option<KeybindingId> {
        let combo = KeyCombo::new(event.code, event.modifiers);
        for (id, combos) in &self.keys_by_id {
            if combos.contains(&combo) {
                return Some(*id);
            }
        }
        None
    }

    /// Get keys for a keybinding.
    pub fn get_keys(&self, binding_id: KeybindingId) -> Vec<KeyCombo> {
        self.keys_by_id.get(binding_id).cloned().unwrap_or_default()
    }

    /// Get definition for a keybinding.
    pub fn get_definition(&self, binding_id: KeybindingId) -> Option<&KeybindingDefinition> {
        self.definitions.get(binding_id)
    }

    /// Get conflicts.
    pub fn get_conflicts(&self) -> &[KeybindingConflict] {
        &self.conflicts
    }

    /// Set user bindings.
    pub fn set_user_bindings(&mut self, user_bindings: HashMap<KeybindingId, Vec<KeyCombo>>) {
        self.user_bindings = user_bindings;
        self.rebuild();
    }

    /// Rebuild the keybindings after user bindings change.
    fn rebuild(&mut self) {
        self.keys_by_id.clear();
        self.conflicts.clear();

        // Track which keys are claimed by which keybindings
        let mut key_claims: HashMap<KeyCombo, Vec<KeybindingId>> = HashMap::new();

        for (id, def) in &self.definitions {
            let keys = if let Some(user_keys) = self.user_bindings.get(id) {
                user_keys.clone()
            } else {
                def.default_keys.clone()
            };

            // Track claims
            for key in &keys {
                key_claims.entry(*key).or_default().push(*id);
            }

            self.keys_by_id.insert(*id, keys);
        }

        // Find conflicts
        for (key, claimants) in key_claims {
            if claimants.len() > 1 {
                self.conflicts.push(KeybindingConflict {
                    key,
                    keybindings: claimants,
                });
            }
        }
    }

    /// Set a single keybinding.
    pub fn set(&mut self, binding_id: KeybindingId, combos: Vec<KeyCombo>) {
        self.user_bindings.insert(binding_id, combos);
        self.rebuild();
    }
}

impl Default for Keybindings {
    fn default() -> Self {
        Self::new()
    }
}

/// Global keybindings manager.
static GLOBAL_KEYBINDINGS: std::sync::OnceLock<std::sync::Mutex<Keybindings>> =
    std::sync::OnceLock::new();

/// Set global keybindings.
pub fn set_keybindings(keybindings: Keybindings) {
    if let Some(guard) = GLOBAL_KEYBINDINGS.get() {
        if let Ok(mut kb) = guard.lock() {
            *kb = keybindings;
        }
    }
}

/// Get global keybindings.
pub fn get_keybindings() -> std::sync::MutexGuard<'static, Keybindings> {
    let guard = GLOBAL_KEYBINDINGS.get_or_init(|| std::sync::Mutex::new(Keybindings::new()));
    guard.lock().expect("Failed to lock global keybindings")
}

/// Predefined keybinding IDs.
pub mod keys {
    use super::KeybindingId;

    // Editor
    pub const CURSOR_UP: KeybindingId = "tui.editor.cursorUp";
    pub const CURSOR_DOWN: KeybindingId = "tui.editor.cursorDown";
    pub const CURSOR_LEFT: KeybindingId = "tui.editor.cursorLeft";
    pub const CURSOR_RIGHT: KeybindingId = "tui.editor.cursorRight";
    pub const CURSOR_WORD_LEFT: KeybindingId = "tui.editor.cursorWordLeft";
    pub const CURSOR_WORD_RIGHT: KeybindingId = "tui.editor.cursorWordRight";
    pub const CURSOR_LINE_START: KeybindingId = "tui.editor.cursorLineStart";
    pub const CURSOR_LINE_END: KeybindingId = "tui.editor.cursorLineEnd";
    pub const DELETE_CHAR_BACKWARD: KeybindingId = "tui.editor.deleteCharBackward";
    pub const DELETE_CHAR_FORWARD: KeybindingId = "tui.editor.deleteCharForward";
    pub const DELETE_WORD_BACKWARD: KeybindingId = "tui.editor.deleteWordBackward";
    pub const DELETE_WORD_FORWARD: KeybindingId = "tui.editor.deleteWordForward";
    pub const DELETE_TO_LINE_START: KeybindingId = "tui.editor.deleteToLineStart";
    pub const DELETE_TO_LINE_END: KeybindingId = "tui.editor.deleteToLineEnd";
    pub const YANK: KeybindingId = "tui.editor.yank";
    pub const YANK_POP: KeybindingId = "tui.editor.yankPop";
    pub const UNDO: KeybindingId = "tui.editor.undo";

    // Input
    pub const INPUT_SUBMIT: KeybindingId = "tui.input.submit";
    pub const INPUT_NEW_LINE: KeybindingId = "tui.input.newLine";
    pub const INPUT_TAB: KeybindingId = "tui.input.tab";
    pub const INPUT_COPY: KeybindingId = "tui.input.copy";

    // Select
    pub const SELECT_UP: KeybindingId = "tui.select.up";
    pub const SELECT_DOWN: KeybindingId = "tui.select.down";
    pub const SELECT_PAGE_UP: KeybindingId = "tui.select.pageUp";
    pub const SELECT_PAGE_DOWN: KeybindingId = "tui.select.pageDown";
    pub const SELECT_CONFIRM: KeybindingId = "tui.select.confirm";
    pub const SELECT_CANCEL: KeybindingId = "tui.select.cancel";

    // Alt screen
    pub const PAGE_UP: KeybindingId = "tui.altScreen.pageUp";
    pub const PAGE_DOWN: KeybindingId = "tui.altScreen.pageDown";
    pub const HALF_PAGE_UP: KeybindingId = "tui.altScreen.halfPageUp";
    pub const HALF_PAGE_DOWN: KeybindingId = "tui.altScreen.halfPageDown";
    pub const LINE_UP: KeybindingId = "tui.altScreen.lineUp";
    pub const LINE_DOWN: KeybindingId = "tui.altScreen.lineDown";
    pub const TOP: KeybindingId = "tui.altScreen.top";
    pub const BOTTOM: KeybindingId = "tui.altScreen.bottom";
    pub const SEARCH: KeybindingId = "tui.altScreen.search";
    pub const SEARCH_NEXT: KeybindingId = "tui.altScreen.searchNext";
    pub const SEARCH_PREVIOUS: KeybindingId = "tui.altScreen.searchPrevious";
    pub const SEARCH_CLOSE: KeybindingId = "tui.altScreen.searchClose";
    pub const PREVIOUS_PROMPT: KeybindingId = "tui.altScreen.previousPrompt";
    pub const NEXT_PROMPT: KeybindingId = "tui.altScreen.nextPrompt";
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_keybindings_new() {
        let kb = Keybindings::new();
        assert!(kb.definitions.len() > 0);
    }

    #[test]
    fn test_matches() {
        let kb = Keybindings::new();
        let event = crossterm::event::KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE);
        assert!(kb.matches(&event, keys::INPUT_SUBMIT));
    }

    #[test]
    fn test_get_keys() {
        let kb = Keybindings::new();
        let keys = kb.get_keys(keys::CURSOR_LEFT);
        assert!(!keys.is_empty());
    }
}