parent
b86f79cf9e
commit
2d6ee2655c
|
@ -9,6 +9,8 @@ class Renderer(object):
|
|||
ATTR_ITALIC = 2
|
||||
ATTR_UNDERLINE = 4
|
||||
|
||||
TERM_24BIT = False
|
||||
|
||||
def __init__(self, theme_config, local_themes, theme_kwargs):
|
||||
self.theme = Theme(theme_config=theme_config, **theme_kwargs)
|
||||
self.local_themes = local_themes
|
||||
|
@ -138,5 +140,12 @@ class Renderer(object):
|
|||
'''
|
||||
return len(''.join([segment['rendered_raw'] for segment in segments]))
|
||||
|
||||
@staticmethod
|
||||
def _int_to_rgb(int):
|
||||
r = (int >> 16) & 0xff
|
||||
g = (int >> 8) & 0xff
|
||||
b = int & 0xff
|
||||
return r, g, b
|
||||
|
||||
def hl(self, fg=None, bg=None, attr=None):
|
||||
raise NotImplementedError
|
||||
|
|
|
@ -17,12 +17,18 @@ class ShellRenderer(Renderer):
|
|||
if fg is False or fg[0] is False:
|
||||
ansi += [39]
|
||||
else:
|
||||
ansi += [38, 5, fg[0]]
|
||||
if self.TERM_24BIT:
|
||||
ansi += [38, 2] + list(self._int_to_rgb(fg[1]))
|
||||
else:
|
||||
ansi += [38, 5, fg[0]]
|
||||
if bg is not None:
|
||||
if bg is False or bg[0] is False:
|
||||
ansi += [49]
|
||||
else:
|
||||
ansi += [48, 5, bg[0]]
|
||||
if self.TERM_24BIT:
|
||||
ansi += [48, 2] + list(self._int_to_rgb(bg[1]))
|
||||
else:
|
||||
ansi += [48, 5, bg[0]]
|
||||
if attr is not None:
|
||||
if attr is False:
|
||||
ansi += [22]
|
||||
|
|
Loading…
Reference in New Issue