diff options
| author | dam <dam@gudinoff> | 2024-05-07 18:14:45 +0100 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2024-05-07 18:14:45 +0100 |
| commit | 89157d00fc4110055d5816cd1897e4def120bcaf (patch) | |
| tree | b7aa8643d9b9d55258c02ff866e2ca185ac77c70 | |
| parent | 63c21762a8d8323facaf729a1bd17e9449eea72e (diff) | |
| download | task-time-tracker-89157d00fc4110055d5816cd1897e4def120bcaf.tar.zst task-time-tracker-89157d00fc4110055d5816cd1897e4def120bcaf.zip | |
Fixed two very nasty bugs.
| -rw-r--r-- | modules/TUI/module.jai | 18 | ||||
| -rw-r--r-- | ttt.jai | 2 |
2 files changed, 9 insertions, 11 deletions
diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai index f2a3a23..612f93e 100644 --- a/modules/TUI/module.jai +++ b/modules/TUI/module.jai @@ -177,8 +177,9 @@ Style :: struct { set_style :: (style: Style) { - auto_release_temp(); - + auto_release_temp(); // TODO Does this breaks if the context.tui_buffer is a temporary buffer... and we're writting to it? + + // TODO If context.tui_buffer is temporary... this will fail.... right? builder := ifx context.tui_buffer != null then context.tui_buffer else *temp_buffer; #if COLOR_MODE_BITS == { @@ -497,10 +498,6 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { assert_is_active(); assert(count_limit >= 0, "Invalid arguments passed to read_input_line(): 'count_limit' must be greater-than or equal to 0."); - // builder := String_Builder.{ allocator = temporary_allocator }; - // builder := String_Builder.{}; - // init_string_builder(*builder, 10000); - // reset(*builder); builder := temp_buffer; str := alloc_string(count_limit); @@ -529,8 +526,7 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { for chars_count..count_limit-1 append(*builder, " "); } print_to_builder(*builder, Commands.SetCursorPosition, y, x+idx); - // write_builder(*builder); // TODO Not sure why this is not working... - write_string(builder_to_string(*builder,, allocator = temporary_allocator)); + write_builder(*builder); // Process input key. key = get_key(); @@ -560,7 +556,7 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { if idx == 0 continue; idx -= 1; delete_character(*str, idx); - + case; if is_escape_code(key) continue; @@ -571,7 +567,7 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { if buff_idx > count_limit - key_str.count then continue; // Move text to allow inserting new character. - for < count_limit..buff_idx+key_str.count { + for < count_limit-1..buff_idx + key_str.count-1 { str.data[it] = str.data[it-key_str.count]; } @@ -602,7 +598,7 @@ 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."); - auto_release_temp(); + auto_release_temp(); // TODO Does this breaks if the context.tui_buffer is a temporary buffer... and we're writting to it? builder := ifx context.tui_buffer != null then context.tui_buffer else *temp_buffer; @@ -218,6 +218,7 @@ print_time :: (y: int, x: int, time: s64, space: int) -> int { assert(size >= 0, "Cannot print negative padding values. The procedure accepts signed values just for convenience."); auto_release_temp(); padding := talloc_string(size); + padding.count = size; memset(padding.data, char, size); TUI.tui_write(padding); } @@ -1131,6 +1132,7 @@ read_input_string :: (x: int, y: int, input_limit: int, padding: int = 0) -> val // TODO Draw padding (at end of inputbox)... padding was renamed to input_width... is this the best name? // TODO Maybe add another optional arg with the placeholder text (to be preset on the input)? + // TODO COULD CACHE... but there's not need... TUI.set_cursor_position(x + input_limit, y); write_string(TUI.Commands.DrawingMode); |
