diff options
author | nc <[email protected]> | 2020-08-06 04:59:40 +0100 |
---|---|---|
committer | nc <[email protected]> | 2020-08-06 04:59:40 +0100 |
commit | 9777930868591abdf4a533e4059cc4fd08898521 (patch) | |
tree | e859f5db53ef8d025bc346d2ac1ae0b8090f6e2a | |
parent | 976ea0282d373c4d08187a78a7b46a09d66f7918 (diff) |
include only minimal code changes to add ctrl-c capturing functionality
-rw-r--r-- | src/app/impl_view.rs | 4 | ||||
-rw-r--r-- | src/main.rs | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs index 892b00c..5f313f7 100644 --- a/src/app/impl_view.rs +++ b/src/app/impl_view.rs | |||
@@ -165,6 +165,10 @@ impl View for App { | |||
165 | self.message.set_kind(MessageKind::Info); | 165 | self.message.set_kind(MessageKind::Info); |
166 | return EventResult::Consumed(None); | 166 | return EventResult::Consumed(None); |
167 | } | 167 | } |
168 | Event::CtrlChar('c') => { | ||
169 | self.message.set_message("Use the :q command to quit"); | ||
170 | return EventResult::Consumed(None); | ||
171 | } | ||
168 | 172 | ||
169 | /* Every keybind that is not caught by App trickles | 173 | /* Every keybind that is not caught by App trickles |
170 | * down to the focused habit. We sift back to today | 174 | * down to the focused habit. We sift back to today |
diff --git a/src/main.rs b/src/main.rs index d96119e..3ec964a 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -52,6 +52,10 @@ fn main() { | |||
52 | } else { | 52 | } else { |
53 | let mut s = termion().unwrap(); | 53 | let mut s = termion().unwrap(); |
54 | let app = App::load_state(); | 54 | let app = App::load_state(); |
55 | |||
56 | // prevent Ctrl-C from killing the app and allow the app to override it. | ||
57 | s.clear_global_callbacks(cursive::event::Event::CtrlChar('c')); | ||
58 | |||
55 | let layout = NamedView::new( | 59 | let layout = NamedView::new( |
56 | "Frame", | 60 | "Frame", |
57 | LinearLayout::vertical().child(NamedView::new("Main", app)), | 61 | LinearLayout::vertical().child(NamedView::new("Main", app)), |