Skip to content

Commit

Permalink
fix: Better handling of Escape and Enter keys
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Jan 19, 2025
1 parent 66257aa commit f9ca661
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions frontends/rioterm/src/router/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -133,32 +133,31 @@ 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 {
if key_event.logical_key == Key::Named(NamedKey::Escape) {
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
}
}

Expand Down
2 changes: 1 addition & 1 deletion frontends/rioterm/src/router/routes/assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.],
)));
Expand Down

0 comments on commit f9ca661

Please sign in to comment.