Skip to main content

rush_sync_server/commands/history/
keyboard.rs

1use crate::core::prelude::*;
2
3#[derive(Debug, Clone, PartialEq)]
4pub enum HistoryAction {
5    NavigatePrevious,
6    NavigateNext,
7}
8
9pub struct HistoryKeyboardHandler;
10
11impl HistoryKeyboardHandler {
12    pub fn get_history_action(key: &KeyEvent) -> Option<HistoryAction> {
13        match (key.code, key.modifiers) {
14            (KeyCode::Up, crossterm::event::KeyModifiers::NONE) => {
15                Some(HistoryAction::NavigatePrevious)
16            }
17            (KeyCode::Down, crossterm::event::KeyModifiers::NONE) => {
18                Some(HistoryAction::NavigateNext)
19            }
20            _ => None,
21        }
22    }
23}