diff options
| author | lukeflo | 2024-09-28 23:11:15 +0200 |
|---|---|---|
| committer | lukeflo | 2024-09-28 23:11:15 +0200 |
| commit | 96a5cc63cce9a2a8f505538268a42fef0891f0b5 (patch) | |
| tree | 78660837e8c9ba9a2644dd955b7ed03e046fb699 /src/frontend/handler.rs | |
| parent | a13f63f34272889239d1e0fcd37f9c4fb5ec983a (diff) | |
| download | bibiman-96a5cc63cce9a2a8f505538268a42fef0891f0b5.tar.gz bibiman-96a5cc63cce9a2a8f505538268a42fef0891f0b5.zip | |
start impl of search mode
Diffstat (limited to 'src/frontend/handler.rs')
| -rw-r--r-- | src/frontend/handler.rs | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/frontend/handler.rs b/src/frontend/handler.rs index 73f30ae..27aa8de 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; +use super::app::{CurrentArea, FormerArea}; /// Handles the key events and updates the state of [`App`]. pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { @@ -61,6 +61,10 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { KeyCode::Char('G') | KeyCode::End => { app.select_last(); } + KeyCode::Char('/') => { + app.former_area = Some(FormerArea::TagArea); + app.current_area = CurrentArea::SearchArea; + } KeyCode::Tab | KeyCode::BackTab => { app.toggle_area(); } @@ -86,11 +90,47 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { KeyCode::Char('y') => { App::yank_text(&app.get_selected_citekey()); } + KeyCode::Char('/') => { + app.former_area = Some(FormerArea::EntryArea); + app.current_area = CurrentArea::SearchArea; + } KeyCode::Tab | KeyCode::BackTab => { app.toggle_area(); } _ => {} }, + // Keycodes for the search area (popup) + CurrentArea::SearchArea => match key_event.code { + KeyCode::Esc => { + app.toggle_area(); + app.former_area = None; + app.search_string.clear(); + } + KeyCode::Enter => { + // TODO: run function for filtering the list + app.toggle_area(); + app.former_area = None; + app.search_string.clear(); + } + KeyCode::Backspace => { + app.search_string.pop(); + } + KeyCode::Char(search_pattern) => { + app.search_string.push(search_pattern); + } + _ => {} + }, + // Keycodes for the help area (popup) + CurrentArea::HelpArea => match key_event.code { + KeyCode::Char('q') => { + app.quit(); + } + KeyCode::Esc => { + app.toggle_area(); + app.former_area = None; + } + _ => {} + }, } Ok(()) } |
