It’s bugging me that I can’t remove the first “check_email” where I was typing before printing out the chatbox version. I tried some solutions from here, but they don’t seem to work on user text.
Example:
using REPL
import REPL.Terminals
terminal = Terminals.TTYTerminal("", stdin, stdout, stderr)
function user_input()
print("how can I help?\n")
response = readline()
# I've also tried some other "clear last line" options with escape characters
REPL.Terminals.clear_line(terminal)
print("your response was $(response)")
end
\e[1A moves the cursor up. \e2K deletes the entire line (although it seems to delete the next one as well). My example was tested in Julia 1.7.0 in the default Ubuntu terminal, different terminals may implement escape codes differently.
That looks amazing, looking forward to see what you’ll build with Term!
Term has some methods that can help with, for example clearing a line from the terminal. These make use of ANSI control codes printed to the terminal, allowing you to move the cursor around, delete stuff etc.
For example
using Term
using Term.Consoles
println("this will show")
println("this will be erased")
up()
erase_line()
println("this will also show")
Hope this helps, get in touch if you have any questions!