From 57ee8da77b3f8a0a265544b9f2cb6fbb247ccc3b Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 13 Nov 2021 16:33:32 -0500 Subject: allow moving focus between history entries --- src/state.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/state.rs') diff --git a/src/state.rs b/src/state.rs index 193d1af..b97249e 100644 --- a/src/state.rs +++ b/src/state.rs @@ -73,6 +73,36 @@ impl State { textmode::Key::Ctrl(b'e') => { ret = false; // fall through and handle normally } + textmode::Key::Char('j') => { + let new_focus = match self.focus { + Focus::History(idx) => { + if idx >= self.history.entry_count() - 1 { + Focus::Readline + } else { + Focus::History(idx + 1) + } + } + Focus::Readline => Focus::Readline, + }; + self.focus = new_focus; + self.render().await.unwrap(); + } + textmode::Key::Char('k') => { + let new_focus = match self.focus { + Focus::History(idx) => { + if idx == 0 { + Focus::History(0) + } else { + Focus::History(idx - 1) + } + } + Focus::Readline => { + Focus::History(self.history.entry_count() - 1) + } + }; + self.focus = new_focus; + self.render().await.unwrap(); + } textmode::Key::Char('r') => { self.focus = Focus::Readline; self.render().await.unwrap(); -- cgit v1.2.3-54-g00ecf