diff options
Diffstat (limited to 'ttt.jai')
| -rw-r--r-- | ttt.jai | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -1234,6 +1234,7 @@ main :: () { " r, R Restore selected task from archive.\n", " t, T Select currently active task (if any).\n", " d, D Duplicate selected task.\n", + " c, C Coalesce similar tasks.\n", " n, N Create new task.\n", " m, M Move selected task to position.\n", " g, G Select task by position.\n", @@ -1698,7 +1699,7 @@ main :: () { case #char "w"; #through; case #char "W"; if (db != *database || db.tasks.count <= 0) continue; - if (read_enter_confirmation(selected_task_row, action_style, " Press enter to archive duplicates and reset all. ") == true) { // TODO Improve message. + if (read_enter_confirmation(selected_task_row, action_style, " Press enter to archive duplicates and reset all. ") == true) { for db.tasks { if (append_to_csv(it, ar_file_path) == false) { print_error("Failed to archive entry."); // TODO Improve this. @@ -1707,6 +1708,33 @@ main :: () { } trigger_autosave(); } + + // Coalesce similar entries. + case #char "c"; #through; + case #char "C"; + if (db.tasks.count <= 0) continue; + if (read_enter_confirmation(selected_task_row, action_style, " Press enter to coalesce similar tasks. ") == true) { + // TODO Coalesce stuff. + print_error(" REQUIRES CODE CLEANUP AND TESTING "); + tasks_to_process := db.tasks.count - 1; + idx := 0; + while tasks_to_process > 0 { + task := *db.tasks[idx]; + for < i : db.tasks.count-1..idx+1 { + if compare_strings(xx task.name, xx db.tasks[i].name) == 0 { + for item, index: db.tasks[i].times { + task.times[index] = add(task.times[index], item); + } + delete_task(db, i); + tasks_to_process -= 1; + } + } + + idx += 1; + tasks_to_process -= 1; + } + trigger_autosave(); + } case KEY_HOME; select_task(db, 0); |
