Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Console] Add support for true colors#36802
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
77b804f tob5be5dbCompareUh oh!
There was an error while loading.Please reload this page.
8ff5fb5 toc8b9489Compare| } | ||
| if (!isset(static::$colors[$color])) { | ||
| thrownewInvalidArgumentException(sprintf('Invalid "%s" color; expected one of (%s).',$color,implode(',',array_keys(static::$colors)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
maybe we can point out here that the user should use one of the predefined colors or an hexadecimal one ?
stof commentedMay 14, 2020
I guess you need to reword your description, to talk about hex colors. CSS colorsdo support RGB and HSL (and more to come) |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedMay 16, 2020
Anyone willing to test on Windows? |
| */ | ||
| finalclass Color | ||
| { | ||
| privatestatic$colors = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
shoudn't these be consts instead ? (Same for$availableOptions)
wouterj commentedMay 16, 2020
Some tests with the |
fabpot commentedJun 10, 2020
Thanks@wouterj for testing on Windows. |




Uh oh!
There was an error while loading.Please reload this page.
This PR adds support for true colors in the Console component.
Instead of adding many ways to add more colors than the current "default" ones, I've opted to only add true color support via Hex CSS colors. If you have something else (RGB, HSV, ...), you need to first convert it to a CSS color. I've also decided to not support the ANSI 256 colors as most terminals support true colors nowadays.
If true colors are not supported by the terminal, we fall back to the "nearest" default color.
<fg=green;bg=blue>is now equivalent to<fg=#00ff00;bg=#00f>.The
Colorclass is usable outside of the Console framework as well:Rainbow time!