From 0b4af96a515d51c409c6dafef406542dee9da3d4 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 18 Jul 2020 21:06:40 +0530 Subject: add smooth error handling --- src/app/impl_view.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/app/impl_view.rs') diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs index 904403b..0a6bce6 100644 --- a/src/app/impl_view.rs +++ b/src/app/impl_view.rs @@ -5,11 +5,12 @@ use std::path::PathBuf; use cursive::direction::{Absolute, Direction}; use cursive::event::{Event, EventResult, Key}; +use cursive::theme::{Color, Style}; use cursive::view::View; use cursive::{Printer, Vec2}; use notify::DebouncedEvent; -use crate::app::App; +use crate::app::{App, MessageKind}; use crate::habit::{HabitWrapper, ViewMode}; use crate::utils; use crate::CONFIGURATION; @@ -36,6 +37,11 @@ impl View for App { let full = self.max_size().x; offset = offset.map_x(|_| full - status.1.len()); 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()) + }); } fn required_size(&mut self, _: Vec2) -> Vec2 { @@ -158,6 +164,11 @@ impl View for App { self.set_view_month_offset(0); return EventResult::Consumed(None); } + Event::CtrlChar('l') => { + self.message.clear(); + self.message.set_kind(MessageKind::Info); + return EventResult::Consumed(None); + } /* Every keybind that is not caught by App trickles * down to the focused habit. We sift back to today -- cgit v1.2.3