feat: Change next-tag to quick-tag

This commit is contained in:
Dheepak Krishnamurthy 2021-10-29 12:27:51 -06:00
parent 68d6ab1299
commit e7a886a42f
5 changed files with 75 additions and 92 deletions

View file

@ -4,7 +4,6 @@ Configure `taskwarrior-tui` using `~/.taskrc`:
`taskwarrior-tui` reads values from your `taskwarrior`'s `taskrc` file (default: `~/.taskrc`). `taskwarrior-tui` reads values from your `taskwarrior`'s `taskrc` file (default: `~/.taskrc`).
```plaintext ```plaintext
uda.taskwarrior-tui.keyconfig.quit=q uda.taskwarrior-tui.keyconfig.quit=q
uda.taskwarrior-tui.keyconfig.refresh=r uda.taskwarrior-tui.keyconfig.refresh=r
@ -17,7 +16,7 @@ uda.taskwarrior-tui.keyconfig.page-up=K
uda.taskwarrior-tui.keyconfig.delete=x uda.taskwarrior-tui.keyconfig.delete=x
uda.taskwarrior-tui.keyconfig.done=d uda.taskwarrior-tui.keyconfig.done=d
uda.taskwarrior-tui.keyconfig.start-stop=s uda.taskwarrior-tui.keyconfig.start-stop=s
uda.taskwarrior-tui.keyconfig.tag-next=n uda.taskwarrior-tui.keyconfig.quick-tag=n
uda.taskwarrior-tui.keyconfig.undo=u uda.taskwarrior-tui.keyconfig.undo=u
uda.taskwarrior-tui.keyconfig.edit=e uda.taskwarrior-tui.keyconfig.edit=e
uda.taskwarrior-tui.keyconfig.modify=m uda.taskwarrior-tui.keyconfig.modify=m

View file

