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 | |
| parent | 6d9b7b4f2d59330c3910f5cad5500ec880aef935 (diff) | |
| download | task-time-tracker-5a6e67d6be44e168d690d262935d5affade37fc6.tar.zst task-time-tracker-5a6e67d6be44e168d690d262935d5affade37fc6.zip | |
Ported reset task time feature.
| -rw-r--r-- | curses.jai | 2 | ||||
| -rw-r--r-- | ttt.jai | 51 |
2 files changed, 25 insertions, 28 deletions
@@ -102,9 +102,11 @@ noecho :: () -> s32 #foreign ncurses box :: (win: *WINDOW, verch: u8, horch: u8) -> s32 #foreign ncurses; init_pair :: (pair: s16, f: s16, b: s16) -> s32 #foreign ncurses; timeout :: (delay: s32) -> void #foreign ncurses; +addch :: (ch: u32) -> s32 #foreign ncurses; mvaddch :: (y: s32, x: s32, ch: u32) -> s32 #foreign ncurses; clear :: () -> s32 #foreign ncurses; refresh :: () -> s32 #foreign ncurses; +move :: (y: s32, x: s32) -> s32 #foreign ncurses; getmaxyx :: inline (win: *WINDOW, y: *s32, x: *s32) { <<y = getmaxy(win); <<x = getmaxx(win); } getmaxx :: inline (win: *WINDOW) -> s32 { return ifx win == null then ERR else win._maxx + 1; } @@ -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; |
