ajalt / mordant

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

Add Raw Mode Support #175

Closed ajalt closed 1 month ago

ajalt commented 1 month ago

Raw mode is supported on all targets except JS and wasm, although there are node/browser APIs to read similar events. I also couldn't get Graal nativeimage working, although that could be added in the future.

select_list

I used to wonder why Jline supports raw mode but all you can do with it is read raw bytes from stdin. But after wading into the mess of parsing VTI escape sequences, I can see why they tapped out. But I'm not willing to push that pain onto users, so I parse all the VTI sequences I can find into InputEvent data classes. You can still read raw bytes from stdin instead if you want.

Fixes #173 Fixes #133 Fixes #89 Fixes #33

ajalt commented 1 month ago

Well, that was a lot of work. Mordant targets JVM/jna, JVM/nativeimage, KT/Native, JS, and wasmJS. Multiply that by three operating systems, and any time you touch a syscall you need to implement it a dozen times.

Jonathan-Zollinger commented 1 month ago

what was the trouble around compiling with graal ? I remember having a beast of a time getting pico to compile to graal, but I eventually got it working. Is this something I could help with?

ajalt commented 1 month ago

I'd love help if you want to take a look.

The problem is actually kind of silly, but I couldn't figure out how to represent the tcgetattr/tcsetattr functions with graal's FFI annotations. If you uncomment the code in SyscallHandler.nativeimage.posix.kt and SyscallHandler.nativeimage.windows.kt and can get it to compile under nativeimage, that should be all that's required.

Jonathan-Zollinger commented 1 month ago

no guarantees I can actually figure anything out! bug I love the challenge! dont wait up on me, I'm not sure when I'll get to this, but I will get to it!