Animated unicode plot inside Term #145
-
I'd like to have an animated Unicode plots inside Term. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, The way the example animation you've sent is done is to repeatedly: 1) clear out the terminal and 2) print an updated display. using Term
import Term.Consoles: clear
make_p(i) = Panel("Iteration $i", fit=true)
for i in 1:10
clear()
make_p(i) |> print
sleep(1)
end This might look a bit glitchy if the function in the loop takes a while or if actually printing the content takes a while (e.g. if Term needs to do a lot of work). One solution might be to use Hope this help. Ps: I will move this to a discussion to make it more discoverable for other people interested in similar things. |
Beta Was this translation helpful? Give feedback.
Hi,
The way the example animation you've sent is done is to repeatedly: 1) clear out the terminal and 2) print an updated display.
You can do the same with anything you'd print to the REPL, including things made with term:
This might look a bit glitchy if the function in the loop takes a while or if actually printing the content takes a while (e.g. if Term needs to do a lot of work). One solution might be to use
sprint
orstring
to first generate somecontent
and then callclear(); print(content)
to avoid delays between clearing and printing.