Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ColorfulTheme's MultiSelect basically can't be used with an empty environment #114

Closed
Ekleog opened this issue Mar 29, 2021 · 3 comments · Fixed by #275
Closed

ColorfulTheme's MultiSelect basically can't be used with an empty environment #114

Ekleog opened this issue Mar 29, 2021 · 3 comments · Fixed by #275
Labels
c-theme Context: Theme p-multi-select Prompt: Multi Select

Comments

@Ekleog
Copy link

Ekleog commented Mar 29, 2021

For reasons that are yet unclear to me, ColorfulTheme becomes monochrome when being used with an empty environment (env -i [binary]).

This, in turn, makes its MultiSelect, that exclusively relies on colors to identify which items are selected, unusable.

Would it make sense to have ColorfulTheme automatically detect when it's being used in a way that will make colors not work, and have it fall back to SimpleTheme? If not, how would you suggest one to handle this scenario?

Anyway, thank you for indicatif and dialoguer, they're both awesome crates :)

@Ekleog
Copy link
Author

Ekleog commented Mar 29, 2021

Actually I found a bypass myself: using console::colors_enabled() to automatically dispatch between ColorfulTheme and SimpleTheme.

This being said… I wonder whether this should not be done upstream? If only so that people with screenreaders (who… hopefully can use the SimpleTheme? I'm not sure) could use programs made by people who didn't think of this case and just used ColorfulTheme without giving it a second thought.

@pksunkara
Copy link
Collaborator

The colors are switched on if a TTY is found. I am not exactly sure what happened with env -i [binary].

I think the best solution here is to edit the rendering of multi-select in ColorfulTheme.

@Ekleog
Copy link
Author

Ekleog commented Apr 1, 2021

I'd guess the reason why env -i makes coloring fail is because it loses the TERM variable and thus means that terminfo can't be found. As for auto-TTY-detection… I must say that I'm not sure it works? Using env -i does trigger my workaround based on console::colors_enabled() and generate a SimpleTheme, so I'd guess something that is not console::colors_enabled() is being used if there's already TTY detection supposed to happen.

This being said, your proposed solution does sound great to me too :)

@pksunkara pksunkara added p-multi-select Prompt: Multi Select c-theme Context: Theme labels Nov 23, 2021
alex19EP added a commit to alex19EP/dialoguer that referenced this issue Nov 23, 2021
this fixes console-rs#114 and also improves accessability related to console-rs#149
@pksunkara pksunkara linked a pull request Sep 1, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-theme Context: Theme p-multi-select Prompt: Multi Select
Projects
None yet
2 participants