r3bl-org / r3bl-open-core

TUI framework and developer productivity apps in Rust 🦀
https://r3bl.com
Apache License 2.0
351 stars 20 forks source link

[tuify] Create a function that allows multiple selections from a list of strings #123

Closed nazmulidris closed 1 year ago

nazmulidris commented 1 year ago

Context:

Currently only single selection is supported in both rt and the library in r3bl_tuify.

Implement the SelectionMode::MultiSelect. Related to:

johnmcl001 commented 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:

nazmulidris commented 1 year ago

@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.

https://github.com/r3bl-org/r3bl_rs_utils/blob/bb620bb348fd88a9874ffadf4eda783e8c1429da/tuify/src/public_api.rs#L172

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>.

https://github.com/r3bl-org/r3bl_rs_utils/blob/bb620bb348fd88a9874ffadf4eda783e8c1429da/tuify/src/state.rs#L28

Please let me know if you have more questions 🙏🏽 .

johnmcl001 commented 1 year ago

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.

johnmcl001 commented 1 year ago

Almost finished with this now, just had 2 questions about the SingleSelectComponent.

1:

// TODO: use styles for selected and unselected

2:

nazmulidris commented 1 year ago

@johnmcl001 If you would like to chat in real time, please join this discord server: https://discord.gg/kgYck6f5

  1. Re: single SelectComponent

    • I agree w/ you 100%. Having a single SelectComponent makes a lot of sense. Let's go with this approach 🎉
  2. Re: selection colors

    • For now, let's go w/ what you propose 🎉

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

nazmulidris commented 1 year ago

@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.

johnmcl001 commented 1 year ago

Please see PR #132