diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/TUI/module.jai | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai index 5399503..70675c7 100644 --- a/modules/TUI/module.jai +++ b/modules/TUI/module.jai @@ -33,7 +33,7 @@ #load "key_map.jai"; #add_context tui_style : Style; // This contains the last style applied by the module. -#add_context tui_builder : *String_Builder; // If set, this will serve as an output buffer for this module procedures. +#add_context tui_output_builder : *String_Builder; // If set, this will serve as an output buffer for this module procedures. KEY_SIZE :: #run type_info(Key).runtime_size; #assert(input_buffer.count >= KEY_SIZE); // The input buffer size must be capable to hold an entire Key. @@ -176,10 +176,10 @@ Style :: struct { } set_style :: (style: Style) { - // If no tui_builder is provided, use a temporary one and discard it afterwards. - builder := context.tui_builder; + // If no tui_output_builder is provided, use a temporary one and discard it afterwards. + builder := context.tui_output_builder; temp_mark: Temporary_Storage_State = ---; - if context.tui_builder == null { + if context.tui_output_builder == null { builder = *temp_builder; temp_mark = get_temporary_storage_mark(); } @@ -213,7 +213,7 @@ set_style :: (style: Style) { append(builder, #run sprint(Commands.SetGraphicsRendition, "49")); } - if context.tui_builder == null { + if context.tui_output_builder == null { write_builder(builder); set_temporary_storage_mark(temp_mark); } @@ -606,10 +606,10 @@ draw_box :: (x: int, y: int, width: int, height: int) { assert_is_active(); assert(x > 0 && y > 0 && width > 1 && height > 1, "Invalid arguments passed to draw_box(): 'x' and 'y' must be greater-than 0; 'width' and 'height' must be greater-than 1."); - // If no tui_builder is provided, use a temporary one and discard it afterwards. - builder := context.tui_builder; + // If no tui_output_builder is provided, use a temporary one and discard it afterwards. + builder := context.tui_output_builder; temp_mark: Temporary_Storage_State = ---; - if context.tui_builder == null { + if context.tui_output_builder == null { builder = *temp_builder; temp_mark = get_temporary_storage_mark(); } @@ -642,7 +642,7 @@ draw_box :: (x: int, y: int, width: int, height: int) { append(builder, Commands.TextMode); - if context.tui_builder == null { + if context.tui_output_builder == null { write_builder(builder); set_temporary_storage_mark(temp_mark); } @@ -702,11 +702,11 @@ get_terminal_size :: () -> width: int, height: int { set_cursor_position :: inline (x: int, y: int) { assert_is_active(); - if context.tui_builder == null { + if context.tui_output_builder == null { print(Commands.SetCursorPosition, y, x); } else { - print_to_builder(context.tui_builder, Commands.SetCursorPosition, y, x); + print_to_builder(context.tui_output_builder, Commands.SetCursorPosition, y, x); } } @@ -749,28 +749,26 @@ set_terminal_title :: inline (title: string) { print(Commands.SetWindowTitle, title); } -using_buffer :: (buffer: *String_Builder) #expand { - __buffer := context.tui_builder; - context.tui_builder = buffer; - `defer context.tui_builder = __buffer; +using_builder_as_output :: (builder: *String_Builder) #expand { + __builder := context.tui_output_builder; + context.tui_output_builder = builder; + `defer context.tui_output_builder = __builder; } -// TODO Maybe we should have a different name for this...? tui_print :: inline (format_string: string, args: .. Any) { - if context.tui_builder == null { + if context.tui_output_builder == null { print(format_string, ..args, to_standard_error = false); } else { - print_to_builder(context.tui_builder, format_string, ..args); + print_to_builder(context.tui_output_builder, format_string, ..args); } } -// TODO Maybe we should have a different name for this...? tui_write_string :: inline (s: string) { - if context.tui_builder == null { + if context.tui_output_builder == null { write_string(s, to_standard_error = false); } else { - append(context.tui_builder, s); + append(context.tui_output_builder, s); } } |
