Skip to content

Commit

Permalink
Merge pull request #461 from kdheepak/kd/rotate-tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
kdheepak authored Jul 28, 2022
2 parents 40cb4bb + b4a28a0 commit 12f7ea0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/configuration/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ uda.taskwarrior-tui.task-report.auto-insert-double-quotes-on-annotate=true
uda.taskwarrior-tui.task-report.auto-insert-double-quotes-on-log=true
uda.taskwarrior-tui.task-report.reset-filter-on-esc=true
uda.taskwarrior-tui.context-menu.select-on-move=false
uda.taskwarrior-tui.tabs.change-focus-rotate=false
```

The `uda.taskwarrior-tui.task-report.next.filter` variable defines the default view at program startup. Set this to any preconfigured report (`task reports`), or create your own report in taskwarrior and specify its name here.
Expand Down
8 changes: 8 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2542,6 +2542,10 @@ impl TaskwarriorTui {
Mode::Calendar => {
if input == self.keyconfig.quit || input == KeyCode::Ctrl('c') {
self.should_quit = true;
} else if input == self.keyconfig.next_tab {
if self.config.uda_change_focus_rotate {
self.mode = Mode::Tasks(Action::Report);
}
} else if input == self.keyconfig.previous_tab {
self.mode = Mode::Projects;
} else if input == KeyCode::Up || input == self.keyconfig.up {
Expand Down Expand Up @@ -2842,6 +2846,10 @@ impl TaskwarriorTui {
self.task_report_show_info = !self.task_report_show_info;
} else if input == self.keyconfig.context_menu {
self.mode = Mode::Tasks(Action::ContextMenu);
} else if input == self.keyconfig.previous_tab {
if self.config.uda_change_focus_rotate {
self.mode = Mode::Calendar;
}
} else if input == self.keyconfig.next_tab {
self.mode = Mode::Projects;
}
Expand Down
10 changes: 10 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub struct Config {
pub uda_style_report_completion_pane: Style,
pub uda_style_report_completion_pane_highlight: Style,
pub uda_shortcuts: Vec<String>,
pub uda_change_focus_rotate: bool,
pub uda_background_process: String,
pub uda_background_process_period: usize,
pub uda_quick_tag_name: String,
Expand Down Expand Up @@ -120,6 +121,7 @@ impl Config {
let rule_precedence_color = Self::get_rule_precedence_color(data);
let uda_priority_values = Self::get_uda_priority_values(data);
let uda_tick_rate = Self::get_uda_tick_rate(data);
let uda_change_focus_rotate = Self::get_uda_change_focus_rotate(data);
let uda_auto_insert_double_quotes_on_add = Self::get_uda_auto_insert_double_quotes_on_add(data);
let uda_auto_insert_double_quotes_on_annotate = Self::get_uda_auto_insert_double_quotes_on_annotate(data);
let uda_auto_insert_double_quotes_on_log = Self::get_uda_auto_insert_double_quotes_on_log(data);
Expand Down Expand Up @@ -185,6 +187,7 @@ impl Config {
rule_precedence_color,
uda_priority_values,
uda_tick_rate,
uda_change_focus_rotate,
uda_auto_insert_double_quotes_on_add,
uda_auto_insert_double_quotes_on_annotate,
uda_auto_insert_double_quotes_on_log,
Expand Down Expand Up @@ -529,6 +532,13 @@ impl Config {
.unwrap_or(true)
}

fn get_uda_change_focus_rotate(data: &str) -> bool {
Self::get_config("uda.taskwarrior-tui.tabs.change-focus-rotate", data)
.unwrap_or_default()
.get_bool()
.unwrap_or(false)
}

fn get_uda_tick_rate(data: &str) -> u64 {
Self::get_config("uda.taskwarrior-tui.tick-rate", data)
.unwrap_or_default()
Expand Down
12 changes: 10 additions & 2 deletions src/pane/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ pub trait Pane {
fn handle_input(app: &mut TaskwarriorTui, input: KeyCode) -> Result<()>;
fn change_focus_to_left_pane(app: &mut TaskwarriorTui) {
match app.mode {
Mode::Tasks(_) => {}
Mode::Tasks(_) => {
if app.config.uda_change_focus_rotate {
app.mode = Mode::Calendar;
}
}
Mode::Projects => app.mode = Mode::Tasks(Action::Report),
Mode::Calendar => {
app.mode = Mode::Projects;
Expand All @@ -23,7 +27,11 @@ pub trait Pane {
match app.mode {
Mode::Tasks(_) => app.mode = Mode::Projects,
Mode::Projects => app.mode = Mode::Calendar,
Mode::Calendar => {}
Mode::Calendar => {
if app.config.uda_change_focus_rotate {
app.mode = Mode::Tasks(Action::Report);
}
}
}
}
}

0 comments on commit 12f7ea0

Please sign in to comment.