From 66b2f0793f236dccd3269ae1c3cbfe2293f7fb3d Mon Sep 17 00:00:00 2001 From: nc Date: Mon, 20 Jul 2020 18:30:32 -0400 Subject: Add RwLock around messages. Catch SIGINT and print that :q is the way to quit. Note that this doesn't actually capture Ctrl-C. I'm not sure how it works but termion somehow swollows Ctrl-C so and circumvents the signal handler... --- src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index d96119e..ca1b653 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,8 +50,15 @@ 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 || { + std::fs::File::create("killed").unwrap(); + m.write().unwrap().set_message("Use the :q command to quit"); + }) }.unwrap(); + + let mut s = termion().unwrap(); + let layout = NamedView::new( "Frame", LinearLayout::vertical().child(NamedView::new("Main", app)), -- cgit v1.2.3