diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-11-13 16:33:32 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-11-13 16:33:32 -0500 |
commit | 57ee8da77b3f8a0a265544b9f2cb6fbb247ccc3b (patch) | |
tree | 1193dad97f7d62f9f181dc75f61cbc44fcbcd75a /src/state.rs | |
parent | b7a0201d42995e34df4f541b23826ff7ac42dd9f (diff) | |
download | nbsh-57ee8da77b3f8a0a265544b9f2cb6fbb247ccc3b.tar.gz nbsh-57ee8da77b3f8a0a265544b9f2cb6fbb247ccc3b.zip |
allow moving focus between history entries
Diffstat (limited to 'src/state.rs')
-rw-r--r-- | src/state.rs | 30 |
1 files changed, 30 insertions, 0 deletions
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(); |