I am animating something on the command line using Mordant. However, when I run the task through Gradle, the output only starts showing ~2 seconds after the app has started running.
You can see this behavior in this asciinema recording. Every 100ms the next value is shown and 18 is the first value appearing on screen.
Source:
package nl.pindab0ter
import com.github.ajalt.mordant.animation.textAnimation
import com.github.ajalt.mordant.terminal.Terminal
fun main() {
val terminal = Terminal(interactive = true)
val animation = terminal.textAnimation<Int> { value -> "$value" }
for (i in 1..50) {
animation.update(i)
Thread.sleep(100)
}
}
What causes this and how can I prevent the start of output being cut off besides using Thread.sleep(2000)
?