diff options
author | Akshay <[email protected]> | 2021-01-25 10:15:03 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2021-01-25 10:15:03 +0000 |
commit | 9cdef4e296c77fb94d99553de05ba1aaa6c81ed8 (patch) | |
tree | 9c0f8d8b6fbf557cdf880a90d3ebb59df8392595 /src/views.rs | |
parent | 84c154018ebdd19acae10d6c9c802b41353507dc (diff) |
fix cursor coloring
Diffstat (limited to 'src/views.rs')
-rw-r--r-- | src/views.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/views.rs b/src/views.rs index a0beb2c..a306602 100644 --- a/src/views.rs +++ b/src/views.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use cursive::direction::Direction; | 1 | use cursive::direction::Direction; |
2 | use cursive::event::{Event, EventResult, Key}; | 2 | use cursive::event::{Event, EventResult, Key}; |
3 | use cursive::theme::{Effect, Style}; | 3 | use cursive::theme::{ColorStyle, ColorType, Effect, Style}; |
4 | use cursive::view::View; | 4 | use cursive::view::View; |
5 | use cursive::{Printer, Vec2}; | 5 | use cursive::{Printer, Vec2}; |
6 | 6 | ||
@@ -8,7 +8,7 @@ use chrono::prelude::*; | |||
8 | use chrono::{Local, NaiveDate}; | 8 | use chrono::{Local, NaiveDate}; |
9 | 9 | ||
10 | use crate::habit::{Bit, Count, Habit, TrackEvent, ViewMode}; | 10 | use crate::habit::{Bit, Count, Habit, TrackEvent, ViewMode}; |
11 | use crate::theme::cursor_gen; | 11 | use crate::theme::cursor_bg; |
12 | use crate::utils::VIEW_WIDTH; | 12 | use crate::utils::VIEW_WIDTH; |
13 | 13 | ||
14 | use crate::CONFIGURATION; | 14 | use crate::CONFIGURATION; |
@@ -112,12 +112,20 @@ where | |||
112 | let draw_day = |printer: &Printer| { | 112 | let draw_day = |printer: &Printer| { |
113 | let mut i = 0; | 113 | let mut i = 0; |
114 | while let Some(d) = NaiveDate::from_ymd_opt(year, month, i + 1) { | 114 | while let Some(d) = NaiveDate::from_ymd_opt(year, month, i + 1) { |
115 | let mut day_style = todo_style; | 115 | let mut day_style = Style::none(); |
116 | let mut fs = future_style; | ||
117 | let grs = ColorStyle::front(CONFIGURATION.reached_color()); | ||
118 | let ts = ColorStyle::front(CONFIGURATION.todo_color()); | ||
119 | let cs = ColorStyle::back(cursor_bg()); | ||
120 | |||
116 | if self.reached_goal(d) { | 121 | if self.reached_goal(d) { |
117 | day_style = goal_reached_style; | 122 | day_style = day_style.combine(Style::from(grs)); |
123 | } else { | ||
124 | day_style = day_style.combine(Style::from(ts)); | ||
118 | } | 125 | } |
119 | if d == now && printer.focused { | 126 | if d == now && printer.focused { |
120 | day_style = day_style.combine(cursor_gen(day_style)); | 127 | day_style = day_style.combine(cs); |
128 | fs = fs.combine(cs); | ||
121 | } | 129 | } |
122 | let coords: Vec2 = ((i % 7) * 3, i / 7 + 2).into(); | 130 | let coords: Vec2 = ((i % 7) * 3, i / 7 + 2).into(); |
123 | if let Some(c) = self.get_by_date(d) { | 131 | if let Some(c) = self.get_by_date(d) { |
@@ -125,7 +133,7 @@ where | |||
125 | p.print(coords, &format!("{:^3}", c)); | 133 | p.print(coords, &format!("{:^3}", c)); |
126 | }); | 134 | }); |
127 | } else { | 135 | } else { |
128 | printer.with_style(future_style, |p| { | 136 | printer.with_style(fs, |p| { |
129 | p.print(coords, &format!("{:^3}", CONFIGURATION.look.future_chr)); | 137 | p.print(coords, &format!("{:^3}", CONFIGURATION.look.future_chr)); |
130 | }); | 138 | }); |
131 | } | 139 | } |