aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/ttyplay/input.rs
blob: a922a5509849b82b8cdc5173759a1942aabc31a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
pub fn to_event(key: &textmode::Key) -> Option<crate::event::Event> {
    Some(match key {
        textmode::Key::Char('g' | '0' | ')') => {
            crate::event::Event::TimerAction(
                crate::event::TimerAction::FirstFrame,
            )
        }
        textmode::Key::Char('G' | '$') => crate::event::Event::TimerAction(
            crate::event::TimerAction::LastFrame,
        ),
        textmode::Key::Char('l' | 'n') => crate::event::Event::TimerAction(
            crate::event::TimerAction::NextFrame,
        ),
        textmode::Key::Char('h' | 'p') => crate::event::Event::TimerAction(
            crate::event::TimerAction::PreviousFrame,
        ),
        textmode::Key::Char('q') => crate::event::Event::Quit,
        textmode::Key::Char(' ') => {
            crate::event::Event::TimerAction(crate::event::TimerAction::Pause)
        }
        textmode::Key::Ctrl(b'i') => crate::event::Event::ToggleUi,
        _ => return None,
    })
}