aboutsummaryrefslogtreecommitdiff
path: root/ttt.jai
diff options
context:
space:
mode:
Diffstat (limited to 'ttt.jai')
-rw-r--r--ttt.jai38
1 files changed, 19 insertions, 19 deletions
diff --git a/ttt.jai b/ttt.jai
index d8233f9..7d1559b 100644
--- a/ttt.jai
+++ b/ttt.jai
@@ -719,8 +719,8 @@ import_from_csv :: (db: *Database, path: string) -> bool {
csv_values := split(line, ",",, temporary_allocator);
// Truncate and import task name.
- truncate(*csv_values[0], task.name.count);
- memcpy(task.name.data, csv_values[0].data, csv_values[0].count);
+ task_name := truncate(csv_values[0], task.name.count);
+ memcpy(task.name.data, task_name.data, task_name.count);
advance(*csv_values);
for csv_values
@@ -901,11 +901,11 @@ draw_user_interface :: (db: *Database, layout: *Layout) {
start := current_time_monotonic(); // DEBUG
-
-
-
- // TODO During dirty_flag revamp...we may also start using the String_Builder.
-
+ auto_release_temp();
+
+ empty_line := talloc_string(size_x);
+ memset(empty_line.data, #char " ", size_x);
+
adjust_first_day_of_week := int.[
(0 + FIRST_DAY_OF_WEEK) % NUM_WEEK_DAYS,
(1 + FIRST_DAY_OF_WEEK) % NUM_WEEK_DAYS,
@@ -1004,6 +1004,7 @@ draw_user_interface :: (db: *Database, layout: *Layout) {
idx_start := (db.selected_idx / layout_tasks_rows) * layout_tasks_rows;
// Display up to rows allowed by the layout, or less if reached end of database.
idx_stop := idx_start + (ifx layout_tasks_rows > db.tasks.count - idx_start then db.tasks.count - idx_start else layout_tasks_rows);
+
for task_idx: idx_start..idx_stop-1 {
task := *db.tasks[task_idx];
y += 1;
@@ -1026,19 +1027,18 @@ draw_user_interface :: (db: *Database, layout: *Layout) {
// Task title.
x += 1;
column_width = layout.columns[L_TITLE_IDX].width;
- // mvprintw(xx y, xx x, "%-*.*s", column_width, column_width, temp_c_string(xx task.name)); //task.name); TODO Fix required for LLVM/Cncurses. TODO DAM
- // TODO FIXME OH MY GOD SUCH BAD CODEZ
+ // Print title.
+ // When the column is wider than the name, we end up with the trailing zeros.
+ // Thankfully, the trailing zeros are not printed so, it's all good.
+ task_name := cast(string)task.name;
+ task_name = truncate(task_name, column_width);
TUI.set_cursor_position(x, y);
- white_spaces := column_width;
- // FIXME Improve by using buffer instead of printing one char at the time.
- while white_spaces > 0 {
- print_character(#char " ");
- white_spaces -= 1;
- }
- TUI.set_cursor_position(x, y);
- task_name: string = cast(string)task.name;
- task_name.count = ifx task_name.count > column_width then column_width else task_name.count;
- print("%", task_name);
+ write_string(task_name);
+ // Paint the remaining column space.
+ task_name_char_count := count_characters(task_name, is_null_terminated = true);
+ paint_remaining := string.{ column_width - task_name_char_count, empty_line.data };
+ write_string(paint_remaining);
+
x += column_width;
// Task times.