mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-26 03:07:18 +02:00
Add configuration to disable looping
This commit is contained in:
parent
0aae32a706
commit
ae6e015069
3 changed files with 52 additions and 22 deletions
|
@ -183,6 +183,9 @@ uda.taskwarrior-tui.selection.dim=no
|
|||
uda.taskwarrior-tui.selection.blink=no
|
||||
uda.taskwarrior-tui.calendar.months-per-row=4
|
||||
uda.taskwarrior-tui.task-report.show-detail=true
|
||||
uda.taskwarrior-tui.task-report.looping=true
|
||||
uda.taskwarrior-tui.style.context.active=black on rgb444
|
||||
uda.taskwarrior-tui.style.calendar.title=black on rgb444
|
||||
```
|
||||
|
||||
</details>
|
||||
|
|
16
src/app.rs
16
src/app.rs
|
@ -686,7 +686,11 @@ impl TTApp {
|
|||
let i = match self.task_table_state.selected() {
|
||||
Some(i) => {
|
||||
if i >= self.tasks.lock().unwrap().len() - 1 {
|
||||
if self.config.uda_task_report_looping {
|
||||
0
|
||||
} else {
|
||||
i
|
||||
}
|
||||
} else {
|
||||
i + 1
|
||||
}
|
||||
|
@ -703,7 +707,11 @@ impl TTApp {
|
|||
let i = match self.task_table_state.selected() {
|
||||
Some(i) => {
|
||||
if i == 0 {
|
||||
if self.config.uda_task_report_looping {
|
||||
self.tasks.lock().unwrap().len() - 1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
} else {
|
||||
i - 1
|
||||
}
|
||||
|
@ -720,7 +728,11 @@ impl TTApp {
|
|||
let i = match self.task_table_state.selected() {
|
||||
Some(i) => {
|
||||
if i >= self.tasks.lock().unwrap().len() - 1 {
|
||||
if self.config.uda_task_report_looping {
|
||||
0
|
||||
} else {
|
||||
i
|
||||
}
|
||||
} else {
|
||||
i.checked_add(self.task_report_height as usize)
|
||||
.unwrap_or(self.tasks.lock().unwrap().len())
|
||||
|
@ -738,7 +750,11 @@ impl TTApp {
|
|||
let i = match self.task_table_state.selected() {
|
||||
Some(i) => {
|
||||
if i == 0 {
|
||||
if self.config.uda_task_report_looping {
|
||||
self.tasks.lock().unwrap().len() - 1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
} else {
|
||||
i.checked_sub(self.task_report_height as usize).unwrap_or(0)
|
||||
}
|
||||
|
|
|
@ -33,24 +33,6 @@ impl TColor {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Config {
|
||||
pub enabled: bool,
|
||||
pub color: HashMap<String, TColor>,
|
||||
pub obfuscate: bool,
|
||||
pub print_empty_columns: bool,
|
||||
pub rule_precedence_color: Vec<String>,
|
||||
pub uda_task_report_show_info: bool,
|
||||
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,
|
||||
pub uda_calendar_months_per_row: usize,
|
||||
pub uda_style_context_active: TColor,
|
||||
pub uda_style_calendar_title: TColor,
|
||||
}
|
||||
|
||||
trait TaskWarriorBool {
|
||||
fn get_bool(&self) -> Option<bool>;
|
||||
}
|
||||
|
@ -79,6 +61,26 @@ impl TaskWarriorBool for str {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Config {
|
||||
pub enabled: bool,
|
||||
pub color: HashMap<String, TColor>,
|
||||
pub obfuscate: bool,
|
||||
pub print_empty_columns: bool,
|
||||
pub rule_precedence_color: Vec<String>,
|
||||
pub uda_task_report_show_info: bool,
|
||||
pub uda_task_report_looping: bool,
|
||||
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,
|
||||
pub uda_calendar_months_per_row: usize,
|
||||
pub uda_style_context_active: TColor,
|
||||
pub uda_style_calendar_title: TColor,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn default() -> Result<Self, Box<dyn Error>> {
|
||||
let bool_collection = Self::get_bool_collection();
|
||||
|
@ -89,6 +91,7 @@ impl Config {
|
|||
color: Self::get_color_collection()?,
|
||||
rule_precedence_color: Self::get_rule_precedence_color(),
|
||||
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_selection_bold: Self::get_uda_selection_bold(),
|
||||
uda_selection_italic: Self::get_uda_selection_italic(),
|
||||
|
@ -318,6 +321,14 @@ impl Config {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_uda_task_report_looping() -> bool {
|
||||
let s = Self::get_config("uda.taskwarrior-tui.task-report.looping");
|
||||
match s.get_bool() {
|
||||
Some(b) => b,
|
||||
None => true,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_uda_selection_indicator() -> String {
|
||||
let indicator = Self::get_config("uda.taskwarrior-tui.selection.indicator");
|
||||
if indicator.is_empty() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue