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

[termcolor] Add gray colors #754

Closed
KodrAus opened this issue Jan 18, 2018 · 3 comments
Closed

[termcolor] Add gray colors #754

KodrAus opened this issue Jan 18, 2018 · 3 comments

Comments

@KodrAus
Copy link

KodrAus commented Jan 18, 2018

Original issue: rust-cli/env_logger#59

It would be nice to have a gray variant in the Color enum, if it's possible. I think on Windows you can bit-twiddle yourself a gray and dark gray.

cc: @quadrupleslap

@KodrAus KodrAus changed the title Add gray color[s] [termcolor] Add gray colors Jan 18, 2018
@quadrupleslap
Copy link

quadrupleslap commented Jan 18, 2018

Light-gray is a non-intense white, and dark-gray is an intense black, on windows, and it also looks like that's true with dracula on linux.

@okdana
Copy link
Contributor

okdana commented Jan 18, 2018

I don't know about Windows, but on UNIX systems, the first 16 ANSI colours are almost always user-configurable, and it's common to have 'white' (7) and 'bright black' (8) set to shades of grey. This is the way the default palettes of most terminals are set. Sometimes 'black' (0) and 'bright white' (15) are grey too, though this is less common.

Above the first 16, there are 240 more numbered colours, with 232 to 255 dedicated to various shades of grey. These colours are configurable in some terminals (especially those that take settings from X11), but it's very uncommon for users to mess with them, and in some terminals (like Apple's, AFAIK) they just can't. As a result, it's risky to use them in console applications, because they may clash with the end user's colour theme, or they may be unreadable entirely. Many of the grey colours are illegible on light-background themes, for example.

Then there's also 'true' RGB colour, where you can specify an exact value like in CSS or whatever. These are never configurable, and are thus even more risky for anyone but the end user to mess with.

(On top of that, some terminals don't support 256/RGB colours at all, though all of the major ones do, except the Linux console i think.)

So i don't think it's a good idea to use colours outside of the standard 16 as hard-coded or even default values in something that's intended for other people to use (though there's no harm in giving them the option to do it themselves, obv).

Anyway... termcolor would gain support for 256 and RGB ANSI colours if/when PR #452 is merged. It's just been waiting on a more thorough review i think.

@KodrAus
Copy link
Author

KodrAus commented Jan 19, 2018

As @quadrupleslap has pointed out, we can get shades of gray using the set_intense methods that already exist so I'll go ahead and close this.

@KodrAus KodrAus closed this as completed Jan 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants