diff options
| author | dam <dam@gudinoff> | 2023-08-29 09:21:24 +0100 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2023-08-29 09:21:24 +0100 |
| commit | 76f3be800b9306a0a63c9f888b5e61c27ea35c0e (patch) | |
| tree | 9c2aeb28895acd9751b60622a121db49027e2a5b /ttt.jai | |
| parent | 9ea152093b2eb2c3704cc7fbaa9e6cc5ae3d80f8 (diff) | |
| download | task-time-tracker-76f3be800b9306a0a63c9f888b5e61c27ea35c0e.tar.zst task-time-tracker-76f3be800b9306a0a63c9f888b5e61c27ea35c0e.zip | |
Attempting to replace ncurses.
Diffstat (limited to 'ttt.jai')
| -rw-r--r-- | ttt.jai | 40 |
1 files changed, 22 insertions, 18 deletions
@@ -25,9 +25,9 @@ #import "File"; #import "File_Utilities"; #import "String"; -//#import "curses"; +// #import "curses"; // #import "kscurses"; -TIO :: #import "tio"; +TUI :: #import "tio"; // TODO Rename module to "tui.jai" #load "Integer_Saturating_Arithmetic.jai"; @@ -36,7 +36,6 @@ TIO :: #import "tio"; stdscr: *void; // TODO DAM A_BOLD: s32 = 0; // TODO DAM COLOR_PAIR :: (a: s32) -> s32 { return 0; } // TODO DAM -ERR :: -1; // TODO DAM KEY_RESIZE :: 410; // TODO DAM KEY_F2 :: 266; // TODO DAM KEY_F5 :: 269; // TODO DAM @@ -902,13 +901,12 @@ initialize_tui :: () { } // TODO DAM - TIO.initialize(); - TIO.terminate(); // TODO DAM - //stdscr = initscr(); // Start curses mode. TODO DAM - //cbreak(); // Line buffering disabled; pass on everty thing to me. TODO DAM - //keypad(stdscr, true); // I need those nifty F1..F12. TODO DAM - //curs_set(0); // Set cursor invisible. TODO DAM - //noecho(); // Disable echoing input characters. TODO DAM + TUI.initialize(); + // stdscr = initscr(); // Start curses mode. TODO DAM + // cbreak(); // Line buffering disabled; pass on everty thing to me. TODO DAM + // keypad(stdscr, true); // I need those nifty F1..F12. TODO DAM + // curs_set(0); // Set cursor invisible. TODO DAM + // noecho(); // Disable echoing input characters. TODO DAM // Initialize pairs of colors. //start_color(); TODO DAM @@ -957,10 +955,11 @@ draw_tui :: (db: *Database, layout: *Layout) { // Reset theme and clear screen. //attrset(A_NORMAL); TODO DAM - //erase(); TODO DAM + TUI.tui_clear_screen(); // Draw outer border. //box(stdscr, 0, 0); TODO DAM + // WIP // Draw table grids. // TODO Maybe this could be simplified? @@ -1362,7 +1361,7 @@ main :: () { layout := *layouts[Layouts.COMPACT]; //flushinp(); TODO DAM - //ungetch(KEY_RESIZE); TODO DAM + TUI.tui_ungetch(KEY_RESIZE); // TODO DAM while (true) { if (is_terminal_too_small) { @@ -1376,7 +1375,7 @@ main :: () { reset_temporary_storage(); //timeout(INPUT_TIMEOUT_MS); TODO DAM - key := 0; // getch(); TODO DAM + key := TUI.tui_getch(); // getch(); TODO DAM if key == #char "q" || key == #char "Q" break; update_times(*database); //timeout(INPUT_AWAIT_INF); TODO DAM @@ -1400,7 +1399,7 @@ main :: () { if key == { // When getch() times out. - case ERR; + case .READ_ERROR; if (is_autosave_enabled && countdown_to_autosave > 0) { countdown_to_autosave -= INPUT_TIMEOUT_MS; if (countdown_to_autosave <= 0) { @@ -1414,8 +1413,13 @@ main :: () { // When terminal is resized. case KEY_RESIZE; - //clear(); TODO DAM - //getmaxyx(stdscr, *size_y, *size_x); TODO DAM + TUI.tui_clear_screen(); + //getmaxyx(stdscr, *size_y, *size_x); + TUI.update_terminal_size(); // TODO DAM + size_x = TUI.terminal_state.width; + size_y = TUI.terminal_state.height; + print("resize:%x%", size_x, size_y); + asd := TUI.tui_getch(); is_terminal_too_small = size_x < 60 || size_y < 3; update_layout(); layout = *layouts[ifx size_x > 100 then Layouts.NORMAL else Layouts.COMPACT]; @@ -1495,7 +1499,7 @@ main :: () { if (selected_task == null) continue; // Prepare position to input time operation. - selected_day := key - #char "1"; + selected_day := cast(int)(key - #char "1"); // TODO DAM this cast... input_width := layout.columns[L_DAYS_IDX + selected_day].width; input_pos_x := 1 + layout.columns[L_TITLE_IDX].width; @@ -1766,7 +1770,7 @@ main :: () { //getch(); TODO DAM } - //endwin(); TODO DAM + TUI.terminate(); // TODO DAM exit(xx ifx error_saving then 1 else 0); } |
