From 5a6e67d6be44e168d690d262935d5affade37fc6 Mon Sep 17 00:00:00 2001 From: dam Date: Fri, 7 Apr 2023 01:27:07 +0100 Subject: Ported reset task time feature. --- ttt.jai | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'ttt.jai') diff --git a/ttt.jai b/ttt.jai index ee0b344..533140b 100644 --- a/ttt.jai +++ b/ttt.jai @@ -587,24 +587,22 @@ update_total_times :: (db: *Database) { totals[6] = add_int64(totals[6], times[6]); } } -/* + // Resets the times of the provided task (and adjusts database totals). -void reset_task_times(database_st *db, task_st *task) { - assert(db != NULL); - assert(task != NULL); - assert(task >= db->tasks && task - db->tasks < db->count); +reset_task_times :: (db: *Database, task: *Task) { + assert(db != null); + assert(task != null); + assert(task >= db.tasks.data && task - db.tasks.data < db.tasks.count); // Make sure we sync before applying the changes. update_times(db); - for (int idx = 0; idx < NUM_WEEK_DAYS; idx++) { - int64_t *timer = &task->times[idx]; - int64_t *total = &db->total_times[idx]; - *total = sub_int64(*total, *timer); - *timer = 0; + for * task.times { + db.total_times[it_index] = sub_int64(db.total_times[it_index], < bool { + assert(message.data != null); - attron(style); - move(row, 1); - for (int idx = 0; idx < size_x - 2; idx++) { + attron(xx style); + move(xx row, 1); + for 0..size_x-3 { + //for (int idx = 0; idx < size_x - 2; idx++) { addch(ACS_CKBOARD); } - mvaddstr(row, 2, message); + mvaddstr(xx row, 2, message.data); attrset(A_NORMAL); - return getch() == '\n'; + return getch() == #char "\n"; } -*/ + main :: () { @@ -1572,19 +1571,15 @@ main :: () { } break; } - - case KEY_BACKSPACE: { - if (selected_task == NULL) { - break; - } + */ + case KEY_BACKSPACE; + if (selected_task == null) break; // BUG if (read_enter_confirmation(selected_task_row, action_style, " Press enter to reset task. ") == true) { reset_task_times(db, selected_task); trigger_autosave(); } - break; - } - + /* case KEY_DC: { // Delete if (selected_task == NULL || selected_task == active_task) { break; -- cgit v1.2.3