From f9ca661bd55d3298c2639721471bb6912ffb93e0 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 19 Jan 2025 21:09:37 +0100 Subject: [PATCH] fix: Better handling of Escape and Enter keys --- frontends/rioterm/src/router/mod.rs | 23 +++++++++---------- .../rioterm/src/router/routes/assistant.rs | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/frontends/rioterm/src/router/mod.rs b/frontends/rioterm/src/router/mod.rs index d4e6cfe7f5..0b7be9b15c 100644 --- a/frontends/rioterm/src/router/mod.rs +++ b/frontends/rioterm/src/router/mod.rs @@ -101,10 +101,10 @@ impl Route<'_> { #[inline] pub fn report_error(&mut self, error: &RioError) { - if error.report == RioErrorType::ConfigurationNotFound { - self.path = RoutePath::Welcome; - return; - } + // if error.report == RioErrorType::ConfigurationNotFound { + // self.path = RoutePath::Welcome; + // return; + // } self.assistant.set(error.to_owned()); self.path = RoutePath::Assistant; @@ -133,13 +133,13 @@ impl Route<'_> { } let is_enter = key_event.logical_key == Key::Named(NamedKey::Enter); - if self.path == RoutePath::Assistant && is_enter { - if self.assistant.is_warning() { + if self.path == RoutePath::Assistant { + if self.assistant.is_warning() && is_enter { self.assistant.clear(); self.path = RoutePath::Terminal; + } else { + return true; } - - return true; } if self.path == RoutePath::ConfirmQuit { @@ -147,18 +147,17 @@ impl Route<'_> { self.path = RoutePath::Terminal; } else if is_enter { self.quit(); - } - return true; + return true; + } } if self.path == RoutePath::Welcome && is_enter { rio_backend::config::create_config_file(None); self.path = RoutePath::Terminal; - return true; } - true + false } } diff --git a/frontends/rioterm/src/router/routes/assistant.rs b/frontends/rioterm/src/router/routes/assistant.rs index 677fc000e2..b89c7a8ff0 100644 --- a/frontends/rioterm/src/router/routes/assistant.rs +++ b/frontends/rioterm/src/router/routes/assistant.rs @@ -83,7 +83,7 @@ pub fn screen( if report.level == RioErrorLevel::Warning { objects.push(Object::Text(Text::single_line( (70., context_dimension.margin.top_y + 80.), - String::from("(press enter twice to continue)"), + String::from("(press enter to continue)"), 18., [1., 1., 1., 1.], )));