-
Notifications
You must be signed in to change notification settings - Fork 2
Description
As mentioned in https://github.com/killercup/rustfix/issues/15 it would be nice to be able to use shortcuts to select a specific option.
While currently, the UI looks like
[?] Choose an option:
> An option
Another option
Something else?
we could just prepend a shortcut key, like this (the second option is selected here):
[?] Choose an option:
[a] An option
> [n] Another option
[s] Something else?
The behaviour should be that pressing e.g. o results in the same as choosing the second option and pressing enter.
If we want to be really fancy, we could look for the first word beginning with (or just the occurrence of) the shortcut character in the display text and highlight that one (e.g. A[n]other option).
Implementation-wise, I would add fn shortcut(&self) -> Option<char> { None } to the Choice trait introduced in #1 and implement it for triples (T, V, S) where S: Into<char>. (Or create a new struct for list items to keep things readable.)