aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/TUI/module.jai32
1 files changed, 16 insertions, 16 deletions
diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai
index fbf2dd9..764effe 100644
--- a/modules/TUI/module.jai
+++ b/modules/TUI/module.jai
@@ -264,7 +264,7 @@ Keys :: struct #type_info_none {
F12 : Key : #run to_key("#f12");
}
-initialized := false;
+active := false;
//input_buffer : [64] u8; // TODO FIXME Input buffer is too small!!!
input_buffer : [8] u8; // TODO FIXME Input buffer is too small!!!
@@ -277,17 +277,17 @@ input_override : Key;
assert(input_buffer.count >= KEY_SIZE, "The input buffer size must be capable to hold an entire terminal (6 bytes) or UTF8 (4 bytes) code.");
}
-assert_is_initialized :: inline () {
- assert(initialized, "TUI is not ready.");
+assert_is_active :: inline () {
+ assert(active, "TUI is not ready.");
}
set_next_key :: (key: Key) {
- assert_is_initialized();
+ assert_is_active();
input_override = key;
}
get_key :: (timeout_milliseconds: s32 = -1) -> Key {
- assert_is_initialized();
+ assert_is_active();
// BBBB BBBB & 1100 0000 == 10XX XXXX -> is continuation byte
is_utf8_continuation_byte :: inline (byte: u8) -> bool {
@@ -371,7 +371,7 @@ get_key :: (timeout_milliseconds: s32 = -1) -> Key {
// TODO Review me!
read_input :: (count_limit: int = -1, terminators: .. u8) -> string {
- assert_is_initialized();
+ assert_is_active();
assert(count_limit >= 0 || terminators.count > 0, "Infinite loop detected, aborting."); // TODO Maybe just return!?
@@ -533,7 +533,7 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key {
}
start :: () {
- if initialized == true return;
+ if active == true return;
setup_key_map(); // TODO This is being called multiple times... please fix me!
@@ -551,12 +551,12 @@ start :: () {
OS_prepare_terminal();
- initialized = true;
+ active = true;
}
stop :: () {
- if initialized == false return;
- initialized = false;
+ if active == false return;
+ active = false;
OS_reset_terminal();
write_strings(Commands.MainScreenBuffer, Commands.RestoreCursorPosition, Commands.ShowCursor);
@@ -574,7 +574,7 @@ flush_input :: () {
// }
draw_box :: (x: int, y: int, width: int, height: int) {
- assert_is_initialized();
+ assert_is_active();
// TODO Check if using a String_Builder improves performance (measure it)!
// TODO Validate input parameters against the terminal size.
@@ -620,13 +620,13 @@ draw_box :: (x: int, y: int, width: int, height: int) {
// TODO Maybe rename to "clear()"
clear_terminal :: inline () {
- assert_is_initialized();
+ assert_is_active();
write_string(Commands.ClearScreen);
}
// TODO Maybe rename to "get_size()"
get_terminal_size :: () -> rows: int, columns: int {
- assert_is_initialized();
+ assert_is_active();
auto_release_temp();
@@ -674,13 +674,13 @@ get_terminal_size :: () -> rows: int, columns: int {
}
set_cursor_position :: (row: int, column: int) {
- assert_is_initialized();
+ assert_is_active();
auto_release_temp();
print(Commands.SetCursorPosition, row, column);
}
get_cursor_position :: () -> row: int, column: int {
- assert_is_initialized();
+ assert_is_active();
auto_release_temp();
@@ -714,7 +714,7 @@ get_cursor_position :: () -> row: int, column: int {
}
set_terminal_title :: (title: string) {
- assert_is_initialized();
+ assert_is_active();
print(Commands.SetWindowTitle, title);
}