-
Notifications
You must be signed in to change notification settings - Fork 238
Open
Description
When I press Ctrl+C, the exception does happen, but it just gets printed in a different thread, and it's not propagated at all:
My application continues to work.
I have:
val terminal = TerminalBuilder.builder()
.dumb(false)
.build()
// Handle Ctrl+C gracefully
terminal.handle(Terminal.Signal.INT, {
throw UserInterruptException("Caught Ctrl+C signal");
})
try {
terminal.puts(Capability.cursor_invisible)
val promptBuilder = PromptBuilder()
val checkboxBuilder = promptBuilder.createCheckboxPrompt()
.name("selection")
.message(title)
options.forEach { opt ->
when (opt) {
is Option.Label -> {
checkboxBuilder
.newSeparator()
.text(opt.label)
.add()
}
is Option.Item<*> -> {
checkboxBuilder
.newItem(opt.key)
.text(opt.key)
.add()
}
}
}
checkboxBuilder.addPrompt()
val promptResult = ConsolePrompt(
terminal,
ConsolePrompt.UiConfig(
"›",
"$FILLED_CIRCLE ",
"$CIRCLE ",
"- ",
),
)
.prompt(promptBuilder.build())["selection"] as? CheckboxResult
?: return emptyList()
return options
.filterIsInstance<Option.Item<*>>()
.filter { item ->
item.key in promptResult.selectedIds
}
} catch (e: UserInterruptException) {
// Does not happen
println("\nOperation cancelled.")
return emptyList()
} finally {
// Does not happen
showCursorSafely(terminal)
terminal.close()
}Metadata
Metadata
Assignees
Labels
No labels