aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-01-25 10:15:03 +0000
committerAkshay <[email protected]>2021-01-25 10:15:03 +0000
commit9cdef4e296c77fb94d99553de05ba1aaa6c81ed8 (patch)
tree9c0f8d8b6fbf557cdf880a90d3ebb59df8392595 /src
parent84c154018ebdd19acae10d6c9c802b41353507dc (diff)
fix cursor coloring
Diffstat (limited to 'src')
-rw-r--r--src/theme.rs10
-rw-r--r--src/views.rs20
2 files changed, 17 insertions, 13 deletions
diff --git a/src/theme.rs b/src/theme.rs
index e373b72..7ae9efc 100644
--- a/src/theme.rs
+++ b/src/theme.rs
@@ -1,4 +1,4 @@
1use cursive::theme::Color::*; 1use cursive::theme::Color::{self, *};
2use cursive::theme::PaletteColor::*; 2use cursive::theme::PaletteColor::*;
3use cursive::theme::{BorderStyle, ColorStyle, Palette, Style, Theme}; 3use cursive::theme::{BorderStyle, ColorStyle, Palette, Style, Theme};
4 4
@@ -25,10 +25,6 @@ pub fn theme_gen() -> Theme {
25 return t; 25 return t;
26} 26}
27 27
28pub fn cursor_gen(foreground: Style) -> Style { 28pub fn cursor_bg() -> Color {
29 Style::from(ColorStyle::new( 29 Light(cursive::theme::BaseColor::Black)
30 TerminalDefault,
31 Light(cursive::theme::BaseColor::Blue),
32 ))
33 .combine(foreground)
34} 30}
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 @@
1use cursive::direction::Direction; 1use cursive::direction::Direction;
2use cursive::event::{Event, EventResult, Key}; 2use cursive::event::{Event, EventResult, Key};
3use cursive::theme::{Effect, Style}; 3use cursive::theme::{ColorStyle, ColorType, Effect, Style};
4use cursive::view::View; 4use cursive::view::View;
5use cursive::{Printer, Vec2}; 5use cursive::{Printer, Vec2};
6 6
@@ -8,7 +8,7 @@ use chrono::prelude::*;
8use chrono::{Local, NaiveDate}; 8use chrono::{Local, NaiveDate};
9 9
10use crate::habit::{Bit, Count, Habit, TrackEvent, ViewMode}; 10use crate::habit::{Bit, Count, Habit, TrackEvent, ViewMode};
11use crate::theme::cursor_gen; 11use crate::theme::cursor_bg;
12use crate::utils::VIEW_WIDTH; 12use crate::utils::VIEW_WIDTH;
13 13
14use crate::CONFIGURATION; 14use 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 }