@ -4,23 +4,17 @@
<!-- To generate the roff version, run `just man`, --> <!-- To generate the roff version, run `just man`, -->
<!-- and the man page will appear in the target directory. --> <!-- and the man page will appear in the target directory. -->
# NAME
NAME
====
taskwarrior-tui — A terminal user interface for taskwarrior (https://github.com/kdheepak/taskwarrior-tui) taskwarrior-tui — A terminal user interface for taskwarrior (https://github.com/kdheepak/taskwarrior-tui)
# SYNOPSIS
SYNOPSIS
========
`taskwarrior-tui` `taskwarrior-tui`
**`taskwarrior-tui`** is a terminal user interface for `taskwarrior`. **`taskwarrior-tui`** is a terminal user interface for `taskwarrior`.
# EXAMPLES
EXAMPLES
========
`taskwarrior-tui` `taskwarrior-tui`
: Starts a terminal user interface for `taskwarrior`. : Starts a terminal user interface for `taskwarrior`.
@ -28,9 +22,7 @@ EXAMPLES
`alias tt=taskwarrior-tui` `alias tt=taskwarrior-tui`
: Add the above to your dotfiles to use `tt` to start `taskwarrior-tui`. : Add the above to your dotfiles to use `tt` to start `taskwarrior-tui`.
KEYBINDINGS # KEYBINDINGS
===========
Keybindings: Keybindings:
@ -38,186 +30,178 @@ Keybindings:
: Exit current action : Exit current action
`]` `]`
: Next view - Go to next view : Next view - Go to next view
`[` `[`
: Previous view - Go to previous view : Previous view - Go to previous view
Keybindings for task report: Keybindings for task report:
`/` `/`
: task {string} - Filter task report : task {string} - Filter task report
`a` `a`
: task add {string} - Add new task : task add {string} - Add new task
`d` `d`
: task {selected} done - Mark task as done : task {selected} done - Mark task as done
`e` `e`
: task {selected} edit - Open selected task in editor : task {selected} edit - Open selected task in editor
`j` `j`
: {selected+=1} - Move down in task report : {selected+=1} - Move down in task report
`k` `k`
: {selected-=1} - Move up in task report : {selected-=1} - Move up in task report
`J` `J`
: {selected+=pageheight} - Move page down in task report : {selected+=pageheight} - Move page down in task report
`K` `K`
: {selected-=pageheight} - Move page up in task report : {selected-=pageheight} - Move page up in task report
`g` `g`
: {selected=first} - Go to top : {selected=first} - Go to top
`G` `G`
: {selected=last} - Go to bottom : {selected=last} - Go to bottom
`l` `l`
: task log {string} - Log new task : task log {string} - Log new task
`m` `m`
: task {selected} modify {string} - Modify selected task : task {selected} modify {string} - Modify selected task
`q` `q`
: exit - Quit : exit - Quit
`s` `s`
: task {selected} start/stop - Toggle start and stop : task {selected} start/stop - Toggle start and stop
`n` `n`
: task {selected} +next/-nex - Toggle "next" tag : task {selected} +{tag}/-{tag} - Toggle {uda.taskwarrior-tui.quick-tag.name} (Default: `next`)
`u` `u`
: task undo - Undo : task undo - Undo
`v` `v`
: {toggle mark on selected} - Toggle mark on selected : {toggle mark on selected} - Toggle mark on selected
`V` `V`
: {toggle marks on all tasks} - Toggle marks on all tasks in current filter report : {toggle marks on all tasks} - Toggle marks on all tasks in current filter report
`x` `x`
: task delete {selected} - Delete : task delete {selected} - Delete
`z` `z`
: toggle task info - Toggle task info view : toggle task info - Toggle task info view
`A` `A`
: task {selected} annotate {string} - Annotate current task : task {selected} annotate {string} - Annotate current task
Ctrl-e Ctrl-e
: scroll down task details - Scroll task details view down one line : scroll down task details - Scroll task details view down one line
Ctrl-y Ctrl-y
: scroll up task details - Scroll task details view up one line : scroll up task details - Scroll task details view up one line
`!` `!`
: {string} - Custom shell command : {string} - Custom shell command
`1-9` `1-9`
: {string} - Run user defined shortcuts : {string} - Run user defined shortcuts
`:` `:`
: {task id} - Jump to task id : {task id} - Jump to task id
`c` `c`
: context switcher menu - Open context switcher menu : context switcher menu - Open context switcher menu
`?` `?`
: help - Help menu : help - Help menu
Keybindings for filter / command prompt: Keybindings for filter / command prompt:
`Ctrl + f | Right` `Ctrl + f | Right`
: move forward - Move forward one character : move forward - Move forward one character
`Ctrl + b | Left` `Ctrl + b | Left`
: move backward - Move backward one character : move backward - Move backward one character
`Ctrl + h | Backspace` `Ctrl + h | Backspace`
: backspace - Delete one character back : backspace - Delete one character back
`Ctrl + d | Delete` `Ctrl + d | Delete`
: delete - Delete one character forward : delete - Delete one character forward
`Ctrl + a | Home` `Ctrl + a | Home`
: home - Go to the beginning of line : home - Go to the beginning of line
`Ctrl + e | End` `Ctrl + e | End`
: end - Go to the end of line : end - Go to the end of line
`Ctrl + k` `Ctrl + k`
: delete to end - Delete to the end of line : delete to end - Delete to the end of line
`Ctrl + u` `Ctrl + u`
: delete to beginning - Delete to the beginning of line : delete to beginning - Delete to the beginning of line
`Ctrl + w` `Ctrl + w`
: delete previous word - Delete previous word : delete previous word - Delete previous word
`Alt + d` `Alt + d`
: delete next word - Delete next word : delete next word - Delete next word
`Alt + b` `Alt + b`
: move to previous word - Move to previous word : move to previous word - Move to previous word
`Alt + f` `Alt + f`
: move to next word - Move to next word : move to next word - Move to next word
`Alt + t` `Alt + t`
: transpose words - Transpose words : transpose words - Transpose words
`Up` `Up`
: scroll history - Go backward in history matching from beginning of line to cursor : scroll history - Go backward in history matching from beginning of line to cursor
`Down` `Down`
: scroll history - Go forward in history matching from beginning of line to cursor : scroll history - Go forward in history matching from beginning of line to cursor
`TAB | Ctrl + n` `TAB | Ctrl + n`
: tab complete - Open tab completion and selection first element OR cycle to next element : tab complete - Open tab completion and selection first element OR cycle to next element
`BACKTAB | Ctrl + p` `BACKTAB | Ctrl + p`
: tab complete - Cycle to previous element : tab complete - Cycle to previous element
Keybindings for context switcher: Keybindings for context switcher:
`j` `j`
: {selected+=1} - Move forward a context : {selected+=1} - Move forward a context
`k` `k`
: {selected-=1} - Move back a context : {selected-=1} - Move back a context
Keybindings for calendar: Keybindings for calendar:
`j` `j`
: {selected+=1} - Move forward a year in calendar : {selected+=1} - Move forward a year in calendar
`k` `k`
: {selected-=1} - Move back a year in calendar : {selected-=1} - Move back a year in calendar
`J` `J`
: {selected+=10} - Move forward a decade in calendar : {selected+=10} - Move forward a decade in calendar
`K` `K`
: {selected-=10} - Move back a decade in calendar : {selected-=10} - Move back a decade in calendar
EXIT STATUSES # EXIT STATUSES
=============
0 0
: If everything goes OK. : If everything goes OK.
# AUTHOR
AUTHOR
======
`taskwarrior-tui` is maintained by Dheepak kdheepak Krishnamurthy and other contributors. `taskwarrior-tui` is maintained by Dheepak kdheepak Krishnamurthy and other contributors.

View file

@ -2012,9 +2012,8 @@ impl TaskwarriorTui {
Ok(()) Ok(())
} }
pub fn task_tag_next(&mut self) -> Result<(), String> { pub fn task_quick_tag(&mut self) -> Result<(), String> {
let app = TaskwarriorTui::new("next").unwrap(); let tag_name = &self.config.uda_quick_tag_name;
let tag_name = &self.config.uda_tag_next_name;
let ptag_name = format!("+{}", tag_name); let ptag_name = format!("+{}", tag_name);
let ntag_name = format!("-{}", tag_name); let ntag_name = format!("-{}", tag_name);
if self.tasks.is_empty() { if self.tasks.is_empty() {
@ -2024,7 +2023,7 @@ impl TaskwarriorTui {
let task_uuids = self.selected_task_uuids(); let task_uuids = self.selected_task_uuids();
for task_uuid in &task_uuids { for task_uuid in &task_uuids {
if let Some(task) = app.task_by_uuid(*task_uuid) { if let Some(task) = self.task_by_uuid(*task_uuid) {
let mut tag_to_set = &ptag_name; let mut tag_to_set = &ptag_name;
for tag in task.tags().unwrap() { for tag in task.tags().unwrap() {
if tag == tag_name { if tag == tag_name {
@ -2037,6 +2036,7 @@ impl TaskwarriorTui {
.arg("modify") .arg("modify")
.arg(tag_to_set) .arg(tag_to_set)
.output(); .output();
if output.is_err() { if output.is_err() {
return Err(format!( return Err(format!(
"Error running `task modify {}` for task `{}`.", "Error running `task modify {}` for task `{}`.",
@ -2473,8 +2473,8 @@ impl TaskwarriorTui {
self.error = e; self.error = e;
} }
} }
} else if input == self.keyconfig.tag_next { } else if input == self.keyconfig.quick_tag {
match self.task_tag_next() { match self.task_quick_tag() {
Ok(_) => self.update(true)?, Ok(_) => self.update(true)?,
Err(e) => { Err(e) => {
self.mode = Mode::Tasks(Action::Error); self.mode = Mode::Tasks(Action::Error);

View file

@ -65,7 +65,7 @@ pub struct Config {
pub uda_shortcuts: Vec<String>, pub uda_shortcuts: Vec<String>,
pub uda_background_process: String, pub uda_background_process: String,
pub uda_background_process_period: usize, pub uda_background_process_period: usize,
pub uda_tag_next_name: String, pub uda_quick_tag_name: String,
pub uda_task_report_prompt_on_delete: bool, pub uda_task_report_prompt_on_delete: bool,
pub uda_task_report_prompt_on_done: bool, pub uda_task_report_prompt_on_done: bool,
} }
@ -112,7 +112,7 @@ impl Config {
let uda_style_context_active = uda_style_context_active.unwrap_or_default(); let uda_style_context_active = uda_style_context_active.unwrap_or_default();
let uda_style_report_completion_pane = let uda_style_report_completion_pane =
uda_style_report_completion_pane.unwrap_or_else(|| Style::default().bg(Color::Rgb(223, 223, 223))); uda_style_report_completion_pane.unwrap_or_else(|| Style::default().bg(Color::Rgb(223, 223, 223)));
let uda_tag_next_name = Self::get_uda_tag_next_name(data); let uda_quick_tag_name = Self::get_uda_quick_tag_name(data);
let uda_task_report_prompt_on_delete = Self::get_uda_task_report_prompt_on_delete(data); let uda_task_report_prompt_on_delete = Self::get_uda_task_report_prompt_on_delete(data);
let uda_task_report_prompt_on_done = Self::get_uda_task_report_prompt_on_done(data); let uda_task_report_prompt_on_done = Self::get_uda_task_report_prompt_on_done(data);
@ -147,7 +147,7 @@ impl Config {
uda_shortcuts, uda_shortcuts,
uda_background_process, uda_background_process,
uda_background_process_period, uda_background_process_period,
uda_tag_next_name, uda_quick_tag_name,
uda_task_report_prompt_on_delete, uda_task_report_prompt_on_delete,
uda_task_report_prompt_on_done, uda_task_report_prompt_on_done,
}) })
@ -546,8 +546,8 @@ impl Config {
.unwrap_or(4) .unwrap_or(4)
} }
fn get_uda_tag_next_name(data: &str) -> String { fn get_uda_quick_tag_name(data: &str) -> String {
let tag_name = Self::get_config("uda.taskwarrior-tui.next-tag.name", data); let tag_name = Self::get_config("uda.taskwarrior-tui.quick-tag.name", data);
match tag_name { match tag_name {
None => "next".to_string(), None => "next".to_string(),
Some(tag_name) => tag_name, Some(tag_name) => tag_name,

View file

@ -19,7 +19,7 @@ pub struct KeyConfig {
pub delete: Key, pub delete: Key,
pub done: Key, pub done: Key,
pub start_stop: Key, pub start_stop: Key,
pub tag_next: Key, pub quick_tag: Key,
pub select: Key, pub select: Key,
pub select_all: Key, pub select_all: Key,
pub undo: Key, pub undo: Key,
@ -61,7 +61,7 @@ impl Default for KeyConfig {
delete: Key::Char('x'), delete: Key::Char('x'),
done: Key::Char('d'), done: Key::Char('d'),
start_stop: Key::Char('s'), start_stop: Key::Char('s'),
tag_next: Key::Char('n'), quick_tag: Key::Char('n'),
select: Key::Char('v'), select: Key::Char('v'),
select_all: Key::Char('V'), select_all: Key::Char('V'),
undo: Key::Char('u'), undo: Key::Char('u'),
@ -110,7 +110,7 @@ impl KeyConfig {
let delete = Self::get_config("uda.taskwarrior-tui.keyconfig.delete", data); let delete = Self::get_config("uda.taskwarrior-tui.keyconfig.delete", data);
let done = Self::get_config("uda.taskwarrior-tui.keyconfig.done", data); let done = Self::get_config("uda.taskwarrior-tui.keyconfig.done", data);
let start_stop = Self::get_config("uda.taskwarrior-tui.keyconfig.start-stop", data); let start_stop = Self::get_config("uda.taskwarrior-tui.keyconfig.start-stop", data);
let tag_next = Self::get_config("uda.taskwarrior-tui.keyconfig.tag-next", data); let quick_tag = Self::get_config("uda.taskwarrior-tui.keyconfig.quick-tag", data);
let select = Self::get_config("uda.taskwarrior-tui.keyconfig.select", data); let select = Self::get_config("uda.taskwarrior-tui.keyconfig.select", data);
let select_all = Self::get_config("uda.taskwarrior-tui.keyconfig.select-all", data); let select_all = Self::get_config("uda.taskwarrior-tui.keyconfig.select-all", data);
let undo = Self::get_config("uda.taskwarrior-tui.keyconfig.undo", data); let undo = Self::get_config("uda.taskwarrior-tui.keyconfig.undo", data);
@ -137,7 +137,7 @@ impl KeyConfig {
self.delete = delete.unwrap_or(self.delete); self.delete = delete.unwrap_or(self.delete);
self.done = done.unwrap_or(self.done); self.done = done.unwrap_or(self.done);
self.start_stop = start_stop.unwrap_or(self.start_stop); self.start_stop = start_stop.unwrap_or(self.start_stop);
self.tag_next = tag_next.unwrap_or(self.tag_next); self.quick_tag = quick_tag.unwrap_or(self.quick_tag);
self.select = select.unwrap_or(self.select); self.select = select.unwrap_or(self.select);
self.select_all = select_all.unwrap_or(self.select_all); self.select_all = select_all.unwrap_or(self.select_all);
self.undo = undo.unwrap_or(self.undo); self.undo = undo.unwrap_or(self.undo);
@ -171,7 +171,7 @@ impl KeyConfig {
&self.select, &self.select,
&self.select_all, &self.select_all,
&self.start_stop, &self.start_stop,
&self.tag_next, &self.quick_tag,
&self.undo, &self.undo,
&self.edit, &self.edit,
&self.modify, &self.modify,