bhcli

"Strange's fork of n0tr1v's bhcli (onion)"
git clone https://git.dasho.dev/Strange/bhcli.git
Log | Files | Refs | README

commit 0905bb9dea9093cbc87891bcf4619119ce59a61c
parent 7e56e9431e448d7ca8168e41d1a391ca2bf0f53f
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Sun,  2 Apr 2023 07:22:06 -0700

filter <enter> to move to message

Diffstat:
Msrc/main.rs | 16++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -1023,7 +1023,7 @@ impl LeChatPHPClient { KeyEvent { code: KeyCode::Down, modifiers: KeyModifiers::NONE, .. } => self.handle_normal_mode_key_event_down(app), KeyEvent { code: KeyCode::Char('k'), modifiers: KeyModifiers::NONE, .. } | KeyEvent { code: KeyCode::Up, modifiers: KeyModifiers::NONE, .. } => self.handle_normal_mode_key_event_up(app), - KeyEvent { code: KeyCode::Enter, modifiers: KeyModifiers::NONE, .. } => self.handle_normal_mode_key_event_enter(app), + KeyEvent { code: KeyCode::Enter, modifiers: KeyModifiers::NONE, .. } => self.handle_normal_mode_key_event_enter(app, messages), KeyEvent { code: KeyCode::Backspace, modifiers: KeyModifiers::NONE, .. } => self.handle_normal_mode_key_event_backspace(app, messages), KeyEvent { code: KeyCode::Char('y'), modifiers: KeyModifiers::NONE, .. } | KeyEvent { code: KeyCode::Char('c'), modifiers: KeyModifiers::CONTROL, .. } => self.handle_normal_mode_key_event_yank(app), @@ -1113,9 +1113,21 @@ impl LeChatPHPClient { app.input_mode = InputMode::Editing; } - fn handle_normal_mode_key_event_enter(&mut self, app: &mut App) { + fn handle_normal_mode_key_event_enter(&mut self, app: &mut App, messages: &Arc<Mutex<Vec<Message>>>) { if let Some(idx) = app.items.state.selected() { if let Some(item) = app.items.items.get(idx) { + if app.filter != "" { + let idx = messages + .lock().unwrap() + .iter() + .enumerate() + .find(|(_, e)| e.date == item.date) + .map(|(i, _)| i) + .unwrap_or(0); + app.clear_filter(); + app.items.state.select(Some(idx)); + return; + } app.long_message = Some(item.clone()); app.input_mode = InputMode::LongMessage; }