Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #121: Cursor Color Customization #237

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/theme.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cursive::theme::Color::{self, *};
use cursive::theme::Color::*;
use cursive::theme::PaletteColor::*;
use cursive::theme::{BorderStyle, Palette, Theme};

Expand All @@ -25,6 +25,6 @@ pub fn theme_gen() -> Theme {
return t;
}

pub fn cursor_bg() -> Color {
Light(cursive::theme::BaseColor::Black)
}
// pub fn cursor_bg() -> Color {
// Light(cursive::theme::BaseColor::Black)
// }
59 changes: 59 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ pub struct Colors {
pub todo: String,
#[serde(default = "light_black")]
pub inactive: String,
#[serde(default = "dark_white")]
pub cursor: String,
}

// Cyan and Magenta are dark by default
fn cyan() -> String {
"cyan".into()
}
Expand All @@ -55,13 +58,66 @@ fn magenta() -> String {
fn light_black() -> String {
"light black".into()
}
#[allow(dead_code)]
fn light_cyan() -> String {
"light cyan".into()
}
#[allow(dead_code)]
fn light_magenta() -> String {
"light magenta".into()
}
#[allow(dead_code)]
fn light_blue() -> String {
"light blue".into()
}
#[allow(dead_code)]
fn light_green() -> String {
"light green".into()
}
#[allow(dead_code)]
fn light_red() -> String {
"light red".into()
}
#[allow(dead_code)]
fn light_white() -> String {
"light white".into()
}
#[allow(dead_code)]
fn light_yellow() -> String {
"light yellow".into()
}
#[allow(dead_code)]
fn dark_white() -> String {
"dark white".into()
}
#[allow(dead_code)]
fn dark_black() -> String {
"dark black".into()
}
#[allow(dead_code)]
fn dark_blue() -> String {
"dark blue".into()
}
#[allow(dead_code)]
fn dark_green() -> String {
"dark green".into()
}
#[allow(dead_code)]
fn dark_red() -> String {
"dark red".into()
}
#[allow(dead_code)]
fn dark_yellow() -> String {
"dark yellow".into()
}

impl Default for Colors {
fn default() -> Self {
Colors {
reached: cyan(),
todo: magenta(),
inactive: light_black(),
cursor: light_black(),
}
}
}
Expand Down Expand Up @@ -95,6 +151,9 @@ impl AppConfig {
pub fn inactive_color(&self) -> Color {
return Color::parse(&self.colors.inactive).unwrap_or(Color::Light(BaseColor::Black));
}
pub fn cursor_color(&self) -> Color {
return Color::parse(&self.colors.cursor).unwrap_or(Color::Light(BaseColor::Black));
}
}

pub fn load_configuration_file() -> AppConfig {
Expand Down
4 changes: 2 additions & 2 deletions src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use chrono::prelude::*;
use chrono::{Local, NaiveDate};

use crate::habit::{Bit, Count, Float, Habit, TrackEvent, ViewMode};
use crate::theme::cursor_bg;
// use crate::theme::cursor_bg;
use crate::utils::VIEW_WIDTH;

use crate::CONFIGURATION;
Expand Down Expand Up @@ -115,7 +115,7 @@ where
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());
let cs = ColorStyle::back(CONFIGURATION.cursor_color());

if self.reached_goal(d) {
day_style = day_style.combine(Style::from(grs));
Expand Down