Animations with newlines do not render correctly in JetBrains' run output
When I create a textAnimation, only everything after the last \n is cleared and redrawn.
import com.github.ajalt.mordant.animation.textAnimation
import com.github.ajalt.mordant.terminal.Terminal
fun main() {
val terminal = Terminal()
val animation = terminal.textAnimation<Int> { value -> "${value}\n" }
for (i in 1..5) {
animation.update(i)
Thread.sleep(250)
}
}
This results in:
1
2
3
4
5
However, when I add something after the final newline, e.g. "${value}\nTest", "Test" is drawn and replaced each time and ends up like so:
1
2
3
4
5
Test
Am I missing something, or is this a bug?
Edit: This is in the IntelliJ built-in terminal. Maybe related to #49?
When running in a terminal with the generated run script by IntelliJ it doesn't work as intended, but when run through gradle :installDist && build/install/<…> it displays correctly.
Edit: When displayed in a normal terminal, proving that the problem lies in the IntelliJ run output 'terminal'.
I guess part of the question is: Is there a way to marry IntelliJ's "Run" feature with the terminal functionality Mordant needs somehow?
You're correct that this is a known issue. Last I checked, the IntelliJ console doesn't support ANSI cursor movements, and we have code to specifically handle that case. Are you saying that you were able to get multi-line animations working on the IntelliJ console?
Unfortunately no. What's more, animations in tasks run through Gradle also perform poorly. In the end I had to use the installDist task to generate a binary and run that to be able to reach 60fps. Maybe good to note somewhere in the docs.
I have similar issue when using multiple progress bars, output gets duplicated in intellij console on every update, while works fine from normal console. Is this fixable?
I don't think is fixable on Mordant's end, but you could try filing a bug against IntelliJ to get them to support ANSI cursor movements.