aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2023-12-13 00:48:05 +0000
committerdam <dam@gudinoff>2023-12-13 00:48:05 +0000
commitf75b85e0dac3ee213b8d77cec8f1669881f99d18 (patch)
treef3e80701fd3f27f82dba7d73eb7ed807a11f0681
parente3f4ad1b4db98f612f097ba76116ab5d85bed912 (diff)
downloadtask-time-tracker-f75b85e0dac3ee213b8d77cec8f1669881f99d18.tar.zst
task-time-tracker-f75b85e0dac3ee213b8d77cec8f1669881f99d18.zip
Improved TUI tests.
-rw-r--r--ttt.jai49
1 files changed, 5 insertions, 44 deletions
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);