Detect other keys in Select #322
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I had a use case where I wanted to detect additional keystrokes while selecting items in Select. For example, I want to detect if the user press 's' to Skip to the next option.
So I added a new function to select called
interact_opt_with_keys
, where you can supply avec
of Key for the select to return back if detected. The return is aSelectResult
object, which contains 2 fields: index which will have the index selected or None, and key which has which optional key was detected or None.The keys supplied will override any of the existing keystrokes detected.
The return values for all the other interact functions remain the same.
I updated the select.rs example file to demonstrate this function.