From 6dd12d2c8b81cd5719fb0ecdcbf678e08460fbeb Mon Sep 17 00:00:00 2001 From: dam Date: Mon, 1 Jan 2024 18:42:24 +0000 Subject: Fixed bug that was clamping terminal sequences to 6 bytes. Added style formatting. --- ttt.jai | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) (limited to 'ttt.jai') diff --git a/ttt.jai b/ttt.jai index b5dca56..2e5af82 100644 --- a/ttt.jai +++ b/ttt.jai @@ -392,7 +392,7 @@ delete_task :: (using db: *Database, index: s64) -> bool { // TODO Maybe use `us size_of_task := size_of(Task); if (tasks.allocated >> 2) > tasks.count && tasks.allocated * size_of_task > 2_000_000 { new_capacity := tasks.allocated >> 1; - new_tasks_data := realloc(tasks.data, new_capacity * size_of_task, tasks.allocated * size_of_task, tasks.allocator); + new_tasks_data := realloc(tasks.data, new_capacity * size_of_task, tasks.allocated * size_of_task,, tasks.allocator); if new_tasks_data != null { tasks.data = new_tasks_data; tasks.allocated = new_capacity; @@ -713,7 +713,7 @@ import_from_csv :: (db: *Database, path: string) -> bool { // Thus this works on both 'dos' and 'unix'-style files. s := << sp; - found, result, right := split_from_left(s, 10); + found, result, right := split_from_left(s, 10,, temporary_allocator); if !found { // This is the last line; there may not have been a linefeed after that, @@ -761,7 +761,7 @@ import_from_csv :: (db: *Database, path: string) -> bool { if success == false break; task: Task; - csv_values := split(line, ","); // TODO Temporary memory... if file is too big this may break. + csv_values := split(line, ",",, temporary_allocator); // TODO Temporary memory... if file is too big this may break. // Import task name. name_length := min(task.name.count, csv_values[0].count); @@ -1069,11 +1069,16 @@ draw_tui :: (db: *Database, layout: *Layout) { // Apply theme. if (task == active_task && task == selected_task) { // attron(COLOR_PAIR(xx Styles.ACTIVE_SELECTED) | A_BOLD); TODO DAM + TUI.set_style_colors(TUI.Colors8b.Red, 6); // TODO TESTING COLORS + TUI.set_style(true, true, true, false); } else if (task == selected_task) { // attron(COLOR_PAIR(xx Styles.SELECTED)); TODO DAM + TUI.set_style_colors(4, 6); // TODO TESTING COLORS } else if (task == active_task) { + TUI.set_style_colors(TUI.Colors8b.Red, 6); // TODO TESTING COLORS + TUI.set_style(false, false, false, true); // TODO TESTING STYLE // attron(COLOR_PAIR(xx Styles.ACTIVE) | A_BOLD); TODO DAM } @@ -1081,16 +1086,18 @@ draw_tui :: (db: *Database, layout: *Layout) { 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 - TUI.set_cursor_position(y, x); // TODO FIXME OH MY GOD SUCH BAD CODEZ + TUI.set_cursor_position(y, x); + 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(y, x); 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); - diff := column_width - task_name.count; - while diff > 0 { - diff -= 1; - print_character(#char " "); - } x += column_width; // Task times. @@ -1111,6 +1118,7 @@ draw_tui :: (db: *Database, layout: *Layout) { // Reset theme. //attrset(A_NORMAL); TODO DAM + TUI.clear_style(); } @@ -1302,7 +1310,7 @@ main :: () { last_none_char := "X"; drop_down := 0; while(key != #char "q") { - // __mark := get_temporary_storage_mark(); + __mark := get_temporary_storage_mark(); if key == { case TUI.Keys.None; { @@ -1316,16 +1324,27 @@ main :: () { TUI.clear_terminal(); drop_down = 0; } + + case TUI.Keys.MetaF7; { + TUI.set_cursor_position(3+drop_down, 2); + drop_down += 1; + write_string("META F7"); + } case; { TUI.set_cursor_position(3+drop_down, 2); str := TUI.to_string(key); + for 0..str.count-1 { + print("'%'", FormatInt.{value = cast(u8)str[it], base=16}); + } + write_string(":> "); for 0..str.count-1 { if str[it] == #char "\e" { str[it] = #char "?"; } } write_string(str); + write_string("