From 58716ceff7f82ee8b01ea43734cc755cacff25a6 Mon Sep 17 00:00:00 2001 From: dam Date: Mon, 11 Dec 2023 01:28:50 +0000 Subject: Add set_terminal_title procedure. --- TUI/module.jai | 13 +++++++++++++ ttt.jai | 1 + 2 files changed, 14 insertions(+) diff --git a/TUI/module.jai b/TUI/module.jai index c8a5512..044fd65 100644 --- a/TUI/module.jai +++ b/TUI/module.jai @@ -43,6 +43,10 @@ Commands :: struct { ClearScreen :: "\e[2J"; ClearLine :: "\e[2K"; + Bell :: "\x07"; + + SetWindowTitle :: "\e]0;%\x07"; + RefreshWindow :: "\e[7t"; // TODO Not yet tested. SetUTF8 :: "\e%G"; // TODO TEST ME PLEASE @@ -99,6 +103,10 @@ input_override : Key; row := 5; +assert_is_initialized :: inline () { + assert(initialized, "TUI is not ready."); +} + set_next_key :: (key: Key) { input_override = key; } @@ -392,6 +400,11 @@ get_cursor_position :: () -> row: int, column: int { return row, column; } +set_terminal_title :: (title: string) { + assert_is_initialized(); + print(Commands.SetWindowTitle, title); +} + #if OS == .WINDOWS { // Prototyping zone... keep clear! diff --git a/ttt.jai b/ttt.jai index 1a25143..49e88eb 100644 --- a/ttt.jai +++ b/ttt.jai @@ -1257,6 +1257,7 @@ main :: () { #if 1 { print("test 4\n", to_standard_error = true); TUI.start(); + TUI.set_terminal_title("bazinga"); xcolumns, xrows: int; key: TUI.Key = #char "d"; last_none_char := "X"; -- cgit v1.2.3