Add select all option

This commit is contained in:
Dheepak Krishnamurthy 2021-03-23 23:42:49 -06:00
parent b6945ec785
commit 2061d0e914
2 changed files with 17 additions and 0 deletions

View file

@ -1646,6 +1646,14 @@ impl TTApp {
}
}
pub fn toggle_mark_all(&mut self) {
for task in &*self.tasks.lock().unwrap() {
if !self.marked.insert(*task.uuid()) {
self.marked.remove(task.uuid());
}
}
}
pub fn handle_input(
&mut self,
input: Key,
@ -1662,6 +1670,9 @@ impl TTApp {
} else if input == self.keyconfig.select {
self.task_table_state.multiple_selection();
self.toggle_mark();
} else if input == self.keyconfig.select_all {
self.task_table_state.multiple_selection();
self.toggle_mark_all();
} else if input == self.keyconfig.refresh {
self.update(true)?;
} else if input == self.keyconfig.go_to_bottom || input == Key::End {

View file

@ -19,6 +19,7 @@ pub struct KeyConfig {
pub done: Key,
pub start_stop: Key,
pub select: Key,
pub select_all: Key,
pub undo: Key,
pub edit: Key,
pub modify: Key,
@ -59,6 +60,7 @@ impl Default for KeyConfig {
done: Key::Char('d'),
start_stop: Key::Char('s'),
select: Key::Char('v'),
select_all: Key::Char('V'),
undo: Key::Char('u'),
edit: Key::Char('e'),
modify: Key::Char('m'),
@ -122,6 +124,9 @@ impl KeyConfig {
self.select = self
.get_config("uda.taskwarrior-tui.keyconfig.select")
.unwrap_or(self.select);
self.select_all = self
.get_config("uda.taskwarrior-tui.keyconfig.select-all")
.unwrap_or(self.select_all);
self.undo = self
.get_config("uda.taskwarrior-tui.keyconfig.undo")
.unwrap_or(self.undo);
@ -170,6 +175,7 @@ impl KeyConfig {
&self.delete,
&self.done,
&self.select,
&self.select_all,
&self.start_stop,
&self.undo,
&self.edit,