Skip to content

Commit

Permalink
Merge pull request #4 from Tylryan/optional-bold-days
Browse files Browse the repository at this point in the history
Added Bold Options
  • Loading branch information
Tylryan authored Dec 3, 2022
2 parents a31f4c4 + 9c58234 commit 6d3733e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
21 changes: 15 additions & 6 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,27 @@ pub struct Characters {
pub false_chr: char,
#[serde(default = "base_char")]
pub future_chr: char,
#[serde(default = "return_true")]
pub bold_future: bool,
#[serde(default = "return_true")]
pub bold_today: bool,
#[serde(default = "return_false")]
pub bold_past: bool,
}

fn base_char() -> char {
'·'
}
fn base_char() -> char { '·' }
fn return_true() -> bool { true }
fn return_false() -> bool { false }

impl Default for Characters {
fn default() -> Self {
Characters {
true_chr: '·',
false_chr: '·',
future_chr: '·',
true_chr: '·',
false_chr: '·',
future_chr: '·',
bold_future: true,
bold_today: true,
bold_past: false,
}
}
}
Expand Down
35 changes: 16 additions & 19 deletions src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@ where
let is_this_month = now.month() == Local::now().month();
let is_this_year = now.year() == Local::now().year();

let goal_reached_style = Style::from(CONFIGURATION.reached_color());
let future_style = Style::from(CONFIGURATION.future_color());
let today_style = Style::from(CONFIGURATION.today_color());
let goal_reached_style = Style::from(CONFIGURATION.reached_color());
let mut future_style = Style::from(CONFIGURATION.future_color());
let mut today_style = Style::from(CONFIGURATION.today_color());
let mut past_style = Style::from(CONFIGURATION.inactive_color());

let past_style = Style::from(CONFIGURATION.inactive_color());
let strikethrough = Style::from(Effect::Strikethrough);
let strikethrough = Style::from(Effect::Strikethrough);
let bold = Style::from(Effect::Bold);

let goal_status = is_today && self.reached_goal(Local::now().naive_local().date());
if CONFIGURATION.look.bold_future { future_style = Style::merge(&[future_style, bold]);}
if CONFIGURATION.look.bold_today { today_style = Style::merge(&[today_style, bold]); }
if CONFIGURATION.look.bold_past { past_style = Style::merge(&[past_style, bold]); }

let goal_status = is_today && self.reached_goal(Local::now().naive_local().date());

printer.with_style(
Style::merge(&[
if goal_status {
strikethrough
} else {
Style::none()
},
if !printer.focused {
past_style
} else {
Style::none()
},
if goal_status { strikethrough }
else { Style::none() },

if !printer.focused { past_style }
else { Style::none() },
]),
|p| {
p.print(
Expand Down Expand Up @@ -140,12 +140,9 @@ where
});
} else {
if i == (actual_day -1) && is_this_month && is_this_year {
// tds = tds.combine(tds);
// tds.combine(cs);
printer.with_style(tds, |p| {
p.print(coords, &format!("{:^3}", CONFIGURATION.look.future_chr));
});

}
else if i < day || !is_this_month || !is_this_year {
printer.with_style(ps, |p| {
Expand Down

0 comments on commit 6d3733e

Please sign in to comment.