From bc5b1e651e17e97177af29762ef7d0558f83db89 Mon Sep 17 00:00:00 2001 From: dam Date: Fri, 29 Mar 2024 01:18:46 +0000 Subject: Fixed input echo on read_input_line. --- modules/TUI/module.jai | 9 +++------ ttt.jai | 7 ++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai index 5fdf3b9..9cc7e5d 100644 --- a/modules/TUI/module.jai +++ b/modules/TUI/module.jai @@ -460,17 +460,14 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { // set_cursor_position(row, col); // write_builder(*builder, false); if is_visible { - set_cursor_position(row, col+idx); - for idx..count_limit print_character(#char " "); set_cursor_position(row, col); write_string(str); + for str.count..count_limit-1 print_character(#char " "); } else { set_cursor_position(row, col); - for 0..str.count-1 { - char := cast(u8) ifx str[it] != 0 then #char "*" else #char " "; - print_character(char); - } + for 0..str.count-1 print_character(#char "*"); + for str.count..count_limit-1 print_character(#char " "); } // print(">%<", builder_to_string(*builder,, temporary_allocator)); set_cursor_position(row, col+idx); diff --git a/ttt.jai b/ttt.jai index 6f0f426..7690c68 100644 --- a/ttt.jai +++ b/ttt.jai @@ -1420,17 +1420,14 @@ main :: () { } TUI.stop(); } - - // BUG - // SECOND TIME CALLING TO read_input_line fails... - if 0 { + if 1 { print("TEST : hidden user input\n", to_standard_error = true); auto_release_temp(); TUI.start(); TUI.clear_terminal(); TUI.set_cursor_position(1, 1); - print("Enter some text (use Enter to finish, Esc to cancel, or resize to abort):"); + print("Enter some secret (use Enter to finish, Esc to cancel, or resize to abort):"); r, c := TUI.get_cursor_position(); TUI.set_cursor_position(r+1, 1); str, key := TUI.read_input_line(15, false); -- cgit v1.2.3