aboutsummaryrefslogtreecommitdiff
path: root/src/views.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-07-10 17:22:05 +0100
committerAkshay <[email protected]>2020-07-10 17:22:05 +0100
commit872297132d9d1fa39545fee54a1a25a95bdbe22d (patch)
tree418d5c141697d20d1e1ec4de07c627e1e7683762 /src/views.rs
parent3895dd5b875fc4c468d692ee59ec58128365e422 (diff)
use strikethrough for completion
Diffstat (limited to 'src/views.rs')
-rw-r--r--src/views.rs34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/views.rs b/src/views.rs
index 81eaf6c..64c85ce 100644
--- a/src/views.rs
+++ b/src/views.rs
@@ -1,6 +1,6 @@
1use cursive::direction::Direction; 1use cursive::direction::Direction;
2use cursive::event::{Event, EventResult, Key}; 2use cursive::event::{Event, EventResult, Key};
3use cursive::theme::Style; 3use cursive::theme::{Effect, Style};
4use cursive::view::View; 4use cursive::view::View;
5use cursive::{Printer, Vec2}; 5use cursive::{Printer, Vec2};
6 6
@@ -39,24 +39,26 @@ where
39 let todo_style = Style::from(CONFIGURATION.todo_color); 39 let todo_style = Style::from(CONFIGURATION.todo_color);
40 let future_style = Style::from(CONFIGURATION.future_color); 40 let future_style = Style::from(CONFIGURATION.future_color);
41 41
42 let goal_reached_today = self.reached_goal(Local::now().naive_utc().date()); 42 let done_today_style = Style::from(Effect::Strikethrough);
43 if goal_reached_today { 43
44 printer.with_style(goal_reached_style, |p| p.print((0, 0), "[x]")); 44 let goal_status =
45 } else { 45 self.view_month_offset() == 0 && self.reached_goal(Local::now().naive_utc().date());
46 printer.with_style(todo_style, |p| p.print((0, 0), "[ ]"));
47 }
48 46
49 printer.with_style( 47 printer.with_style(
50 if !printer.focused { 48 Style::merge(&[
51 future_style 49 if goal_status {
52 } else { 50 done_today_style
53 Style::none() 51 } else {
54 }, 52 Style::none()
53 },
54 if !printer.focused {
55 future_style
56 } else {
57 Style::none()
58 },
59 ]),
55 |p| { 60 |p| {
56 p.print( 61 p.print((0, 0), &format!(" {} ", self.name()));
57 (4, 0),
58 &format!("{:width$}", self.name(), width = CONFIGURATION.view_width),
59 )
60 }, 62 },
61 ); 63 );
62 64