diff --git a/src/app.rs b/src/app.rs index 2a59661..9ce4005 100644 --- a/src/app.rs +++ b/src/app.rs @@ -798,6 +798,8 @@ impl TTApp { ) .highlight_style(highlight_style) .highlight_symbol(&self.config.uda_selection_indicator) + .mark_symbol(&self.config.uda_mark_indicator) + .unmark_symbol(&self.config.uda_unmark_indicator) .widths(&constraints); f.render_stateful_widget(t, rect, &mut self.task_table_state); diff --git a/src/config.rs b/src/config.rs index 1dcd6e7..55a2904 100644 --- a/src/config.rs +++ b/src/config.rs @@ -45,6 +45,8 @@ pub struct Config { pub uda_task_report_show_info: bool, pub uda_task_report_looping: bool, pub uda_selection_indicator: String, + pub uda_mark_indicator: String, + pub uda_unmark_indicator: String, pub uda_selection_bold: bool, pub uda_selection_italic: bool, pub uda_selection_dim: bool, @@ -70,6 +72,8 @@ impl Config { uda_task_report_show_info: Self::get_uda_task_report_show_info(), uda_task_report_looping: Self::get_uda_task_report_looping(), uda_selection_indicator: Self::get_uda_selection_indicator(), + uda_mark_indicator: Self::get_uda_mark_indicator(), + uda_unmark_indicator: Self::get_uda_unmark_indicator(), uda_selection_bold: Self::get_uda_selection_bold(), uda_selection_italic: Self::get_uda_selection_italic(), uda_selection_dim: Self::get_uda_selection_dim(), @@ -335,6 +339,24 @@ impl Config { } } + fn get_uda_mark_indicator() -> String { + let indicator = Self::get_config("uda.taskwarrior-tui.mark.indicator"); + if indicator.is_empty() { + "☑ ".to_string() + } else { + format!("{} ", indicator) + } + } + + fn get_uda_unmark_indicator() -> String { + let indicator = Self::get_config("uda.taskwarrior-tui.unmark.indicator"); + if indicator.is_empty() { + "☐ ".to_string() + } else { + format!("{} ", indicator) + } + } + fn get_uda_selection_bold() -> bool { Self::get_config("uda.taskwarrior-tui.selection.bold") .get_bool() diff --git a/src/table.rs b/src/table.rs index 6ff6184..75f9b0b 100644 --- a/src/table.rs +++ b/src/table.rs @@ -154,6 +154,8 @@ pub struct Table<'a, H, R> { highlight_symbol: Option<&'a str>, /// Symbol in front of the marked row mark_symbol: Option<&'a str>, + /// Symbol in front of the unmarked row + unmark_symbol: Option<&'a str>, /// Data to display in each row rows: R, } @@ -175,6 +177,7 @@ where highlight_style: Style::default(), highlight_symbol: None, mark_symbol: None, + unmark_symbol: None, rows: R::default(), } } @@ -198,6 +201,7 @@ where highlight_style: Style::default(), highlight_symbol: None, mark_symbol: None, + unmark_symbol: None, rows, } } @@ -245,6 +249,16 @@ where self } + pub fn mark_symbol(mut self, mark_symbol: &'a str) -> Table<'a, H, R> { + self.mark_symbol = Some(mark_symbol); + self + } + + pub fn unmark_symbol(mut self, unmark_symbol: &'a str) -> Table<'a, H, R> { + self.unmark_symbol = Some(unmark_symbol); + self + } + pub fn highlight_symbol(mut self, highlight_symbol: &'a str) -> Table<'a, H, R> { self.highlight_symbol = Some(highlight_symbol); self @@ -382,7 +396,10 @@ where }; let blank_symbol = match state.mode { - TableMode::MultipleSelection => "☐ ".to_string(), + TableMode::MultipleSelection => { + let s = self.unmark_symbol.unwrap_or("☐").trim_end(); + format!("{} ", s) + } TableMode::SingleSelection => iter::repeat(" ").take(highlight_symbol.width()).collect::(), };