ajalt / mordant

Multiplatform text styling for Kotlin command-line applications
https://ajalt.github.io/mordant/
Apache License 2.0
982 stars 34 forks source link

Current snapshot can't enter raw mode on the JVM #227

Closed JakeWharton closed 1 month ago

JakeWharton commented 1 month ago

I'm not doing anything special but raw mode no longer works. Seems to get the "dumb" implementation for some reason.

fun main() {
  Terminal().enterRawMode().close()
}
Exception in thread "main" java.lang.UnsupportedOperationException: Cannot enter raw mode on this system
    at com.github.ajalt.mordant.internal.DumbTerminalInterface.enterRawMode(MppInternal.jvm.kt:165)
    at com.github.ajalt.mordant.input.RawModeKt.enterRawMode(RawMode.kt:19)
    at com.github.ajalt.mordant.input.RawModeKt.enterRawMode$default(RawMode.kt:15)
    at example.MainKt.main(rrtop.kt:14)

I am running outside of IntelliJ and Gradle where it should work. Tried with multiple terminal emulators, too, just in case (Warp and Ghostty).

Usung mordant-core 2.7.2.176-SNAPSHOT

ajalt commented 1 month ago

If you're getting the DumbTerminalInterface, it's not related to the terminal emulator you're running on, it means that there's no usable TerminalInterface on your classpath.

Do you have all the mordant-jvm modules in your dependencies? They should be included by default with the normal com.github.ajalt.mordant:mordant target.

Try adding implementation("com.github.ajalt.mordant:mordant-jvm-jna:$mordantVersion") explicitly to see if that fixes it.

JakeWharton commented 1 month ago

Oooh I didn't realize I had to pick with 'mordant-core'.

I had to migrate from 'mordant' to 'mordant-core' because 'mordant' no longer appears to be multiplatform. Its .module contains only JVM entries. Was it supposed to still be a multiplatform artifact with all variants like it used to be?

ajalt commented 1 month ago

Yes, it was supposed to keep working without changes. I'll fix the MPP metadata, and also update that error message to be more helpful.

:mordant is now a convenience module that empty other than dependencies on core and all the jvm modules.

JakeWharton commented 1 month ago

Should those JVM dependencies for the implementation be changed to depend only on 'mordant-core', too?

ajalt commented 1 month ago

Actually, I think they do. I just didn't rename the folders in the project, so the mordant folder is the :mordant-core module. It is a little confusing.

JakeWharton commented 1 month ago

Aaaah, yes. That clears up a lot of my own confusion browsing around!