mirror of
https://github.com/powerline/powerline.git
synced 2025-06-17 20:30:59 +02:00
Add configuration option and docs for 24-bit terminal colors
Closes #81.
This commit is contained in:
parent
9985ca5313
commit
16b82cf070
@ -52,6 +52,32 @@ Common configuration
|
|||||||
Common configuration is a subdictionary that is a value of ``common`` key in
|
Common configuration is a subdictionary that is a value of ``common`` key in
|
||||||
:file:`powerline/config.json` file.
|
:file:`powerline/config.json` file.
|
||||||
|
|
||||||
|
``term_24bit_colors``
|
||||||
|
Defines whether to output a cterm index (8-bit) or RGB colors (24-bit)
|
||||||
|
to the terminal emulator.
|
||||||
|
|
||||||
|
.. table:: 24-bit color support table
|
||||||
|
:name: term-rgb-color-support
|
||||||
|
|
||||||
|
================== =====================
|
||||||
|
Terminal emulator 24-bit color support
|
||||||
|
================== =====================
|
||||||
|
Gnome Terminal |supp_no|
|
||||||
|
Gvim |supp_no|
|
||||||
|
Konsole |supp_yes|
|
||||||
|
lxterminal |supp_no|
|
||||||
|
rxvt-unicode |supp_no|
|
||||||
|
st |supp_no|
|
||||||
|
Xfce Terminal |supp_no|
|
||||||
|
xterm |supp_partial| [#]_
|
||||||
|
================== =====================
|
||||||
|
|
||||||
|
.. |supp_yes| image:: _static/img/icons/tick.png
|
||||||
|
.. |supp_no| image:: _static/img/icons/cross.png
|
||||||
|
.. |supp_partial| image:: _static/img/icons/error.png
|
||||||
|
|
||||||
|
.. [#] Uses nearest color from 8-bit palette.
|
||||||
|
|
||||||
``dividers``
|
``dividers``
|
||||||
Defines the dividers used in all Powerline extensions. This option
|
Defines the dividers used in all Powerline extensions. This option
|
||||||
should usually only be changed if you don't have a patched font, or if
|
should usually only be changed if you don't have a patched font, or if
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"common": {
|
"common": {
|
||||||
|
"term_24bit_colors": false,
|
||||||
"dividers": {
|
"dividers": {
|
||||||
"left": {
|
"left": {
|
||||||
"hard": "",
|
"hard": "",
|
||||||
|
@ -46,7 +46,8 @@ class Powerline(object):
|
|||||||
renderer_module_import = 'powerline.renderers.{0}'.format(renderer_module_name)
|
renderer_module_import = 'powerline.renderers.{0}'.format(renderer_module_name)
|
||||||
renderer_class_name = '{0}Renderer'.format(underscore_to_camelcase(renderer_module_name))
|
renderer_class_name = '{0}Renderer'.format(underscore_to_camelcase(renderer_module_name))
|
||||||
Renderer = getattr(importlib.import_module(renderer_module_import), renderer_class_name)
|
Renderer = getattr(importlib.import_module(renderer_module_import), renderer_class_name)
|
||||||
self.renderer = Renderer(theme_config, local_themes, theme_kwargs)
|
self.renderer = Renderer(theme_config, local_themes, theme_kwargs,
|
||||||
|
term_24bit_colors=self.config.get('term_24bit_colors', False))
|
||||||
|
|
||||||
def add_local_theme(self, key, config):
|
def add_local_theme(self, key, config):
|
||||||
'''Add local themes at runtime (e.g. during vim session).
|
'''Add local themes at runtime (e.g. during vim session).
|
||||||
|
@ -9,12 +9,13 @@ class Renderer(object):
|
|||||||
ATTR_ITALIC = 2
|
ATTR_ITALIC = 2
|
||||||
ATTR_UNDERLINE = 4
|
ATTR_UNDERLINE = 4
|
||||||
|
|
||||||
TERM_24BIT = False
|
TERM_24BIT_COLORS = False
|
||||||
|
|
||||||
def __init__(self, theme_config, local_themes, theme_kwargs):
|
def __init__(self, theme_config, local_themes, theme_kwargs, term_24bit_colors=False):
|
||||||
self.theme = Theme(theme_config=theme_config, **theme_kwargs)
|
self.theme = Theme(theme_config=theme_config, **theme_kwargs)
|
||||||
self.local_themes = local_themes
|
self.local_themes = local_themes
|
||||||
self.theme_kwargs = theme_kwargs
|
self.theme_kwargs = theme_kwargs
|
||||||
|
self.TERM_24BIT_COLORS = term_24bit_colors
|
||||||
|
|
||||||
def add_local_theme(self, matcher, theme):
|
def add_local_theme(self, matcher, theme):
|
||||||
if matcher in self.local_themes:
|
if matcher in self.local_themes:
|
||||||
|
@ -17,7 +17,7 @@ class ShellRenderer(Renderer):
|
|||||||
if fg is False or fg[0] is False:
|
if fg is False or fg[0] is False:
|
||||||
ansi += [39]
|
ansi += [39]
|
||||||
else:
|
else:
|
||||||
if self.TERM_24BIT:
|
if self.TERM_24BIT_COLORS:
|
||||||
ansi += [38, 2] + list(self._int_to_rgb(fg[1]))
|
ansi += [38, 2] + list(self._int_to_rgb(fg[1]))
|
||||||
else:
|
else:
|
||||||
ansi += [38, 5, fg[0]]
|
ansi += [38, 5, fg[0]]
|
||||||
@ -25,7 +25,7 @@ class ShellRenderer(Renderer):
|
|||||||
if bg is False or bg[0] is False:
|
if bg is False or bg[0] is False:
|
||||||
ansi += [49]
|
ansi += [49]
|
||||||
else:
|
else:
|
||||||
if self.TERM_24BIT:
|
if self.TERM_24BIT_COLORS:
|
||||||
ansi += [48, 2] + list(self._int_to_rgb(bg[1]))
|
ansi += [48, 2] + list(self._int_to_rgb(bg[1]))
|
||||||
else:
|
else:
|
||||||
ansi += [48, 5, bg[0]]
|
ansi += [48, 5, bg[0]]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user