From f1fe4f6bcf27e0843d424f4885b0913e220ade2e Mon Sep 17 00:00:00 2001 From: dam Date: Sun, 24 Mar 2024 00:50:01 +0000 Subject: Improved robustness and code clarity on get_key. --- modules/TUI/module.jai | 8 +++++--- ttt.jai | 7 +++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai index 93e410e..6aeac68 100644 --- a/modules/TUI/module.jai +++ b/modules/TUI/module.jai @@ -332,11 +332,13 @@ get_key :: (timeout_milliseconds: s32 = -1) -> Key { key, success = table_find(*key_map, to_parse); } - // If an escape code was found, use it. + if success { - return key; + return key; // Escape code found, return it. + } + else { + to_parse.count = 1; // No escape code found, return a single (escape) character. } - // else { ... } If we entered this block and did not succeed, then we'll return a single escape character.รข } return to_key(to_parse); diff --git a/ttt.jai b/ttt.jai index 9b08f6d..593e30f 100644 --- a/ttt.jai +++ b/ttt.jai @@ -1324,9 +1324,8 @@ main :: () { assert(key == #char "y", "# Failed to set terminal title.\n"); print("- success\n", to_standard_error = true); } - - // TODO Setup this test... check for Meta+FX or Ctrl+FX compatibility between windows and *nix. - if 1 { + + if 0 { print("TEST : print keys and set terminal title\n", to_standard_error = true); TUI.start(); TUI.set_terminal_title("bazinga"); @@ -1390,7 +1389,7 @@ main :: () { TUI.stop(); } - if 0 { + if 1 { print("TEST : user input\n", to_standard_error = true); auto_release_temp(); TUI.start(); -- cgit v1.2.3