tab_title_template allow using the 256 terminal colors for formatting

This commit is contained in:
Kovid Goyal
2024-10-15 11:45:47 +05:30
parent 62d5e13cbd
commit d31459b092
3 changed files with 5 additions and 0 deletions

View File

@@ -81,6 +81,8 @@ Detailed list of changes
- kitten icat: Fix the :option:`kitty +kitten icat --no-trailing-newline` not working when using unicode placeholders (:iss:`7948`) - kitten icat: Fix the :option:`kitty +kitten icat --no-trailing-newline` not working when using unicode placeholders (:iss:`7948`)
- :opt:`tab_title_template` allow using the 256 terminal colors for formatting (:disc:`7976`)
0.36.4 [2024-09-27] 0.36.4 [2024-09-27]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -1399,6 +1399,7 @@ use styling directives, for example:
``{fmt.fg.red}red{fmt.fg.tab}normal{fmt.bg._00FF00}greenbg{fmt.bg.tab}``. ``{fmt.fg.red}red{fmt.fg.tab}normal{fmt.bg._00FF00}greenbg{fmt.bg.tab}``.
Similarly, for bold and italic: Similarly, for bold and italic:
``{fmt.bold}bold{fmt.nobold}normal{fmt.italic}italic{fmt.noitalic}``. ``{fmt.bold}bold{fmt.nobold}normal{fmt.italic}italic{fmt.noitalic}``.
The 256 eight terminal colors can be used as ``fmt.fg.color0`` through ``fmt.fg.color255``.
Note that for backward compatibility, if :code:`{bell_symbol}` or Note that for backward compatibility, if :code:`{bell_symbol}` or
:code:`{activity_symbol}` are not present in the template, they are prepended to :code:`{activity_symbol}` are not present in the template, they are prepended to
it. it.

View File

@@ -118,6 +118,8 @@ class ColorFormatter:
elif q == 'tab': elif q == 'tab':
col = color_from_int((self.draw_data.tab_bg if self.which == '4' else self.draw_data.tab_fg)(self.tab_data)) col = color_from_int((self.draw_data.tab_bg if self.which == '4' else self.draw_data.tab_fg)(self.tab_data))
ans = f'8{color_as_sgr(col)}' ans = f'8{color_as_sgr(col)}'
elif q.startswith('color'):
ans = f'8:5:{int(q[5:])}'
else: else:
if name.startswith('_'): if name.startswith('_'):
q = f'#{name[1:]}' q = f'#{name[1:]}'