diff options
| author | dam <dam@gudinoff> | 2023-04-06 16:00:06 +0100 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2023-04-06 16:00:06 +0100 |
| commit | f0c4c2e5b453403c367528c7425f8cc0954ab924 (patch) | |
| tree | b81a0dbaf0ae1e51c25475b8753dd4ad2f587665 /ttt.jai | |
| parent | 2c18a63dad5a0d931f8ebeef711bfbb1d289a755 (diff) | |
| download | task-time-tracker-f0c4c2e5b453403c367528c7425f8cc0954ab924.tar.zst task-time-tracker-f0c4c2e5b453403c367528c7425f8cc0954ab924.zip | |
Draw selected/total tasks and daily totals.
Diffstat (limited to 'ttt.jai')
| -rw-r--r-- | ttt.jai | 42 |
1 files changed, 24 insertions, 18 deletions
@@ -179,6 +179,12 @@ Text_Encoding :: enum u8 #specified { UTF8 :: 2; } +// TODO Provide good description. +number_size :: (number: s64, base: s64 = 10) -> s64 { + if number == 0 return 1; + return cast(s64)floor(log(cast(float64)abs(number))/log(cast(float64)abs(base))) + 1; // TODO So many casts. +} + // WIP TODO Ues compiler time code to see the auto bake being used... just for fun, once! :D truncate_string :: (str: string, length: s64, $encoding: Text_Encoding = .UTF8) -> length: s64 #no_abc { // TODO Should I use #no_abc ? assert(str.data != null); @@ -1177,46 +1183,46 @@ draw_tui :: (db: *Database, layout: *Layout) { attrset(A_NORMAL); } - return; /* + /////////////////////////////////////////////////////////////////////////// // Draw selected/total tasks. - int size = snprintf(NULL, 0, " %td/%zd ", db->selected_task + 1, db->count); - if (size <= layout->columns[L_TITLE_IDX].width) { - mvprintw(size_y - 1, 1, " %td/%zd ", db->selected_task + 1, db->count); + size := 1 + number_size(db.selected_idx + 1) + 1 + number_size(db.tasks.count) + 1; // " XXX/YYY " + if (size <= layout.columns[L_TITLE_IDX].width) { + mvprintw(size_y - 1, 1, " %td/%zd ", db.selected_idx + 1, db.tasks.count); } else { - mvprintw(size_y - 1, 1, "%td", db->selected_task + 1); + mvprintw(size_y - 1, 1, "%td", db.selected_idx + 1); } + /////////////////////////////////////////////////////////////////////////// // Draw daily totals. y = size_y - 1; - x = 0 + 1 + layout->columns[L_TITLE_IDX].width; + x = 0 + 1 + layout.columns[L_TITLE_IDX].width; total_time = 0; - for (int raw_idx = 0; raw_idx < NUM_WEEK_DAYS; raw_idx++) { - int idx = adjust_first_day_of_week[raw_idx]; - int64_t daily_total = db->total_times[idx]; - x++; + for 0..NUM_WEEK_DAYS-1 { + idx := adjust_first_day_of_week[it]; + daily_total := db.total_times[idx]; + x += 1; // Apply theme. - if (idx == now_week_day && active_task != NULL) { - attron(COLOR_PAIR(STYLE_ACTIVE) | A_BOLD); + if (idx == now_week_day && active_task != null) { + attron(COLOR_PAIR(xx Styles.ACTIVE) | A_BOLD); } else if (idx == now_week_day) { - attron(COLOR_PAIR(SELECTED_INVERTED) | A_BOLD); + attron(COLOR_PAIR(xx Styles.SELECTED_INVERTED) | A_BOLD); } - column_width = layout->columns[L_DAYS_IDX + idx].width; + column_width = layout.columns[L_DAYS_IDX + idx].width; total_time = add_int64(total_time, daily_total); - mvprintw_time(y, x, daily_total, column_width); + mvprintw_time(xx y, xx x, daily_total, xx column_width); x += column_width; // Reset theme. attrset(A_NORMAL); } - x++; - mvprintw_time(y, x, total_time, layout->columns[L_TOTAL_IDX].width); - */ + x += 1; + mvprintw_time(xx y, xx x, total_time, xx layout.columns[L_TOTAL_IDX].width); } /* void *mem_alloc(size_t mem_size, const char *error_tag) { |
