From d31459b0926f2afddc317d76314e4afd0d07d473 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 15 Oct 2024 11:45:47 +0530 Subject: [PATCH] tab_title_template allow using the 256 terminal colors for formatting --- docs/changelog.rst | 2 ++ kitty/options/definition.py | 1 + kitty/tab_bar.py | 2 ++ 3 files changed, 5 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5be8440dd..fc189752f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 338029491..8e12004dc 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -1399,6 +1399,7 @@ use styling directives, for example: ``{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. diff --git a/kitty/tab_bar.py b/kitty/tab_bar.py index dc68764cb..6dd6a6a9c 100644 --- a/kitty/tab_bar.py +++ b/kitty/tab_bar.py @@ -118,6 +118,8 @@ class ColorFormatter: 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:]}'