Closed nazmulidris closed 1 year ago
Quick question, just to get an idea of what's required here and see if I'm going in the right direction:
SelectionMode::MultiSelect
MultiSelectComponent
which should be similar to the existing SingleSelectComponent
.select_from_list
to make use of these components.@johnmcl001 Thank you so much for spending time on this issue 🎉 . And for confirming the direction prior to proceeding. You are 100% on the right track 👍🏽 .
To support "multiple selection mode", in addition to all the other things you pointed out, the State
will be affected as well.
State
will need to "remember" what items are selected in multiple selection mode (since the user can select multiple items, and unselect them, before pressing Enter to finalize their choice(s)). keypress.rs
With single selection it is enough to have raw_caret_row_index
to remember what the user has chosen, but for multiple selections, it will probably need to be a Vec<String>
.
Please let me know if you have more questions 🙏🏽 .
Thanks, you've just answered my next question about using space to do multi-selects :+1: . I'll get started on registering the new key press and come back to you with any more questions.
Almost finished with this now, just had 2 questions about the SingleSelectComponent
.
1:
SelectionMode
. SelectionMode::Single
is used then it is fine as is but if SelectionMode::Multiple
is used then we want it to highlight which options the user has currently selected, as indicated by this TODO
:// TODO: use styles for selected and unselected
MutliSelectComponent
like I said above, we could just rename SingleSelectComponent
to SelectComponent
and include the logic for selection styles here. SelectComponent
in public_api.rs
depending on the SelectionMode
.SelectionMode::Single
they will never see the selection style applied since the program will exit and display the user's selection immediately, i.e: current behavior is unaffected.SelectionMode::Multiple
then the styles will be applied as needed.SelectComponent
for use with both modes.2:
bg_color
and fg_color
for multi-select to address the TODO
I mentioned above, if this falls outside the scope of this issue I'll hold off on doing it for now.@johnmcl001 If you would like to chat in real time, please join this discord server: https://discord.gg/kgYck6f5
Re: single SelectComponent
SelectComponent
makes a lot of sense. Let's go with this approach 🎉 Re: selection colors
There's an open issue to add styling to this crate, so that users will be able to pass in whatever "style sheet" struct they would like, and then we don't have to hard code these colors anymore, by providing a default "style sheet".
Here's the issue for this
@johnmcl001 This isn't directly related to what you are currently working on, but I just wanted to give you heads up of this branch that I'm working on. I've found some bugs in the main branch that are fixed here
Not to worry, we can land your PR first (whenever it is ready) and then merge this branch after that.
Please see PR #132
Context:
Currently only single selection is supported in both
rt
and the library inr3bl_tuify
.Implement the
SelectionMode::MultiSelect
. Related to: