spectreconsole / spectre.console

A .NET library that makes it easier to create beautiful console applications.
https://spectreconsole.net
MIT License
9.17k stars 472 forks source link

Esc Key to exit selection #851

Open 0xStuart opened 2 years ago

0xStuart commented 2 years ago

There is an "Abort" input selection, but it is not used. https://github.com/spectreconsole/spectre.console/blob/eb6a9d8d047266b1317cdbed87c35f68996b9f0f/src/Spectre.Console/Prompts/List/ListPromptInputResult.cs#L8

Optionally tie that to the Esc Key, so that you can have nested menus.


Please upvote :+1: this issue if you are interested in it.

BenjaminMichaelis commented 1 year ago

I would like to try out this one!

patriksvensson commented 1 year ago

Absolutely. Knock yourself out! 😄

BenjaminMichaelis commented 1 year ago

Just to clarify on the scope of this, is all that is needed here to simply be returning this input result or also to do some handling of the escape case? And also is this abort wanted as a return option for all prompts or just the multi selection as I see that nesting was mentioned?

0xStuart commented 1 year ago

I have a menu list, which links to further menus, so you can drill down to the option you want. At the moment, there is no way to go back to the previous menu, unless you add "back" as a menu item. Ideally, I would like to capture the Esc key.

nth-commit commented 1 year ago

@0xStuart I've accomplished this by using the IAnsiConsole everywhere, and decorating the input with my implementation that intercepts keys globally.