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
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
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`)
- :opt:`tab_title_template` allow using the 256 terminal colors for formatting (:disc:`7976`)
0.36.4 [2024-09-27]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -1399,6 +1399,7 @@
``{fmt.fg.red}red{fmt.fg.tab}normal{fmt.bg._00FF00}greenbg{fmt.bg.tab}``.
Similarly, for bold and italic:
``{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
:code:`{activity_symbol}` are not present in the template, they are prepended to
it.

View file

@ -118,6 +118,8 @@ def __getattr__(self, name: str) -> str:
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))
ans = f'8{color_as_sgr(col)}'
elif q.startswith('color'):
ans = f'8:5:{int(q[5:])}'
else:
if name.startswith('_'):
q = f'#{name[1:]}'