Adding TrueColor/RGB support to themes #515
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've added TrueColor support to the color system, to allow for themes to be more flexible in their color usage rather than being limited to only xterm-256 color space.
The
Powerline
ctor now checks for TrueColor support by checking theCOLORTERM
environment variable, and sets a flag.The
color()
function inpowerline_shell/__init__.py
both checks this flag, as well as the type of the color information coming in from the theme. If the color is an integer, it is applied as an xterm-256 color as normal. If the color is an RGB tuple, however, one of two things happens:colortrans.rgb2short
before being applied.Color fallback works as normal if a theme doesn't specify a color for a certain segment property.
I've also added a color test script specifically for TrueColor, however it only allows for testing one background and foreground color each, since interpolating between two RGB values for each would be intensive, and likely not fit cleanly on a user's terminal.