Skip to content

Animated unicode plot inside Term #145

Answered by FedeClaudi
zsoerenm asked this question in Q&A
Discussion options

You must be logged in to vote

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:

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 sprint or string to first generate some content and then call clear(); print(content) to avoid delays between clearing and printing.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zsoerenm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #143 on August 18, 2022 14:12.