Debian Codegraph @

src/input/termion.rs

raw symbols SCIP
1 use ratatui::termion::event::{Event, Key};
2
3 use super::Input;
4
5 impl From<&Event> for Input {
6 /// Convert termion [`Event`](https://docs.rs/termion/latest/termion/event/enum.Event.html) to [`Input`].
7 ///
8 /// **Note:** This implementation is only available when the `termion` feature is enabled.
9 fn from(value: &Event) -> Self {
10 match value {
11 Event::Key(key) => match key {
12 Key::Char('j') | Key::Down => Input::Down,
13 Key::Char('k') | Key::Up => Input::Up,
14 Key::Char('h') | Key::Left | Key::Backspace => Input::Left,
15 Key::Char('l') | Key::Right | Key::Char('\n') => Input::Right,
16 Key::Home => Input::Home,
17 Key::End => Input::End,
18 Key::PageUp => Input::PageUp,
19 Key::PageDown => Input::PageDown,
20 Key::Ctrl('h') => Input::ToggleShowHidden,
21 _ => Input::None,
22 },
23 _ => Input::None,
24 }
25 }
26 }