diff options
| author | dam <dam@gudinoff> | 2023-09-20 00:45:44 +0100 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2023-09-20 00:45:44 +0100 |
| commit | 9e2fc467ad0e779734d836656875cf92bcb5732a (patch) | |
| tree | 9cf327b8e19d2d5f0b501a4fce10d7440803e1e2 /tio.jai | |
| parent | 470702f3ef0645b47c11ff54b9a6b0a5e9e8caab (diff) | |
| download | task-time-tracker-9e2fc467ad0e779734d836656875cf92bcb5732a.tar.zst task-time-tracker-9e2fc467ad0e779734d836656875cf92bcb5732a.zip | |
Prepare TUI for windows.
Diffstat (limited to 'tio.jai')
| -rw-r--r-- | tio.jai | 62 |
1 files changed, 45 insertions, 17 deletions
@@ -39,8 +39,11 @@ terminal_state : struct { // https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/tcgetattr.c.html tcgetattr :: (fd : s32, termios_p : *My_Termios) -> s32 #foreign libc; } +else #if OS == .WINDOWS { + #run print("TODO tio\n", to_standard_error = true); +} else { - assert(false, "unsupported OS\n"); + #run assert(false, "unsupported OS\n"); } Graphics_Mode :: struct { @@ -138,13 +141,21 @@ Color :: enum u8 { } update_terminal_size :: () { - TIOCGWINSZ :: 0x5413; - winsize : struct { - ws_row, ws_col, ws_xpixel, ws_ypixel : u16; + #if OS == .LINUX { + TIOCGWINSZ :: 0x5413; + winsize : struct { + ws_row, ws_col, ws_xpixel, ws_ypixel : u16; + } + ioctl(0, TIOCGWINSZ, *winsize); + terminal_state.width = xx winsize.ws_col; + terminal_state.height = xx winsize.ws_row; + } + else #if OS == .WINDOWS { + print("TODO tio\n", to_standard_error = true); + } + else { + assert(false, "unsupported OS\n"); } - ioctl(0, TIOCGWINSZ, *winsize); - terminal_state.width = xx winsize.ws_col; - terminal_state.height = xx winsize.ws_row; } initialize :: () { @@ -170,10 +181,14 @@ initialize :: () { tcsetattr(STDIN_FILENO, 0, *term_new); } - update_terminal_size(); - } else { - assert(false, "procedure call on unsupported OS\n"); - } + update_terminal_size(); + } + else #if OS == .WINDOWS { + print("TODO tio\n", to_standard_error = true); + } + else { + assert(false, "unsupported OS\n"); + } } terminate :: () { @@ -185,17 +200,24 @@ terminate :: () { tui_write("\e[?25h"); // show cursor tui_write("\e[?30h"); // show scrollbar terminal_state = .{}; - - } else { - assert(false, "procedure call on unsupported OS\n"); + } + else #if OS == .WINDOWS { + print("TODO tio\n", to_standard_error = true); + } + else { + assert(false, "unsupported OS\n"); } } tui_write :: (str : string) { #if OS == .LINUX { write(STDIN_FILENO, str.data, xx str.count); - } else { - assert(false, "procedure call on unsupported OS\n"); + } + else #if OS == .WINDOWS { + #run print("TODO tio\n", to_standard_error = true); + } + else { + #run assert(false, "unsupported OS\n"); } } @@ -216,7 +238,13 @@ tui_getch :: (block := true) -> Key { } check_signal(buf); return ifx l <= 0 then Key.READ_ERROR else buf; - } else { + } + else #if OS == .WINDOWS { + print("TODO tio\n", to_standard_error = true); + return .READ_ERROR; + } + else { + assert(false, "unsupported OS\n"); return .READ_ERROR; } } |
