use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use crate::tui::app::{App, ExitAction};
pub fn handle_search_mode(
app: &mut App,
key: KeyEvent,
) {
match key.code {
KeyCode::Esc => app.exit_search_keep_query(),
KeyCode::Char('N') => app.cycle_panel(),
KeyCode::Char('P') => app.cycle_panel_backward(),
KeyCode::Char('L') => app.cycle_filter(),
KeyCode::Char('H') => app.cycle_filter_backward(),
KeyCode::Char('j') if key.modifiers.contains(KeyModifiers::CONTROL) => app.scroll_down(1),
KeyCode::Char('k') if key.modifiers.contains(KeyModifiers::CONTROL) => app.scroll_up(1),
KeyCode::Char(c) => app.search_insert_char(c),
KeyCode::Backspace => app.search_delete_char(),
KeyCode::Left => app.search_cursor_left(),
KeyCode::Right => app.search_cursor_right(),
KeyCode::Enter => app.select_entry(ExitAction::Execute),
KeyCode::Tab => app.select_entry(ExitAction::Populate),
_ => {},
}
}