diff options
| -rw-r--r-- | modules/TUI/module.jai | 8 | ||||
| -rw-r--r-- | ttt.jai | 45 |
2 files changed, 25 insertions, 28 deletions
diff --git a/modules/TUI/module.jai b/modules/TUI/module.jai index 21cd88a..4e67db5 100644 --- a/modules/TUI/module.jai +++ b/modules/TUI/module.jai @@ -448,7 +448,13 @@ read_input_line :: (count_limit: int, is_visible: bool = true) -> string, Key { // > https://unix.stackexchange.com/questions/255707/what-are-the-keyboard-shortcuts-for-the-command-line row, col := get_cursor_position(); - write_strings(Commands.StartBlinking, Commands.BlinkingUnderlineShape); + write_strings(Commands.StartBlinking, Commands.BlinkingBarShape); + + // Clear line for input. + for 1..count_limit { + print_character(#char " "); + } + set_cursor_position(row, col); key := Keys.None; while true { @@ -1175,8 +1175,6 @@ read_input_string :: (row: int, column: int, input_limit: int, padding: int = 0) // 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 WIPWIPWIP - column += 1; // TODO FIX THE NCURSES INDEXING CHAOS TUI.set_cursor_position(row, column + input_limit); @@ -1193,15 +1191,24 @@ read_input_string :: (row: int, column: int, input_limit: int, padding: int = 0) // Returns success. read_input_int :: (row: int, message: string) -> value: int, success: bool { - // attron(xx style); TODO DAM - //move(xx row, 1); TODO DAM - //addch(ACS_CKBOARD); TODO DAM - //addstr(message.data); // TODO Convert to C type TODO DAM - //attrset(A_NORMAL); TODO DAM + TUI.set_cursor_position(row, 2); + write_string(TUI.Commands.DrawingMode); + for 1..size_x-2 { + print(TUI.Drawings.Checkerboard); + } + write_string(TUI.Commands.TextMode); + + TUI.set_cursor_position(row, 3); + write_strings(" ", message, " "); // Get line number. - input_pos_x := 1;//getcurx(stdscr); TODO DAM - input_width := size_x - input_pos_x; + input_pos_x := 1 + 1 + 1 + message.count + 1; + input_width := size_x - input_pos_x - 1; + + style_input := context.tui_style; + style_input.underline = true; + TUI.using_style(style_input); + str := read_input_string(row, input_pos_x, input_width); value, success := parse_int(*str); @@ -1210,22 +1217,6 @@ read_input_int :: (row: int, message: string) -> value: int, success: bool { // Shows message to user and waits for user key press. prompt_user_key :: (row: int, message: string) -> TUI.Key { -/* - assert(message.data != null, ASSERT_NOT_NULL, "message"); - attron(xx style); - move(xx row, 1); - for 0..size_x-3 { - // for (int idx = 0; idx < size_x - 2; idx++) { - addch(ACS_CKBOARD); - } - mvaddstr(xx row, 2, message.data); - attrset(A_NORMAL); - - return getch(); -*/ - - // TODO We still need to apply the style. - TUI.set_cursor_position(row, 2); write_string(TUI.Commands.DrawingMode); for 1..size_x-2 { @@ -1858,7 +1849,7 @@ main :: () { if selected_task == null continue; TUI.using_style(action_style); - value, success := read_input_int(selected_task_row, " Move to: "); + value, success := read_input_int(selected_task_row, "Move to:"); if success == false continue; move_task(db, db.selected_idx, value-1); // -1 to adjust for zero based index trigger_autosave(); @@ -1869,7 +1860,7 @@ main :: () { if selected_task == null continue; TUI.using_style(action_style); - value, success := read_input_int(selected_task_row, " Go to: "); + value, success := read_input_int(selected_task_row, "Go to:"); if success == false continue; target_index := clamp(value, 1, MAX_DATABASE_TASKS) - 1; select_task(db, target_index); |
