diff options
Diffstat (limited to 'ttt.jai')
| -rw-r--r-- | ttt.jai | 39 |
1 files changed, 24 insertions, 15 deletions
@@ -21,13 +21,9 @@ #import "System"; #import "Sort"; #import "Math"; -// #import "POSIX"; #import "File"; #import "File_Utilities"; #import "String"; -// #import "curses"; -// #import "kscurses"; -TIO :: #import "tio"; // TODO Move things into TUI. TUI :: #import "TUI"; #load "Integer_Saturating_Arithmetic.jai"; @@ -991,17 +987,22 @@ draw_tui :: (db: *Database, layout: *Layout) { // Draw table grids. // TODO Maybe this could be simplified? - y = 0; - x = 0; + y = 1; + x = 1; + write_string(TUI.Commands.StartDrawingMode); for 0..layout.columns.count-2 { column := layout.columns[it]; x += 1 + column.width; - //mvaddch(xx y, xx x, ACS_TTEE); TODO DAM - for row: 1..size_y-1 { - //mvaddch(xx row, xx x, ACS_VLINE); TODO DAM + TUI.set_cursor_position(y, x); + write_string(TUI.Drawings.TeeT); + for row: 2..size_y { + TUI.set_cursor_position(row, x); + write_string(TUI.Drawings.LineV); } - //mvaddch(size_y-1, xx x, ACS_BTEE); TODO DAM + TUI.set_cursor_position(size_y, x); + write_string(TUI.Drawings.TeeB); } + write_string(TUI.Commands.StartNormalMode); /////////////////////////////////////////////////////////////////////////// @@ -1081,7 +1082,15 @@ draw_tui :: (db: *Database, layout: *Layout) { 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); - print("%", cast(string)task.name); // TODO Needs adjustment to fit column width. + // TODO FIXME OH MY GOD SUCH BAD CODEZ + 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. @@ -1120,7 +1129,7 @@ draw_tui :: (db: *Database, layout: *Layout) { /////////////////////////////////////////////////////////////////////////// // Draw daily totals. y = size_y; - x = 0 + 1 + layout.columns[L_TITLE_IDX].width; + x = 1 + 1 + layout.columns[L_TITLE_IDX].width; total_time = 0; for 0..NUM_WEEK_DAYS-1 { idx := adjust_first_day_of_week[it]; @@ -1526,7 +1535,8 @@ main :: () { if (is_terminal_too_small) { INVALID_WINDOW_MESSAGE :: "Terminal is too small: minimum 60x3."; - //mvaddstr(size_y / 2, (size_x - xx INVALID_WINDOW_MESSAGE.count) / 2, INVALID_WINDOW_MESSAGE); TODO DAM + TUI.set_cursor_position(size_y / 2, (size_x - INVALID_WINDOW_MESSAGE.count) / 2); + write_strings(INVALID_WINDOW_MESSAGE); } else { draw_tui(db, layout); @@ -1574,11 +1584,10 @@ main :: () { // When terminal is resized. case TUI.Keys.Resize; TUI.clear_terminal(); - //getmaxyx(stdscr, *size_y, *size_x); _y, _x := TUI.get_terminal_size(); + // TODO FIX ME size_y = xx _y; size_x = xx _x; - print("resize:%x%", size_x, size_y); is_terminal_too_small = size_x < 60 || size_y < 3; update_layout(); layout = *layouts[ifx size_x > 100 then Layouts.NORMAL else Layouts.COMPACT]; |
