aboutsummaryrefslogtreecommitdiff
path: root/TUI/module.jai
diff options
context:
space:
mode:
Diffstat (limited to 'TUI/module.jai')
-rw-r--r--TUI/module.jai20
1 files changed, 17 insertions, 3 deletions
diff --git a/TUI/module.jai b/TUI/module.jai
index 0e2ff22..bb5b800 100644
--- a/TUI/module.jai
+++ b/TUI/module.jai
@@ -115,6 +115,14 @@ Keys :: struct {
// Terminal key-codes have 1 to 6 bytes, so we can signal special cases setting the edge-bytes.
None : Key : 0xF0000000_0000000F;
Resize : Key : 0xF0000000_0000001F;
+
+ Up : Key : #run to_key("\e[A");
+ Down : Key : #run to_key("\e[B");
+ Right : Key : #run to_key("\e[C");
+ Left : Key : #run to_key("\e[D");
+
+ PgUp : Key : #run to_key("\e[5~");
+ PgDown : Key : #run to_key("\e[6~");
}
/* TODO
@@ -293,12 +301,18 @@ get_key :: (timeout_milliseconds: s32 = -1) -> Key {
utf8_bytes := count_utf8_bytes(input_string[0]);
assert(utf8_bytes <= input_string.count, "The input buffer is too small."); // TODO Improve error message.
-
+
+ // TODO This is only being done after the OS_wait_for_input... for now!
to_parse := input_string;
to_parse.count = utf8_bytes;
- key := to_key(to_parse);
- advance(*input_string, utf8_bytes);
+ // Must be a terminal escape sequence.
+ if utf8_bytes == 1 && input_string[0] == #char "\e" {
+ to_parse.count = ifx input_string.count > 6 then 6 else input_string.count; // TODO We should look into the input_string and search for the following escape sequence or somehting!?
+ }
+
+ key := to_key(to_parse);
+ advance(*input_string, to_parse.count);
return key;
/// /// /// /// /// /// /// /// ///