diff options
Diffstat (limited to 'modules/TUI/module.jai')
| -rw-r--r-- | modules/TUI/module.jai | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai index 764effe..5b7861e 100644 --- a/modules/TUI/module.jai +++ b/modules/TUI/module.jai @@ -447,14 +447,14 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { // TODO Some of these may be nice to have: // > https://unix.stackexchange.com/questions/255707/what-are-the-keyboard-shortcuts-for-the-command-line - row, col := get_cursor_position(); + x, y := get_cursor_position(); write_strings(Commands.StartBlinking, Commands.BlinkingBarShape); // Clear line for input. for 1..count_limit { print_character(#char " "); } - set_cursor_position(row, col); + set_cursor_position(x, y); key := Keys.None; while true { @@ -513,17 +513,17 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { } if is_visible { - set_cursor_position(row, col); + set_cursor_position(x, y); write_string(str); for str.count..count_limit-1 print_character(#char " "); } else { - set_cursor_position(row, col); + set_cursor_position(x, y); for 0..str.count-1 print_character(#char "*"); for str.count..count_limit-1 print_character(#char " "); } - set_cursor_position(row, col+idx); + set_cursor_position(x+idx, y); } write_strings(Commands.StopBlinking, Commands.DefaultShape); @@ -535,6 +535,8 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { start :: () { if active == true return; + // TODO Should start() call flush_input internally? + setup_key_map(); // TODO This is being called multiple times... please fix me! input_string.data = input_buffer.data; @@ -625,7 +627,7 @@ clear_terminal :: inline () { } // TODO Maybe rename to "get_size()" -get_terminal_size :: () -> rows: int, columns: int { +get_terminal_size :: () -> width: int, height: int { assert_is_active(); auto_release_temp(); @@ -659,27 +661,25 @@ get_terminal_size :: () -> rows: int, columns: int { rows = parse_int(*parts[1]); columns = parse_int(*parts[2]); } - // Some systems don't allow to query the terminal size directly. + // Some systems don't allow to query the terminal size directly... or the answer takes too much time. // In such cases, measure it indirectly by the maximum possible cursor position. else { - flush_input(); - cursor_row, cursor_column := get_cursor_position(); - defer set_cursor_position(cursor_row, cursor_column); + x, y := get_cursor_position(); + defer set_cursor_position(x, y); set_cursor_position(0xFFFF, 0xFFFF); - rows, columns = get_cursor_position(); + columns, rows = get_cursor_position(); } - return rows, columns; + return columns, rows; } -set_cursor_position :: (row: int, column: int) { +set_cursor_position :: (x: int, y: int) { assert_is_active(); - auto_release_temp(); - print(Commands.SetCursorPosition, row, column); + print(Commands.SetCursorPosition, y, x); } -get_cursor_position :: () -> row: int, column: int { +get_cursor_position :: () -> x: int, y: int { assert_is_active(); auto_release_temp(); @@ -710,7 +710,7 @@ get_cursor_position :: () -> row: int, column: int { parts := split(input, ";",, temporary_allocator); row := parse_int(*parts[0]); column := parse_int(*parts[1]); - return row, column; + return column, row; } set_terminal_title :: (title: string) { |
