diff --git a/src/usecase/tui/app.rs b/src/usecase/tui/app.rs index a592f3b..8c6df63 100644 --- a/src/usecase/tui/app.rs +++ b/src/usecase/tui/app.rs @@ -14,7 +14,7 @@ use crate::{ }; use anyhow::{anyhow, bail, Result}; use crossterm::{ - event::{DisableMouseCapture, EnableMouseCapture, KeyCode, KeyEvent}, + event::{DisableMouseCapture, EnableMouseCapture, KeyCode, KeyModifiers, KeyEvent}, execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; @@ -72,7 +72,15 @@ impl Model<'_> { _ => match s.current_pane { CurrentPane::Main => match key.code { KeyCode::Down => Some(Message::NextCommand), + KeyCode::Char('n') => match key.modifiers { + KeyModifiers::CONTROL => Some(Message::NextCommand), + _ => None, + } KeyCode::Up => Some(Message::PreviousCommand), + KeyCode::Char('p') => match key.modifiers { + KeyModifiers::CONTROL => Some(Message::PreviousCommand), + _ => None, + } KeyCode::Enter => Some(Message::ExecuteCommand), _ => Some(Message::SearchTextAreaKeyInput(key)), }, @@ -945,7 +953,7 @@ mod test { }, }, Case { - title: "PreviousCommand when there is no commands to select, + title: "PreviousCommand when there is no commands to select, panic should not occur", model: { let mut m = Model { @@ -1011,7 +1019,7 @@ mod test { }, }, Case { - title: "When the last history is selected and NextHistory is received, + title: "When the last history is selected and NextHistory is received, it returns to the beginning.", model: Model { app_state: AppState::SelectCommand(SelectCommandState { @@ -1030,7 +1038,7 @@ mod test { }, }, Case { - title: "When the first history is selected and PreviousHistory is received, + title: "When the first history is selected and PreviousHistory is received, it moves to the last history.", model: Model { app_state: AppState::SelectCommand(SelectCommandState {