diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-11-12 20:24:15 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-11-12 20:24:15 -0500 |
commit | f28ba66113d0ab2ceecd169e1fb07401074dc056 (patch) | |
tree | fe6bdb123a925b4ebce2b7d4761f813d931802f9 /src/history.rs | |
parent | fe1cf326fbac5fbede750ec20829e01c1c6ca38f (diff) | |
download | nbsh-f28ba66113d0ab2ceecd169e1fb07401074dc056.tar.gz nbsh-f28ba66113d0ab2ceecd169e1fb07401074dc056.zip |
use ^E+r instead of ^Z to return to the repl
we will want to be able to pass ^Z through to running processes as well
- all out of band stuff should go through a single escape character
Diffstat (limited to 'src/history.rs')
-rw-r--r-- | src/history.rs | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/history.rs b/src/history.rs index e06762e..73ace52 100644 --- a/src/history.rs +++ b/src/history.rs @@ -6,6 +6,7 @@ use textmode::Textmode as _; pub struct History { size: (u16, u16), entries: Vec<crate::util::Mutex<HistoryEntry>>, + escape: bool, action: async_std::channel::Sender<crate::action::Action>, } @@ -16,6 +17,7 @@ impl History { Self { size: (24, 80), entries: vec![], + escape: false, action, } } @@ -127,19 +129,34 @@ impl History { key: textmode::Key, idx: usize, ) -> bool { - match key { - textmode::Key::Ctrl(b'z') => { - self.action - .send(crate::action::Action::UpdateFocus( - crate::state::Focus::Readline, - )) - .await - .unwrap(); + if self.escape { + match key { + textmode::Key::Ctrl(b'e') => { + self.send_process_input(idx, &key.into_bytes()) + .await + .unwrap(); + } + textmode::Key::Char('r') => { + self.action + .send(crate::action::Action::UpdateFocus( + crate::state::Focus::Readline, + )) + .await + .unwrap(); + } + _ => {} } - key => { - self.send_process_input(idx, &key.into_bytes()) - .await - .unwrap(); + self.escape = false; + } else { + match key { + textmode::Key::Ctrl(b'e') => { + self.escape = true; + } + key => { + self.send_process_input(idx, &key.into_bytes()) + .await + .unwrap(); + } } } false |