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`).
```plaintext
uda.taskwarrior-tui.keyconfig.quit=q
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.done=d
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.edit=e
uda.taskwarrior-tui.keyconfig.modify=m

View file

@ -4,23 +4,17 @@
<!-- To generate the roff version, run `just man`, -->
<!-- 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)
SYNOPSIS
========
# SYNOPSIS
`taskwarrior-tui`
**`taskwarrior-tui`** is a terminal user interface for `taskwarrior`.
EXAMPLES
========
# EXAMPLES
`taskwarrior-tui`
: Starts a terminal user interface for `taskwarrior`.
@ -28,9 +22,7 @@ EXAMPLES
`alias tt=taskwarrior-tui`
: Add the above to your dotfiles to use `tt` to start `taskwarrior-tui`.
KEYBINDINGS
===========
# KEYBINDINGS
Keybindings:
@ -38,186 +30,178 @@ Keybindings:
: 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:
`/`
: task {string} - Filter task report
: task {string} - Filter task report
`a`
: task add {string} - Add new task
: task add {string} - Add new task
`d`
: task {selected} done - Mark task as done
: task {selected} done - Mark task as done
`e`
: task {selected} edit - Open selected task in editor
: task {selected} edit - Open selected task in editor
`j`
: {selected+=1} - Move down in task report
: {selected+=1} - Move down in task report
`k`
: {selected-=1} - Move up in task report
: {selected-=1} - Move up in task report
`J`
: {selected+=pageheight} - Move page down in task report
: {selected+=pageheight} - Move page down in task report
`K`
: {selected-=pageheight} - Move page up in task report
: {selected-=pageheight} - Move page up in task report
`g`
: {selected=first} - Go to top
: {selected=first} - Go to top
`G`
: {selected=last} - Go to bottom
: {selected=last} - Go to bottom
`l`
: task log {string} - Log new task
: task log {string} - Log new task
`m`
: task {selected} modify {string} - Modify selected task
: task {selected} modify {string} - Modify selected task
`q`
: exit - Quit
: exit - Quit
`s`
: task {selected} start/stop - Toggle start and stop
: task {selected} start/stop - Toggle start and stop
`n`
: task {selected} +next/-nex - Toggle "next" tag
: task {selected} +{tag}/-{tag} - Toggle {uda.taskwarrior-tui.quick-tag.name} (Default: `next`)
`u`
: task undo - Undo
: task undo - Undo
`v`
: {toggle mark on selected} - Toggle mark on selected
: {toggle mark on selected} - Toggle mark on selected
`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`
: task delete {selected} - Delete
: task delete {selected} - Delete
`z`
: toggle task info - Toggle task info view
: toggle task info - Toggle task info view
`A`
: task {selected} annotate {string} - Annotate current task
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
: 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`
: {string} - Run user defined shortcuts
: {string} - Run user defined shortcuts
`:`
: {task id} - Jump to task id
: {task id} - Jump to task id
`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:
`Ctrl + f | Right`
: move forward - Move forward one character
: move forward - Move forward one character
`Ctrl + b | Left`
: move backward - Move backward one character
: move backward - Move backward one character
`Ctrl + h | Backspace`
: backspace - Delete one character back
: backspace - Delete one character back
`Ctrl + d | Delete`
: delete - Delete one character forward
: delete - Delete one character forward
`Ctrl + a | Home`
: home - Go to the beginning of line
: home - Go to the beginning of line
`Ctrl + e | End`
: end - Go to the end of line
: end - Go to the end of line
`Ctrl + k`
: delete to end - Delete to the end of line
: delete to end - Delete to the end of line
`Ctrl + u`
: delete to beginning - Delete to the beginning of line
: delete to beginning - Delete to the beginning of line
`Ctrl + w`
: delete previous word - Delete previous word
: delete previous word - Delete previous word
`Alt + d`
: delete next word - Delete next word
: delete next word - Delete next word
`Alt + b`
: move to previous word - Move to previous word
: move to previous word - Move to previous word
`Alt + f`
: move to next word - Move to next word
: move to next word - Move to next word
`Alt + t`
: transpose words - Transpose words
: transpose words - Transpose words
`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`
: 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 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`
: tab complete - Cycle to previous element
: tab complete - Cycle to previous element
Keybindings for context switcher:
`j`
: {selected+=1} - Move forward a context
: {selected+=1} - Move forward a context
`k`
: {selected-=1} - Move back a context
: {selected-=1} - Move back a context
Keybindings for calendar:
`j`
: {selected+=1} - Move forward a year in calendar
: {selected+=1} - Move forward a year in calendar
`k`
: {selected-=1} - Move back a year in calendar
: {selected-=1} - Move back a year in calendar
`J`
: {selected+=10} - Move forward a decade in calendar
: {selected+=10} - Move forward a decade in calendar
`K`
: {selected-=10} - Move back a decade in calendar
: {selected-=10} - Move back a decade in calendar
EXIT STATUSES
=============
# EXIT STATUSES
0
: If everything goes OK.
AUTHOR
======
# AUTHOR
`taskwarrior-tui` is maintained by Dheepak kdheepak Krishnamurthy and other contributors.

View file

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

View file

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

View file

@ -19,7 +19,7 @@ pub struct KeyConfig {
pub delete: Key,
pub done: Key,
pub start_stop: Key,
pub tag_next: Key,
pub quick_tag: Key,
pub select: Key,
pub select_all: Key,
pub undo: Key,
@ -61,7 +61,7 @@ impl Default for KeyConfig {
delete: Key::Char('x'),
done: Key::Char('d'),
start_stop: Key::Char('s'),
tag_next: Key::Char('n'),
quick_tag: Key::Char('n'),
select: Key::Char('v'),
select_all: Key::Char('V'),
undo: Key::Char('u'),
@ -110,7 +110,7 @@ impl KeyConfig {
let delete = Self::get_config("uda.taskwarrior-tui.keyconfig.delete", 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 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_all = Self::get_config("uda.taskwarrior-tui.keyconfig.select-all", 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.done = done.unwrap_or(self.done);
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_all = select_all.unwrap_or(self.select_all);
self.undo = undo.unwrap_or(self.undo);
@ -171,7 +171,7 @@ impl KeyConfig {
&self.select,
&self.select_all,
&self.start_stop,
&self.tag_next,
&self.quick_tag,
&self.undo,
&self.edit,
&self.modify,