diff options
| author | dam <dam@gudinoff> | 2023-04-07 01:27:07 +0100 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2023-04-07 01:27:07 +0100 |
| commit | 5a6e67d6be44e168d690d262935d5affade37fc6 (patch) | |
| tree | 4b0975043ec2a33fa026feabb0c4d05844258943 /ttt.jai | |
| parent | 6d9b7b4f2d59330c3910f5cad5500ec880aef935 (diff) | |
| download | task-time-tracker-5a6e67d6be44e168d690d262935d5affade37fc6.tar.zst task-time-tracker-5a6e67d6be44e168d690d262935d5affade37fc6.zip | |
Ported reset task time feature.
Diffstat (limited to 'ttt.jai')
| -rw-r--r-- | ttt.jai | 51 |
1 files changed, 23 insertions, 28 deletions
@@ -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], <<it); + <<it = 0; } } - +/* // Sets the time on the day and task provided (and adjusts database totals). void set_task_time(database_st *db, task_st *task, int day, int64_t time) { assert(db != NULL); @@ -1286,22 +1284,23 @@ bool read_input_to_int(int row, int style, const char *message, intmax_t *result return success; } - +*/ // Retuns true if user presses enter, false otherwise. -bool read_enter_confirmation(int row, int style, const char *message) { - assert(message != NULL); +read_enter_confirmation :: (row: int, style: int, message: string) -> 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; |
