New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to display several progress bars? #62
Comments
Sure, just use one terminal and make two progress animations: val terminal = Terminal()
val progress = terminal.progressAnimation { progressBar() }
val progress2 = terminal.progressAnimation { progressBar() }
progress.start()
progress2.start() Or, if you did want two bars on the same line, put them both in the same animation: val terminal = Terminal()
val progress = terminal.progressAnimation {
progressBar()
progressBar()
}
progress.start() |
Thank you for your reply. `
} The result was not what I expected. Instead of two lines being updated, I got many new lines
What did I do wrong? Thanks, Yoel p.s. [edit] |
That works correctly for me. What OS/Terminal/JVM are you using? How are you running the program? Does it work if you only use one progress bar, or do you still see many lines? |
With one progress bar everything works perfectly With two I get the reported error |
So the issue is that the IntelliJ terminal doesn't support cursor movement commands, so it's not possible to animate anything that spans more than one line. We special case that terminal for single line animations by using a carriage return. Try running in a real terminal and it should work. |
OK, tried it on several windows terminals (git-bash, power-shell, cmd) Note: I noticed that Gradle somehow manage to display multiple lines correctly. On every terminal I tested, linux, windows - whatever. So there must be some kind of a solution to this nasty annoying bug. Not sure how worth-while it is though |
So again it depends on how you are running the program. I'm guessing you're running through gradle, which redirects stdin and stdout. Since there's no way for mordant to tell whether you're running interactively in gradle vs being redirected to a file, it takes the safe approach and disables animations. You can force the animations to play by forcing interactive output: For the |
Thanks! |
Hi!
I really enjoy your code, you are super talented and I learned many cool Kotlin tricks reading your code :)
My issue is:
I want to present several progress bars. Simple use case will be downloading two (or more) files simultaneously - trying to display a progress-bar per file
I tried several approaches utilizing progressAnimation, one terminal with multiple progress bars, and several terminals with progressAnimation each. Digging a little into the code I realized that this is not the way that I should use your code
Sadly my attempts failed miserably :(
My workaround is not using the progress bars at all and using styled text instead - but I feel like there is possibly a better solution
Can you please hint to me about what should I do?
Thanks a bunch!!
(p.s. I don't mind having both progress bars at the same line but I would prefer them one per line)
The text was updated successfully, but these errors were encountered: