aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authornc <[email protected]>2020-07-20 23:30:32 +0100
committernc <[email protected]>2020-07-20 23:30:32 +0100
commit66b2f0793f236dccd3269ae1c3cbfe2293f7fb3d (patch)
tree0e1a2604d9d395bda8d8eaae12353014b6adc836 /src/main.rs
parent2a3be003015bac9c6a13549029b9fb4595e88384 (diff)
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...
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs9
1 files changed, 8 insertions, 1 deletions
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() {
50 ), 50 ),
51 } 51 }
52 } else { 52 } else {
53 let mut s = termion().unwrap();
54 let app = App::load_state(); 53 let app = App::load_state();
54 let m = app.message.clone();
55 unsafe { signal_hook::register(signal_hook::SIGINT, move || {
56 std::fs::File::create("killed").unwrap();
57 m.write().unwrap().set_message("Use the :q command to quit");
58 }) }.unwrap();
59
60 let mut s = termion().unwrap();
61
55 let layout = NamedView::new( 62 let layout = NamedView::new(
56 "Frame", 63 "Frame",
57 LinearLayout::vertical().child(NamedView::new("Main", app)), 64 LinearLayout::vertical().child(NamedView::new("Main", app)),