From ee9be05579d87ca99f153d20995af3273385b564 Mon Sep 17 00:00:00 2001 From: nc Date: Wed, 5 Aug 2020 22:08:51 -0400 Subject: Override Ctrl-C by disabling callback in Cursive Thanks to @gyscos for the explanation in #22! Also removed extraneous code that's no longer needed. --- src/main.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index d733f97..3ec964a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,13 +50,11 @@ fn main() { ), } } else { + let mut s = termion().unwrap(); let app = App::load_state(); - let m = app.message.clone(); - unsafe { signal_hook::register(signal_hook::SIGINT, move || { - m.write().unwrap().set_message("Use the :q command to quit"); - }) }.unwrap(); - let mut s = termion().unwrap(); + // prevent Ctrl-C from killing the app and allow the app to override it. + s.clear_global_callbacks(cursive::event::Event::CtrlChar('c')); let layout = NamedView::new( "Frame", @@ -66,7 +64,6 @@ fn main() { s.add_global_callback(':', |s| open_command_window(s)); s.set_theme(theme::theme_gen()); - s.run(); } } -- cgit v1.2.3