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

feat: dim unselected #611

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions docs/configuration/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ uda.taskwarrior-tui.selection.italic=no
uda.taskwarrior-tui.selection.dim=no
uda.taskwarrior-tui.selection.blink=no
uda.taskwarrior-tui.selection.reverse=no
uda.taskwarrior-tui.unselected.dim=no
uda.taskwarrior-tui.mark.indicator=✔
uda.taskwarrior-tui.unmark.indicator=
uda.taskwarrior-tui.mark-selection.indicator=⦿
Expand Down
7 changes: 7 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,10 @@ impl TaskwarriorTui {
let virtual_tag_names_in_precedence = &self.config.rule_precedence_color;

let mut style = Style::default();
if self.config.uda_unselected_dim {
style = style.patch(self.config.uda_style_report_unselected);
style = style.add_modifier(Modifier::DIM);
}

for tag_name in virtual_tag_names_in_precedence.iter().rev() {
if tag_name == "uda." || tag_name == "priority" {
Expand Down Expand Up @@ -1227,6 +1231,9 @@ impl TaskwarriorTui {
if self.config.uda_selection_reverse {
highlight_style = highlight_style.add_modifier(Modifier::REVERSED);
}
if self.config.uda_unselected_dim {
highlight_style = highlight_style.fg(Color::White);
}
}
rows.push(Row::StyledData(task.iter(), style));
}
Expand Down
14 changes: 14 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ pub struct Config {
pub uda_selection_dim: bool,
pub uda_selection_blink: bool,
pub uda_selection_reverse: bool,
pub uda_unselected_dim: bool,
pub uda_calendar_months_per_row: usize,
pub uda_style_context_active: Style,
pub uda_style_report_selection: Style,
pub uda_style_report_unselected: Style,
pub uda_style_calendar_title: Style,
pub uda_style_calendar_today: Style,
pub uda_style_navbar: Style,
Expand Down Expand Up @@ -146,8 +148,10 @@ impl Config {
let uda_selection_dim = Self::get_uda_selection_dim(data);
let uda_selection_blink = Self::get_uda_selection_blink(data);
let uda_selection_reverse = Self::get_uda_selection_reverse(data);
let uda_unselected_dim = Self::get_uda_unselected_dim(data);
let uda_calendar_months_per_row = Self::get_uda_months_per_row(data);
let uda_style_report_selection = Self::get_uda_style("report.selection", data);
let uda_style_report_unselected = Self::get_uda_style("report.unselected", data);
let uda_style_report_scrollbar = Self::get_uda_style("report.scrollbar", data);
let uda_style_report_scrollbar_area = Self::get_uda_style("report.scrollbar.area", data);
let uda_style_calendar_title = Self::get_uda_style("calendar.title", data);
Expand All @@ -161,6 +165,7 @@ impl Config {
let uda_background_process = Self::get_uda_background_process(data);
let uda_background_process_period = Self::get_uda_background_process_period(data);
let uda_style_report_selection = uda_style_report_selection.unwrap_or_default();
let uda_style_report_unselected = uda_style_report_unselected.unwrap_or_default();
let uda_style_report_scrollbar = uda_style_report_scrollbar.unwrap_or_else(|| Style::default().fg(Color::Black));
let uda_style_report_scrollbar_area = uda_style_report_scrollbar_area.unwrap_or_default();
let uda_style_calendar_title = uda_style_calendar_title.unwrap_or_default();
Expand Down Expand Up @@ -213,8 +218,10 @@ impl Config {
uda_selection_dim,
uda_selection_blink,
uda_selection_reverse,
uda_unselected_dim,
uda_calendar_months_per_row,
uda_style_report_selection,
uda_style_report_unselected,
uda_style_context_active,
uda_style_calendar_title,
uda_style_calendar_today,
Expand Down Expand Up @@ -712,6 +719,13 @@ impl Config {
.unwrap_or(false)
}

fn get_uda_unselected_dim(data: &str) -> bool {
Self::get_config("uda.taskwarrior-tui.unselected.dim", data)
.unwrap_or_default()
.get_bool()
.unwrap_or(false)
}

fn get_uda_months_per_row(data: &str) -> usize {
Self::get_config("uda.taskwarrior-tui.calendar.months-per-row", data)
.unwrap_or_default()
Expand Down
Loading