diff options
Diffstat (limited to 'ttt.jai')
| -rw-r--r-- | ttt.jai | 47 |
1 files changed, 34 insertions, 13 deletions
@@ -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(" <EOL"); drop_down += 1; } } @@ -1337,6 +1356,8 @@ main :: () { print("size(CxR): %x%\n", size_c, size_r); key = TUI.get_key(3000); + + set_temporary_storage_mark(__mark); } TUI.stop(); print("size(CxR): %x%\n", xcolumns, xrows); @@ -1757,14 +1778,14 @@ main :: () { if (active_task == null) continue; select_task(db, db.active_idx); - case #char "\n"; #through; - case #char " "; + case TUI.Keys.Enter; #through; + case TUI.Keys.Space; if (db != *database || selected_task == null) continue; set_active_task(db, ifx db.active_idx == db.selected_idx then -1 else db.selected_idx); active_task = get_active_task(db); trigger_autosave(); - case #char "\t"; + case TUI.Keys.Tab; if (db == *database) { if (import_from_csv(*archive, ar_file_path) == false) { reset_database(*archive); |
