termstr: Coding style

- Add rgb color properties to char styles.
This commit is contained in:
Andrew Hamilton 2022-04-30 13:35:55 +10:00
parent 21a9ec2826
commit 960cc57559
2 changed files with 13 additions and 11 deletions

View file

@ -165,14 +165,10 @@ def highlight_str(line, highlight_color, transparency):
@functools.lru_cache(maxsize=500)
def blend_style(style):
fg_color = (style.fg_color if type(style.fg_color) == tuple
else termstr.XTERM_COLORS[style.fg_color])
bg_color = (style.bg_color if type(style.bg_color) == tuple
else termstr.XTERM_COLORS[style.bg_color])
return termstr.CharStyle(
termstr.blend_color(fg_color, highlight_color, transparency),
termstr.blend_color(bg_color, highlight_color, transparency), is_bold=style.is_bold,
is_italic=style.is_italic, is_underlined=style.is_underlined)
termstr.blend_color(style.fg_rgb_color, highlight_color, transparency),
termstr.blend_color(style.bg_rgb_color, highlight_color, transparency),
is_bold=style.is_bold, is_italic=style.is_italic, is_underlined=style.is_underlined)
return termstr.TermStr(line).transform_style(blend_style)