From 9cdef4e296c77fb94d99553de05ba1aaa6c81ed8 Mon Sep 17 00:00:00 2001 From: Akshay Date: Mon, 25 Jan 2021 15:45:03 +0530 Subject: fix cursor coloring --- src/theme.rs | 10 +++------- src/views.rs | 20 ++++++++++++++------ 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 @@ -use cursive::theme::Color::*; +use cursive::theme::Color::{self, *}; use cursive::theme::PaletteColor::*; use cursive::theme::{BorderStyle, ColorStyle, Palette, Style, Theme}; @@ -25,10 +25,6 @@ pub fn theme_gen() -> Theme { return t; } -pub fn cursor_gen(foreground: Style) -> Style { - Style::from(ColorStyle::new( - TerminalDefault, - Light(cursive::theme::BaseColor::Blue), - )) - .combine(foreground) +pub fn cursor_bg() -> Color { + Light(cursive::theme::BaseColor::Black) } 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 @@ use cursive::direction::Direction; use cursive::event::{Event, EventResult, Key}; -use cursive::theme::{Effect, Style}; +use cursive::theme::{ColorStyle, ColorType, Effect, Style}; use cursive::view::View; use cursive::{Printer, Vec2}; @@ -8,7 +8,7 @@ use chrono::prelude::*; use chrono::{Local, NaiveDate}; use crate::habit::{Bit, Count, Habit, TrackEvent, ViewMode}; -use crate::theme::cursor_gen; +use crate::theme::cursor_bg; use crate::utils::VIEW_WIDTH; use crate::CONFIGURATION; @@ -112,12 +112,20 @@ where let draw_day = |printer: &Printer| { let mut i = 0; while let Some(d) = NaiveDate::from_ymd_opt(year, month, i + 1) { - let mut day_style = todo_style; + let mut day_style = Style::none(); + let mut fs = future_style; + let grs = ColorStyle::front(CONFIGURATION.reached_color()); + let ts = ColorStyle::front(CONFIGURATION.todo_color()); + let cs = ColorStyle::back(cursor_bg()); + if self.reached_goal(d) { - day_style = goal_reached_style; + day_style = day_style.combine(Style::from(grs)); + } else { + day_style = day_style.combine(Style::from(ts)); } if d == now && printer.focused { - day_style = day_style.combine(cursor_gen(day_style)); + day_style = day_style.combine(cs); + fs = fs.combine(cs); } let coords: Vec2 = ((i % 7) * 3, i / 7 + 2).into(); if let Some(c) = self.get_by_date(d) { @@ -125,7 +133,7 @@ where p.print(coords, &format!("{:^3}", c)); }); } else { - printer.with_style(future_style, |p| { + printer.with_style(fs, |p| { p.print(coords, &format!("{:^3}", CONFIGURATION.look.future_chr)); }); } -- cgit v1.2.3