blob: 530e244af0a3d0af582e46d089469111f771bf31 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
use std::io;
use ratatui::crossterm::event::{self, Event, KeyCode};
use crate::app::App;
pub fn handle_event(app: &mut App) -> io::Result<bool> {
if let Event::Key(key) = event::read()? {
if !app.showing_search_window {
match key.code {
KeyCode::Char('q') => return Ok(true),
KeyCode::Char('j') => app.list_state.select_next(),
KeyCode::Char('k') => app.list_state.select_previous(),
KeyCode::Char('/') => app.toggle_search_window(),
KeyCode::Char('n') => app.next_search(),
KeyCode::Char('N') => app.prev_search(),
_ => return Ok(false),
}
} else {
match key.code {
KeyCode::Esc => app.toggle_search_window(),
KeyCode::Enter => {
app.search();
app.toggle_search_window();
()
}
_ => {
app.textarea.input_without_shortcuts(key);
app.search_found = Some(app.search());
()
}
}
}
}
Ok(false)
}
|