This is heavily related to How clear the printed content in terminal and print to the same line?, which provides some good answers.
The linked thread has examples that I used to create the showcase function below:
julia> function test() print("ayy") print("\e[2K") # clear whole line print("\e[1G") # move cursor to column 1 print("new line") end test (generic function with 1 method) julia> test() new line
So it seems like these escape sequences can do what is needed. However, I just stumbled upon a bunch of functions inside
REPL.LineEdit, with promising names. I was hoping they would be easier to reason about than obscure codes. Below is the output from tab-completing the functions in the module that start with
julia> import REPL julia> REPL.LineEdit.edit_ edit_abort edit_backspace edit_clear edit_copy_region edit_delete edit_delete_next_word edit_delete_prev_word edit_exchange_point_and_mark edit_indent edit_indent_left edit_indent_right edit_input edit_insert edit_insert_last_word edit_insert_newline edit_insert_tab edit_kill_line edit_kill_line_backwards edit_kill_line_forwards edit_kill_region edit_lower_case edit_move_down edit_move_left edit_move_right edit_move_up edit_move_word_left edit_move_word_right edit_redo! edit_replace_word_right edit_shift_move edit_splice! edit_tab edit_title_case edit_transpose_chars edit_transpose_lines_down! edit_transpose_lines_up! edit_transpose_words edit_undo! edit_upper_case edit_werase edit_yank edit_yank_pop
Are these functions something that users could/should use? Are there other, better ways to overwrite previous terminal outputs? Or is the status just “get good and learn ANSI escape codes”?