Skip to content
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

Animations with newlines do not render correctly in JetBrains' run output #243

Open
pindab0ter opened this issue Dec 8, 2024 · 3 comments

Comments

@pindab0ter
Copy link

pindab0ter commented Dec 8, 2024

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?

@pindab0ter
Copy link
Author

pindab0ter commented Dec 8, 2024

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?

@pindab0ter pindab0ter changed the title Animations with newlines do not render correctly Animations with newlines do not render correctly in JetBrains' run output Dec 8, 2024
@ajalt
Copy link
Owner

ajalt commented Dec 9, 2024

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?

@pindab0ter
Copy link
Author

pindab0ter commented Dec 10, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants