aboutsummaryrefslogtreecommitdiff
path: root/src/app/impl_view.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-07-18 16:36:40 +0100
committerAkshay <[email protected]>2020-07-18 16:36:40 +0100
commit0b4af96a515d51c409c6dafef406542dee9da3d4 (patch)
tree21acafc98b48988d43627b8b8374ad02358f25d1 /src/app/impl_view.rs
parent29d49dddaae57d59a2c99c376a632a0d9560dcfc (diff)
add smooth error handling
Diffstat (limited to 'src/app/impl_view.rs')
-rw-r--r--src/app/impl_view.rs13
1 files changed, 12 insertions, 1 deletions
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;
5 5
6use cursive::direction::{Absolute, Direction}; 6use cursive::direction::{Absolute, Direction};
7use cursive::event::{Event, EventResult, Key}; 7use cursive::event::{Event, EventResult, Key};
8use cursive::theme::{Color, Style};
8use cursive::view::View; 9use cursive::view::View;
9use cursive::{Printer, Vec2}; 10use cursive::{Printer, Vec2};
10use notify::DebouncedEvent; 11use notify::DebouncedEvent;
11 12
12use crate::app::App; 13use crate::app::{App, MessageKind};
13use crate::habit::{HabitWrapper, ViewMode}; 14use crate::habit::{HabitWrapper, ViewMode};
14use crate::utils; 15use crate::utils;
15use crate::CONFIGURATION; 16use crate::CONFIGURATION;
@@ -36,6 +37,11 @@ impl View for App {
36 let full = self.max_size().x; 37 let full = self.max_size().x;
37 offset = offset.map_x(|_| full - status.1.len()); 38 offset = offset.map_x(|_| full - status.1.len());
38 printer.print(offset, &status.1); // right status 39 printer.print(offset, &status.1); // right status
40
41 offset = offset.map_x(|_| 0).map_y(|_| self.max_size().y - 1);
42 printer.with_style(Color::from(self.message.kind()), |p| {
43 p.print(offset, self.message.contents())
44 });
39 } 45 }
40 46
41 fn required_size(&mut self, _: Vec2) -> Vec2 { 47 fn required_size(&mut self, _: Vec2) -> Vec2 {
@@ -158,6 +164,11 @@ impl View for App {
158 self.set_view_month_offset(0); 164 self.set_view_month_offset(0);
159 return EventResult::Consumed(None); 165 return EventResult::Consumed(None);
160 } 166 }
167 Event::CtrlChar('l') => {
168 self.message.clear();
169 self.message.set_kind(MessageKind::Info);
170 return EventResult::Consumed(None);
171 }
161 172
162 /* Every keybind that is not caught by App trickles 173 /* Every keybind that is not caught by App trickles
163 * down to the focused habit. We sift back to today 174 * down to the focused habit. We sift back to today