mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 17:57:19 +02:00
Make calendar background color configurable
This commit is contained in:
parent
9ec3543e9d
commit
0aae32a706
3 changed files with 9 additions and 3 deletions
|
@ -211,7 +211,7 @@ impl TTApp {
|
||||||
.constraints([Constraint::Min(0)].as_ref())
|
.constraints([Constraint::Min(0)].as_ref())
|
||||||
.split(f.size());
|
.split(f.size());
|
||||||
let today = Local::today();
|
let today = Local::today();
|
||||||
let c = Calendar::default()
|
let mut c = Calendar::default()
|
||||||
.block(
|
.block(
|
||||||
Block::default()
|
Block::default()
|
||||||
.title(Spans::from(vec![
|
.title(Spans::from(vec![
|
||||||
|
@ -225,6 +225,7 @@ impl TTApp {
|
||||||
.year(self.calendar_year)
|
.year(self.calendar_year)
|
||||||
.date_style(dates_with_styles)
|
.date_style(dates_with_styles)
|
||||||
.months_per_row(self.config.uda_calendar_months_per_row);
|
.months_per_row(self.config.uda_calendar_months_per_row);
|
||||||
|
c.title_background_color = self.config.uda_style_calendar_title.bg;
|
||||||
f.render_widget(c, rects[0]);
|
f.render_widget(c, rects[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ pub struct Calendar<'a> {
|
||||||
pub style: Style,
|
pub style: Style,
|
||||||
pub months_per_row: usize,
|
pub months_per_row: usize,
|
||||||
pub date_style: Vec<(NaiveDate, Style)>,
|
pub date_style: Vec<(NaiveDate, Style)>,
|
||||||
|
pub title_background_color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for Calendar<'a> {
|
impl<'a> Default for Calendar<'a> {
|
||||||
|
@ -38,6 +39,7 @@ impl<'a> Default for Calendar<'a> {
|
||||||
year,
|
year,
|
||||||
month,
|
month,
|
||||||
date_style: vec![],
|
date_style: vec![],
|
||||||
|
title_background_color: Color::White,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,7 +159,7 @@ impl<'a> Widget for Calendar<'a> {
|
||||||
let d = &mut days[c];
|
let d = &mut days[c];
|
||||||
let m = d.0.month() as usize;
|
let m = d.0.month() as usize;
|
||||||
let s = format!("{:^20}", month_names[m - 1]);
|
let s = format!("{:^20}", month_names[m - 1]);
|
||||||
let style = Style::default().bg(Color::Rgb(220, 220, 220));
|
let style = Style::default().bg(self.title_background_color);
|
||||||
if m == today.month() as usize && self.year + year as i32 == today.year() {
|
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, style.add_modifier(Modifier::BOLD));
|
||||||
} else {
|
} else {
|
||||||
|
@ -170,7 +172,7 @@ impl<'a> Widget for Calendar<'a> {
|
||||||
for c in startm..endm {
|
for c in startm..endm {
|
||||||
let d = &mut days[c];
|
let d = &mut days[c];
|
||||||
let m = d.0.month() as usize;
|
let m = d.0.month() as usize;
|
||||||
let style = Style::default().bg(Color::Rgb(220, 220, 220));
|
let style = Style::default().bg(self.title_background_color);
|
||||||
if m == today.month() as usize && self.year + year as i32 == today.year() {
|
if m == today.month() as usize && self.year + year as i32 == today.year() {
|
||||||
buf.set_string(
|
buf.set_string(
|
||||||
x as u16,
|
x as u16,
|
||||||
|
|
|
@ -48,6 +48,7 @@ pub struct Config {
|
||||||
pub uda_selection_blink: bool,
|
pub uda_selection_blink: bool,
|
||||||
pub uda_calendar_months_per_row: usize,
|
pub uda_calendar_months_per_row: usize,
|
||||||
pub uda_style_context_active: TColor,
|
pub uda_style_context_active: TColor,
|
||||||
|
pub uda_style_calendar_title: TColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait TaskWarriorBool {
|
trait TaskWarriorBool {
|
||||||
|
@ -94,6 +95,8 @@ impl Config {
|
||||||
uda_selection_dim: Self::get_uda_selection_dim(),
|
uda_selection_dim: Self::get_uda_selection_dim(),
|
||||||
uda_selection_blink: Self::get_uda_selection_blink(),
|
uda_selection_blink: Self::get_uda_selection_blink(),
|
||||||
uda_calendar_months_per_row: Self::get_uda_months_per_row(),
|
uda_calendar_months_per_row: Self::get_uda_months_per_row(),
|
||||||
|
uda_style_calendar_title: Self::get_uda_style("calendar.title")
|
||||||
|
.unwrap_or(TColor::new(Color::Black, Color::Rgb(220, 220, 220), vec![])),
|
||||||
uda_style_context_active: Self::get_uda_style("context.active")
|
uda_style_context_active: Self::get_uda_style("context.active")
|
||||||
.unwrap_or(TColor::new(Color::Black, Color::Rgb(220, 220, 220), vec![])),
|
.unwrap_or(TColor::new(Color::Black, Color::Rgb(220, 220, 220), vec![])),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue