tty-prompt icon indicating copy to clipboard operation
tty-prompt copied to clipboard

add the ability to specify keys to select list items

Open slowbro opened this issue 5 years ago • 3 comments

Describe the change

This change updates List (Prompt#select) to add the ability to specify keypress triggers for choices. It makes List respect the already-existing Choice#key, as well as adding displaying of the keys with :enum, overriding of those displayed keys with Choice#key_name, and modification of keypress behavior for List. The default behavior of keypress == move to item is kept, but the ability to have a keypress immediately select an item was added. This changeset also includes some whitespace, comment, and spec fixups.

Why are we doing this?

The readme called out this ability, but it didn't work with List. This adds the ability. Resolves #151

Benefits

This makes List more robust, especially in 'menu' style uses (i.e. simple keypresses to navigate menus, no arrow keys+enter keys needed)

Drawbacks

None immediately come to mind. I kept the original default behaviors, so this should be backwards-compatible.

Requirements

Put an X between brackets on each line if you have done the item: [x] Tests written & passing locally? [x] Code style checked? [x] Rebased with master branch? [x] Documentation updated?

slowbro avatar Sep 30 '20 16:09 slowbro

Coverage Status

Coverage increased (+0.2%) to 97.922% when pulling 598e798c3f54e0b6fd9f1b1cf0d4ce6b925957f8 on slowbro:issue-151 into 2cc58dae4d5e2674fe0a4db271af7337a8f8ba66 on piotrmurach:master.

coveralls avatar Sep 30 '20 17:09 coveralls

Hi @piotrmurach, is there anything you'd like to see changed about this PR?

slowbro avatar Nov 11 '20 04:11 slowbro

Thank you for reminding me and sorry for keeping your waiting so long! Will review shortly.

piotrmurach avatar Nov 11 '20 23:11 piotrmurach