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

kotlin.RuntimeException: Error reading from console input: unexpected event type 16 #185

Closed tumuidle closed 2 weeks ago

tumuidle commented 2 weeks ago

in kotlin/native mingwX64 executable, appears when active window switched or running with double-click exe

when(
        term.interactiveSelectList {
            addEntry(ACTION_INSTALL_MODEL)  // 4 Chinese characters
            addEntry(ACTION_OPEN_DOWNLOAD_PAGE) // 8 Chinese characters
        }
    ) {
        ACTION_INSTALL_MODEL -> installModelAction() // Empty function
        ACTION_OPEN_DOWNLOAD_PAGE -> actionOpenDownloadPage() // Called ShellExecuteA to open an URL
        else -> {
            term.println(TextColors.red("无效操作"))
        }
    }

Error in debug executable

Uncaught Kotlin exception: kotlin.RuntimeException: Error reading from console input: unexpected event type 16
    at 0   ???                                 7ff60b7d4513       kfun:kotlin.Throwable#<init>(kotlin.String?){} + 115
    at 1   ???                                 7ff60b7cf4de       kfun:kotlin.Exception#<init>(kotlin.String?){} + 110
    at 2   ???                                 7ff60b7cf0fe       kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 110
    at 3   ???                                 7ff60b9d719c       kfun:com.github.ajalt.mordant.internal.syscalls.SyscallHandlerNativeWindows#readRawEvent(kotlin.Int){}com.github.ajalt.mordant.internal.syscalls.SyscallHandlerWindows.EventRecord + 3756
    at 4   ???                                 7ff60ba026a0       kfun:com.github.ajalt.mordant.internal.syscalls.SyscallHandlerWindows#readRawEvent(kotlin.Int){}com.github.ajalt.mordant.internal.syscalls.SyscallHandlerWindows.EventRecord-trampoline + 64
    at 5   ???                                 7ff60b9de065       kfun:com.github.ajalt.mordant.internal.syscalls.SyscallHandlerWindows#readInputEvent(kotlin.time.Duration;com.github.ajalt.mordant.input.MouseTracking){}com.github.ajalt.mordant.internal.syscalls.SysInputEvent + 373
    at 6   ???                                 7ff60b9ff71c       kfun:com.github.ajalt.mordant.internal.syscalls.SyscallHandler#readInputEvent(kotlin.time.Duration;com.github.ajalt.mordant.input.MouseTracking){}com.github.ajalt.mordant.internal.syscalls.SysInputEvent-trampoline + 92
    at 7   ???                                 7ff60b9dbad7       kfun:com.github.ajalt.mordant.input.RawModeScope#readEvent(kotlin.time.Duration){}com.github.ajalt.mordant.input.InputEvent + 487
    at 8   ???                                 7ff60b9dbd96       kfun:com.github.ajalt.mordant.input.RawModeScope#readEvent$default(kotlin.time.Duration;kotlin.Int){}com.github.ajalt.mordant.input.InputEvent + 246
    at 9   ???                                 7ff60b9dc254       kfun:com.github.ajalt.mordant.input#receiveEvents__at__com.github.ajalt.mordant.input.InputReceiver<0:0>(com.github.ajalt.mordant.input.MouseTracking){0§<kotlin.Any?>}0:0 + 676
    at 10  ???                                 7ff60b9dc61e       kfun:com.github.ajalt.mordant.input#receiveEvents$default__at__com.github.ajalt.mordant.input.InputReceiver<0:0>(com.github.ajalt.mordant.input.MouseTracking?;kotlin.Int){0§<kotlin.Any?>}0:0 + 286
    at 11  ???                                 7ff60b9e93c4       kfun:#main(kotlin.Array<out|kotlin.String>...){} + 884

    at 12  ???                                 7ff60b9e961c       Konan_start + 156
    at 13  ???                                 7ff60ba212f8       Init_and_run_start + 136
    at 14  ???                                 7ff60b7c13b4       __tmainCRTStartup + 564
    at 15  ???                                 7ff60b7c150b       mainCRTStartup + 27
    at 16  ???                                 7ffade7e26ad       _ZSt25__throw_bad_function_callv + 20717262381
    at 17  ???                                 7ffae094aa68       _ZSt25__throw_bad_function_callv + 20752292328

Error in release executable

Uncaught Kotlin exception: kotlin.RuntimeException: Error reading from console input: unexpected event type 16
    at 0   ???                                 7ff7914984d2       kfun:com.github.ajalt.mordant.internal.syscalls.SyscallHandlerNativeWindows#readRawEvent(kotlin.Int){}com.github.ajalt.mordant.internal.syscalls.SyscallHandlerWindows.EventRecord + 1282
    at 1   ???                                 7ff79149a2e3       kfun:com.github.ajalt.mordant.internal.syscalls.SyscallHandlerWindows#readInputEvent(kotlin.time.Duration;com.github.ajalt.mordant.input.MouseTracking){}com.github.ajalt.mordant.internal.syscalls.SysInputEvent + 579
    at 2   ???                                 7ff79149f87d       kfun:#main(kotlin.Array<out|kotlin.String>...){} + 2957
    at 3   ???                                 7ff7914a6045       Init_and_run_start + 261
    at 4   ???                                 7ff7914a620f       Konan_main + 15
    at 5   ???                                 7ff7913e13b4       __tmainCRTStartup + 564
    at 6   ???                                 7ff7913e150b       mainCRTStartup + 27
    at 7   ???                                 7ffade7e26ad       _ZSt25__throw_bad_function_callv + 14179951677
    at 8   ???                                 7ffae094aa68       _ZSt25__throw_bad_function_callv + 14214981624
ajalt commented 2 weeks ago

Thanks for the report! This is already fixed in #184, and will be included in the next release, or you can use a snapshot now to test it out.