From f75b85e0dac3ee213b8d77cec8f1669881f99d18 Mon Sep 17 00:00:00 2001 From: dam Date: Wed, 13 Dec 2023 00:48:05 +0000 Subject: Improved TUI tests. --- ttt.jai | 49 +++++-------------------------------------------- 1 file changed, 5 insertions(+), 44 deletions(-) (limited to 'ttt.jai') diff --git a/ttt.jai b/ttt.jai index b8681ff..f0b554f 100644 --- a/ttt.jai +++ b/ttt.jai @@ -1185,46 +1185,6 @@ main :: () { // TODO Test input - #if 0 { - print("test 1\n"); - TUI.start(); - buffer: [8] u8; - bytes_read, error, error_msg := TUI.OS_read_input(buffer.data, buffer.count); - TUI.stop(); - if error == true print("error:%\n", error_msg); - print("read % bytes:", bytes_read); - for 0..bytes_read-1 { - char := "-NA-"; - if buffer[it] >= 33 && buffer[it] <= 126 { - char.data = *buffer[it]; - char.count = 1; - } - print(" 0x% (%)", FormatInt.{minimum_digits=2, base=10, value=buffer[it]}, char); - } - print("\n"); - TUI.stop(); - } - - #if 0 { - print("test 2\n"); - _key: TUI.Key = #char "d"; - while(_key != #char "q") { - // key = TUI.get_key(10); - buffer: [8] u8; - buffer[0] = 0; - bytes_read := TUI.OS_read_input(buffer.data, 1); - if bytes_read > 0 { - _key = buffer[0]; - print(">%<", xx _key); - } - else { - print(":"); - } - sleep_milliseconds(10); - } - TUI.stop(); - } - if 1 { print("TEST : set and get cursor position --\n", to_standard_error = true); TUI.start(); @@ -1249,7 +1209,7 @@ main :: () { while(key != #char "q") { __mark := get_temporary_storage_mark(); key = TUI.get_key(1000); - if key != xx TUI.Keys.None print_character(cast,force(u8)key); + if key >= 33 && key <= 128 then print_character(cast,force(u8)key); else write_string("-"); set_temporary_storage_mark(__mark); } @@ -1279,13 +1239,14 @@ main :: () { rows, columns := TUI.get_terminal_size(); TUI.set_cursor_position(1, 1); print("Is terminal size % columns and % rows? (y/n)", columns, rows); - key := TUI.get_key(); + key: TUI.Key = xx TUI.Keys.None; + while (key == xx TUI.Keys.None || key == xx TUI.Keys.Resize) { + key = TUI.get_key(); + } TUI.stop(); assert(key == #char "y", "Failed to get terminal size.\n"); print("> success\n", to_standard_error = true); } - - // TODO Resizing terminal breaks the tests... try to fix it. #if 0 { print("test 5\n", to_standard_error = true); -- cgit v1.2.3