diff options
| author | dam <dam@gudinoff> | 2024-04-07 23:23:06 +0100 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2024-04-07 23:23:06 +0100 |
| commit | 353d8b1145db12ffc42e4f6c2148a848ef8bba84 (patch) | |
| tree | afbf51e66a9e7eaba04b6659b224187bc7a95c75 /modules/TUI | |
| parent | a3cf506defb4a01759db6f920a363e23de63e984 (diff) | |
| download | task-time-tracker-353d8b1145db12ffc42e4f6c2148a848ef8bba84.tar.zst task-time-tracker-353d8b1145db12ffc42e4f6c2148a848ef8bba84.zip | |
Preparing for UTF8 support on read_input_line.
Diffstat (limited to 'modules/TUI')
| -rw-r--r-- | modules/TUI/module.jai | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai index bda326b..e7dc21a 100644 --- a/modules/TUI/module.jai +++ b/modules/TUI/module.jai @@ -14,6 +14,7 @@ #import "Basic"; #import "String"; #import "Thread"; +#import "UTF8"; #load "key_map.jai"; // Special Graphics Characters @@ -289,21 +290,6 @@ set_next_key :: (key: Key) { get_key :: (timeout_milliseconds: s32 = -1) -> Key { assert_is_active(); - // BBBB BBBB & 1100 0000 == 10XX XXXX -> is continuation byte - is_utf8_continuation_byte :: inline (byte: u8) -> bool { - return (byte & 0xC0) == 0x80; - } - - // BBBB BBBB & 1110 0000 == 110X XXXX -> 1 initial + 1 continuation byte - // BBBB BBBB & 1111 0000 == 1110 XXXX -> 1 initial + 2 continuation byte - // BBBB BBBB & 1111 1000 == 1111 0XXX -> 1 initial + 3 continuation byte - count_utf8_bytes :: inline (byte: u8) -> int { - if (byte & 0xE0) == 0xC0 return 1+1; - if (byte & 0xF0) == 0xE0 return 1+2; - if (byte & 0xF8) == 0xF0 return 1+3; - return 1; - } - if input_override != xx Keys.None { defer input_override = xx Keys.None; return input_override; @@ -421,7 +407,7 @@ read_input :: (count_limit: int = -1, terminators: .. u8) -> string { } } -read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { +read_input_line :: (count_limit: int, is_visible: bool = true, placeholder: string = "") -> string, Key { /* Use the get_key to read user input and show it on screen. Should allow to move the cursor left and right and to delete/backspace. |
