From ee1a68abb41ec7d0f76b458b5340d08a3f881a2b Mon Sep 17 00:00:00 2001 From: dam Date: Fri, 15 Sep 2023 02:24:05 +0100 Subject: Added QueryWindowSizeInChars to tui.jai. --- ttt.jai | 12 ++++++++---- tui.jai | 24 ++++++++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ttt.jai b/ttt.jai index 53a3e01..8ac98c8 100644 --- a/ttt.jai +++ b/ttt.jai @@ -21,7 +21,7 @@ #import "System"; #import "Sort"; #import "Math"; -#import "POSIX"; +// #import "POSIX"; #import "File"; #import "File_Utilities"; #import "String"; @@ -1186,10 +1186,14 @@ main :: () { // https://github.com/MicrosoftDocs/Console-Docs/blob/main/docs/console-virtual-terminal-sequences.md TUI.start(); TUI.clear_screen(); - TUI.draw_box(1,1,13,13); - sleep_milliseconds(10000); - write_string(TUI.Commands.ShowCursor); + TUI.draw_box(1,1,24,13); + // TODO get size of console... its being displayed... but we want to collect it. + // write_string(TUI.Commands.QueryCursorPosition); + write_string(TUI.Commands.QueryWindowSizeInChars); + sleep_milliseconds(3000); + // write_string(TUI.Commands.ShowCursor); TUI.stop(); + // write_string(TUI.Commands.QueryDeviceAttributes); return; str: string; diff --git a/tui.jai b/tui.jai index a0eb025..3c868ee 100644 --- a/tui.jai +++ b/tui.jai @@ -12,6 +12,16 @@ Drawings :: struct { TeeB :: "\x76"; TeeT :: "\x77"; LineV :: "\x78"; + + Blank :: "\x5F"; + Diamond :: "\x60"; + Checkerboard :: "\x61"; + PlusMinus :: "\x67"; + LessThanOrEqual :: "\x79"; + GreaterThanOrEqual :: "\x7A"; + Pi :: "\x7B"; + NotEqual :: "\x7C"; + CenteredDot :: "\x7E"; } Commands :: struct { @@ -21,6 +31,11 @@ Commands :: struct { EnterDrawingMode :: "\e(0"; EnterNormalMode :: "\e(B"; ClearScreen :: "\e[2J"; + ClearLine :: "\e[2K"; + + RefreshWindow :: "\e[7t"; // TODO Not yet tested. + + SetUTF8 :: "\e%G"; // TODO TEST ME PLEASE // Cursor Visibility ShowCursor :: "\e[?25h"; @@ -44,21 +59,22 @@ Commands :: struct { CursorNormalMode :: "\e[?1l"; // Query State - QueryCursorPos :: "\e[6n"; // Emits the cursor position as: ESC [ ; R Where = row and = column. + QueryCursorPosition :: "\e[6n"; // Emits the cursor position as: "ESC [ ; R" Where = row and = column. QueryDeviceAttributes :: "\e[0c"; + QueryWindowSizeInChars :: "\e[18t"; // Emits the window size as: "ESC [ 8 ; t" Where = row and = column. + } start :: () { - write_string(Commands.EnterAlternateBuffer); + write_strings(Commands.EnterAlternateBuffer, Commands.SetUTF8, Commands.HideCursor); } stop :: () { - write_string(Commands.EnterMainBuffer); + write_strings(Commands.EnterMainBuffer, Commands.ShowCursor); } draw_box :: (x: int, y: int, width: int, height: int, to_standard_error := false) { - write_string(Commands.HideCursor); write_strings( // Commands.EnterNormalMode, Commands.EnterDrawingMode, -- cgit v1.2.3