From adaeba1a907dfee5f33afe832e9e9a7e9f59b1f2 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sun, 29 Sep 2024 22:46:58 +0200 Subject: implemented search mode (for entries only ATM) --- src/frontend/handler.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/frontend/handler.rs') diff --git a/src/frontend/handler.rs b/src/frontend/handler.rs index 27aa8de..573795c 100644 --- a/src/frontend/handler.rs +++ b/src/frontend/handler.rs @@ -18,7 +18,7 @@ use crate::frontend::app::{App, AppResult}; use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; -use super::app::{CurrentArea, FormerArea}; +use super::app::{CurrentArea, EntryTable, FormerArea}; /// Handles the key events and updates the state of [`App`]. pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { @@ -97,6 +97,11 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { KeyCode::Tab | KeyCode::BackTab => { app.toggle_area(); } + KeyCode::Esc => { + if let Some(FormerArea::SearchArea) = app.former_area { + app.reset_entry_table(); + } + } _ => {} }, // Keycodes for the search area (popup) @@ -105,18 +110,21 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { app.toggle_area(); app.former_area = None; app.search_string.clear(); + app.reset_entry_table(); } KeyCode::Enter => { // TODO: run function for filtering the list app.toggle_area(); - app.former_area = None; + app.former_area = Some(FormerArea::SearchArea); app.search_string.clear(); } KeyCode::Backspace => { app.search_string.pop(); + app.search_entries(); } KeyCode::Char(search_pattern) => { app.search_string.push(search_pattern); + app.search_entries(); } _ => {} }, -- cgit v1.2.3