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

Adding TrueColor/RGB support to themes #515

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

typedef-sorbet
Copy link

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 the COLORTERM environment variable, and sets a flag.

The color() function in powerline_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:

  • If the terminal does support TrueColor, the color is applied using an alternative color coding string
  • If the terminal does not support TrueColor, the color is converted to the closest xterm-256 color using 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.

Adds the ability to use (R,G,B) tuples in theme files to more accurately
specify the colors desired for each segment.
Not all terminals have TrueColor support, so in the case that a theme
uses (R,G,B) tuples that cannot be supported by the current terminal,
the colors are approximated using colortrans.rgb2short to bring them to
the nearest xterm-256 color.
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

Successfully merging this pull request may close these issues.

None yet

1 participant