diff options
| author | dam <dam@gudinoff> | 2024-05-20 23:19:55 +0100 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2024-05-20 23:19:55 +0100 |
| commit | 22e3b95ce23808ee08a5fa3b0481c17c2e5506d6 (patch) | |
| tree | f60be3b1a12dc2c6897e03c7a0690eb872b17ef6 /modules/TUI/module.jai | |
| parent | af1317ed93f7d5fc16baceaadb0da17aa17591be (diff) | |
| download | task-time-tracker-22e3b95ce23808ee08a5fa3b0481c17c2e5506d6.tar.zst task-time-tracker-22e3b95ce23808ee08a5fa3b0481c17c2e5506d6.zip | |
Updated TUI module to clear inside error message box.
Diffstat (limited to 'modules/TUI/module.jai')
| -rw-r--r-- | modules/TUI/module.jai | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai index d0373f9..2fb1233 100644 --- a/modules/TUI/module.jai +++ b/modules/TUI/module.jai @@ -125,10 +125,21 @@ Commands :: struct #type_info_none { // Draw/text. DrawingMode :: "\e(0"; TextMode :: "\e(B"; - ClearScreen :: "\e[2J"; - ClearLine :: "\e[2K"; + ClearToEndOfScreen :: "\e[0J"; // From current cursor position (inclusive) to end of screen. + ClearFromStartOfScreen :: "\e[1J"; // From start of screen to current cursor position. + ClearScreen :: "\e[2J"; // Leaves cursor in top left corner position. ClearScrollBack :: "\e[3J"; + ClearToEndOfLine :: "\e[0K"; // From current cursor position (inclusive) to end of line. + ClearFromStartOfLine :: "\e[1K"; // From start of line to current cursor position. + ClearLine :: "\e[2K"; SetGraphicsRendition :: "\e[%m"; + + // Text Modification. + InsertCharacters :: "\e[%@"; // Insert % spaces at curret cursor position (shifts existing text to the right). + DeleteCharacters :: "\e[%P"; // Delete % characters at the current cursor position (inserts space characters from the right). + EraseCharacters :: "\e[%X"; // Erase % characters from the current cursor position by overwriting them with space characters. + InsertLines :: "\e[%L"; // Insert % lines into the buffer at the current cursor position. + DeleteLines :: "\e[%M"; // Deletes % lines from the buffer, starting with the row the cursor is on. // Character encoding. EncodingIEC2022 :: "\e%@"; @@ -536,12 +547,12 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { if is_visible { print_to_builder(*builder, Commands.SetCursorPosition, y, x); append(*builder, str); - for chars_count..count_limit-1 append(*builder, " "); + if count_limit > chars_count then print_to_builder(*builder, Commands.EraseCharacters, count_limit-chars_count); } else { print_to_builder(*builder, Commands.SetCursorPosition, y, x); for 1..chars_count append(*builder, "*"); - for chars_count..count_limit-1 append(*builder, " "); + if count_limit > chars_count print_to_builder(*builder, Commands.EraseCharacters, count_limit-chars_count); } print_to_builder(*builder, Commands.SetCursorPosition, y, x+idx); write_builder(*builder); @@ -615,7 +626,7 @@ flush_input :: () { input_string.count = 0; } -draw_box :: (x: int, y: int, width: int, height: int) { +draw_box :: (x: int, y: int, width: int, height: int, clear_inside := false) { 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."); @@ -641,10 +652,13 @@ draw_box :: (x: int, y: int, width: int, height: int) { for idx: y+1..y+height-2 { print_to_builder(builder, Commands.SetCursorPosition, idx, x); append(builder, Drawings.LineV); + if clear_inside { + print_to_builder(builder, Commands.EraseCharacters, width-2); + } print_to_builder(builder, Commands.SetCursorPosition, idx, x+width-1); append(builder, Drawings.LineV); } - + // Draw bottom line. print_to_builder(builder, Commands.SetCursorPosition, y+height-1, x); append(builder, Drawings.CornerBL); |
