From 7434a2b94d18abc0440a995a8cad7e9b037a5b92 Mon Sep 17 00:00:00 2001 From: emilis Date: Sun, 15 Jan 2023 23:18:58 +0000 Subject: [PATCH] fixed up writing to/deleting (but overflows still happen it seems) --- src/display/body.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/display/body.rs b/src/display/body.rs index f1cffe8..35c163a 100644 --- a/src/display/body.rs +++ b/src/display/body.rs @@ -195,6 +195,16 @@ impl SigninPage { ] .into() } + + #[inline] + fn char(&mut self, c: char) { + match self.cursor { + SigninCursorLocation::Hostname => { + self.hostname.push(c); + } + SigninCursorLocation::Ok => {} + } + } } impl Page for SigninPage { @@ -206,10 +216,16 @@ impl Page for SigninPage { ) -> Result<()> { match event { Event::Key(key) => match key { - termion::event::Key::Char(_) => {} + termion::event::Key::Char(c) => self.char(c), termion::event::Key::Up => self.next(), termion::event::Key::Down => self.previous(), - termion::event::Key::Backspace => {} + termion::event::Key::Backspace => { + if let SigninCursorLocation::Hostname = + self.cursor + { + self.hostname.pop(); + } + } termion::event::Key::Delete => {} termion::event::Key::Left => {} termion::event::Key::Right => {}