mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-26 03:07:18 +02:00
Make today style configurable
This commit is contained in:
parent
b2271f9c19
commit
6e13948c0e
3 changed files with 16 additions and 3 deletions
|
@ -347,6 +347,7 @@ impl TaskwarriorTuiApp {
|
|||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded),
|
||||
)
|
||||
.today_style(self.config.uda_style_calendar_today)
|
||||
.year(self.calendar_year)
|
||||
.date_style(dates_with_styles)
|
||||
.months_per_row(self.config.uda_calendar_months_per_row);
|
||||
|
|
|
@ -25,6 +25,7 @@ pub struct Calendar<'a> {
|
|||
pub style: Style,
|
||||
pub months_per_row: usize,
|
||||
pub date_style: Vec<(NaiveDate, Style)>,
|
||||
pub today_style: Style,
|
||||
pub title_background_color: Color,
|
||||
}
|
||||
|
||||
|
@ -39,6 +40,7 @@ impl<'a> Default for Calendar<'a> {
|
|||
year,
|
||||
month,
|
||||
date_style: vec![],
|
||||
today_style: Default::default(),
|
||||
title_background_color: Color::Reset,
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +75,11 @@ impl<'a> Calendar<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn today_style(mut self, today_style: Style) -> Self {
|
||||
self.today_style = today_style;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn months_per_row(mut self, months_per_row: usize) -> Self {
|
||||
self.months_per_row = months_per_row;
|
||||
self
|
||||
|
@ -142,7 +149,7 @@ impl<'a> Widget for Calendar<'a> {
|
|||
let mut year = 0;
|
||||
let style = Style::default().add_modifier(Modifier::UNDERLINED);
|
||||
if self.year + year as i32 == today.year() {
|
||||
buf.set_string(x, y, &s, style.add_modifier(Modifier::BOLD));
|
||||
buf.set_string(x, y, &s, self.today_style.add_modifier(Modifier::UNDERLINED));
|
||||
} else {
|
||||
buf.set_string(x, y, &s, style);
|
||||
}
|
||||
|
@ -160,7 +167,7 @@ impl<'a> Widget for Calendar<'a> {
|
|||
let s = format!("{:^20}", month_names[m - 1]);
|
||||
let style = Style::default().bg(self.title_background_color);
|
||||
if m == today.month() as usize && self.year + year as i32 == today.year() {
|
||||
buf.set_string(x, y, &s, style.add_modifier(Modifier::BOLD));
|
||||
buf.set_string(x, y, &s, self.today_style);
|
||||
} else {
|
||||
buf.set_string(x, y, &s, style);
|
||||
}
|
||||
|
@ -200,7 +207,7 @@ impl<'a> Widget for Calendar<'a> {
|
|||
style = self.date_style[i].1
|
||||
}
|
||||
if d.1 == Local::today().naive_local() {
|
||||
buf.set_string(x, y, s, style.add_modifier(Modifier::BOLD));
|
||||
buf.set_string(x, y, s, self.today_style);
|
||||
} else {
|
||||
buf.set_string(x, y, s, style);
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ pub struct Config {
|
|||
pub uda_calendar_months_per_row: usize,
|
||||
pub uda_style_context_active: Style,
|
||||
pub uda_style_calendar_title: Style,
|
||||
pub uda_style_calendar_today: Style,
|
||||
pub uda_style_report_completion_pane: Style,
|
||||
pub uda_shortcuts: Vec<String>,
|
||||
}
|
||||
|
@ -92,10 +93,13 @@ impl Config {
|
|||
let uda_selection_blink = Self::get_uda_selection_blink(data);
|
||||
let uda_calendar_months_per_row = Self::get_uda_months_per_row(data);
|
||||
let uda_style_calendar_title = Self::get_uda_style("calendar.title", data);
|
||||
let uda_style_calendar_today = Self::get_uda_style("calendar.today", data);
|
||||
let uda_style_context_active = Self::get_uda_style("context.active", data);
|
||||
let uda_style_report_completion_pane = Self::get_uda_style("report.completion-pane", data);
|
||||
let uda_shortcuts = Self::get_uda_shortcuts(data);
|
||||
let uda_style_calendar_title = uda_style_calendar_title.unwrap_or_default();
|
||||
let uda_style_calendar_today =
|
||||
uda_style_calendar_today.unwrap_or_else(|| Style::default().add_modifier(Modifier::BOLD));
|
||||
let uda_style_context_active = uda_style_context_active.unwrap_or_default();
|
||||
let uda_style_report_completion_pane =
|
||||
uda_style_report_completion_pane.unwrap_or_else(|| Style::default().bg(Color::Rgb(223, 223, 223)));
|
||||
|
@ -125,6 +129,7 @@ impl Config {
|
|||
uda_calendar_months_per_row,
|
||||
uda_style_context_active,
|
||||
uda_style_calendar_title,
|
||||
uda_style_calendar_today,
|
||||
uda_style_report_completion_pane,
|
||||
uda_shortcuts,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue