diff options
| author | lukeflo | 2024-09-29 22:46:58 +0200 |
|---|---|---|
| committer | lukeflo | 2024-09-29 22:46:58 +0200 |
| commit | adaeba1a907dfee5f33afe832e9e9a7e9f59b1f2 (patch) | |
| tree | 1d498156846c99a5201d0e1d83beeec76301a7c8 /src/frontend/handler.rs | |
| parent | 96a5cc63cce9a2a8f505538268a42fef0891f0b5 (diff) | |
| download | bibiman-adaeba1a907dfee5f33afe832e9e9a7e9f59b1f2.tar.gz bibiman-adaeba1a907dfee5f33afe832e9e9a7e9f59b1f2.zip | |
implemented search mode (for entries only ATM)
Diffstat (limited to 'src/frontend/handler.rs')
| -rw-r--r-- | src/frontend/handler.rs | 12 |
1 files changed, 10 insertions, 2 deletions
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(); } _ => {} }, |
