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/app/impl_view.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/app/impl_view.rs') diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs index 892b00c..acc387e 100644 --- a/src/app/impl_view.rs +++ b/src/app/impl_view.rs @@ -39,8 +39,8 @@ impl View for App { printer.print(offset, &status.1); // right status offset = offset.map_x(|_| 0).map_y(|_| self.max_size().y - 1); - printer.with_style(Color::from(self.message.kind()), |p| { - p.print(offset, self.message.contents()) + printer.with_style(Color::from(self.message.read().unwrap().kind()), |p| { + p.print(offset, self.message.read().unwrap().contents()) }); } @@ -161,8 +161,8 @@ impl View for App { return EventResult::Consumed(None); } Event::CtrlChar('l') => { - self.message.clear(); - self.message.set_kind(MessageKind::Info); + self.message.write().unwrap().clear(); + self.message.write().unwrap().set_kind(MessageKind::Info); return EventResult::Consumed(None); } -- cgit v1.2.3