mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 08:47:18 +02:00
Support selection bold italic dim and blink
This commit is contained in:
parent
8d4c0d2bcc
commit
ad16ef71af
2 changed files with 67 additions and 6 deletions
16
src/app.rs
16
src/app.rs
|
@ -812,7 +812,19 @@ impl TTApp {
|
|||
for (i, task) in tasks.iter().enumerate() {
|
||||
let style = self.style_for_task(&self.tasks.lock().unwrap()[i]);
|
||||
if i == selected {
|
||||
highlight_style = style.add_modifier(Modifier::BOLD);
|
||||
highlight_style = style;
|
||||
if self.config.uda_selection_bold {
|
||||
highlight_style = highlight_style.add_modifier(Modifier::BOLD);
|
||||
}
|
||||
if self.config.uda_selection_italic {
|
||||
highlight_style = highlight_style.add_modifier(Modifier::ITALIC);
|
||||
}
|
||||
if self.config.uda_selection_dim {
|
||||
highlight_style = highlight_style.add_modifier(Modifier::DIM);
|
||||
}
|
||||
if self.config.uda_selection_blink {
|
||||
highlight_style = highlight_style.add_modifier(Modifier::SLOW_BLINK);
|
||||
}
|
||||
}
|
||||
rows.push(Row::StyledData(task.iter(), style));
|
||||
}
|
||||
|
@ -825,7 +837,7 @@ impl TTApp {
|
|||
let t = Table::new(header, rows.into_iter())
|
||||
.block(Block::default().borders(Borders::ALL).title("Task next"))
|
||||
.highlight_style(highlight_style)
|
||||
.highlight_symbol(&self.config.uda_current_task_indicator)
|
||||
.highlight_symbol(&self.config.uda_selection_indicator)
|
||||
.widths(&constraints);
|
||||
|
||||
f.render_stateful_widget(t, rect, &mut self.state);
|
||||
|
|
|
@ -33,7 +33,11 @@ pub struct TConfig {
|
|||
pub obfuscate: bool,
|
||||
pub print_empty_columns: bool,
|
||||
pub rule_precedence_color: Vec<String>,
|
||||
pub uda_current_task_indicator: String,
|
||||
pub uda_selection_indicator: String,
|
||||
pub uda_selection_bold: bool,
|
||||
pub uda_selection_italic: bool,
|
||||
pub uda_selection_dim: bool,
|
||||
pub uda_selection_blink: bool,
|
||||
}
|
||||
|
||||
impl TConfig {
|
||||
|
@ -45,7 +49,11 @@ impl TConfig {
|
|||
print_empty_columns: bool_collection.get("print_empty_columns").cloned().unwrap_or(false),
|
||||
color: Self::get_color_collection(),
|
||||
rule_precedence_color: Self::get_rule_precedence_color(),
|
||||
uda_current_task_indicator: Self::get_uda_current_task_indicator(),
|
||||
uda_selection_indicator: Self::get_uda_selection_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(),
|
||||
uda_selection_blink: Self::get_uda_selection_blink(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,8 +253,8 @@ impl TConfig {
|
|||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
fn get_uda_current_task_indicator() -> String {
|
||||
let indicator = Self::get_config("uda.taskwarrior-tui.indicator");
|
||||
fn get_uda_selection_indicator() -> String {
|
||||
let indicator = Self::get_config("uda.taskwarrior-tui.selection.indicator");
|
||||
if indicator.is_empty() {
|
||||
"• ".to_string()
|
||||
} else {
|
||||
|
@ -254,6 +262,47 @@ impl TConfig {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_uda_selection_bold() -> bool {
|
||||
let s = Self::get_config("uda.taskwarrior-tui.selection.bold");
|
||||
if s == "yes" {
|
||||
true
|
||||
} else if s == "no" {
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
fn get_uda_selection_italic() -> bool {
|
||||
let s = Self::get_config("uda.taskwarrior-tui.selection.italic");
|
||||
if s == "yes" {
|
||||
true
|
||||
} else if s == "no" {
|
||||
false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
fn get_uda_selection_dim() -> bool {
|
||||
let s = Self::get_config("uda.taskwarrior-tui.selection.dim");
|
||||
if s == "yes" {
|
||||
true
|
||||
} else if s == "no" {
|
||||
false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
fn get_uda_selection_blink() -> bool {
|
||||
let s = Self::get_config("uda.taskwarrior-tui.selection.blink");
|
||||
if s == "yes" {
|
||||
true
|
||||
} else if s == "no" {
|
||||
false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue