aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2023-04-19 00:09:23 +0100
committerdam <dam@gudinoff>2023-04-19 00:09:23 +0100
commit68be730ffb762e2a0d796fc57d6039ad75cd010e (patch)
tree42320d7329b35c0f90ba4f8d782d980252a27236
parentadff8aaceb63d3e679f0f5cd4c5f93146ad8f012 (diff)
downloadtask-time-tracker-68be730ffb762e2a0d796fc57d6039ad75cd010e.tar.zst
task-time-tracker-68be730ffb762e2a0d796fc57d6039ad75cd010e.zip
Implemented action to backup and reset all tasks.
-rw-r--r--ttt.jai17
1 files changed, 17 insertions, 0 deletions
diff --git a/ttt.jai b/ttt.jai
index 3822d72..df02123 100644
--- a/ttt.jai
+++ b/ttt.jai
@@ -1158,6 +1158,8 @@ read_enter_confirmation :: (row: int, style: int, message: string) -> bool {
main :: () {
+ // TODO Implement signal handling and see modules/Debug.jai for examples.
+
defer report_memory_leaks(); // TODO Remove after final debug sessions.
defer free_memory();
@@ -1227,6 +1229,7 @@ main :: () {
" m, M Move selected task to position.\n",
" g, G Select task by position.\n",
" q, Q Save changes and exit.\n",
+ " w, W Archive duplicates and reset all tasks.\n", // TODO Improve message.
" F2 Rename selected task.\n",
" F5 Recalculate total times.\n",
" TAB Toggle archive view.\n",
@@ -1601,6 +1604,19 @@ main :: () {
delete_task(db, db.selected_idx);
trigger_autosave();
+ 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.
+ for db.tasks {
+ if (append_to_csv(it, ar_file_path) == false) {
+ print_error("Failed to archive entry."); // TODO Improve this.
+ }
+ reset_task_times(db, it_index);
+ }
+ trigger_autosave();
+ }
+
case KEY_HOME;
select_task(db, 0);
@@ -1644,5 +1660,6 @@ main :: () {
}
endwin();
+
exit(xx ifx error_saving then 1 else 0);
}