From f28ba66113d0ab2ceecd169e1fb07401074dc056 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 12 Nov 2021 20:24:15 -0500 Subject: 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 --- src/history.rs | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'src') 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>, + escape: bool, action: async_std::channel::Sender, } @@ -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 -- cgit v1.2.3-54-g00ecf