Add a new variable `{num_window_groups}` for tab_title_template

See #3837
This commit is contained in:
Kovid Goyal
2021-07-16 19:25:24 +05:30
parent d55a86e39b
commit 4b889750db
4 changed files with 15 additions and 3 deletions

View File

@@ -28,6 +28,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- macOS: Render colors in the sRGB colorspace to match other macOS terminal
applications (:iss:`2249`)
- Add a new variable ``{num_window_groups}`` for the :opt:`tab_title_template`
(:iss:`3837`)
0.21.2 [2021-06-28]
----------------------

View File

@@ -941,8 +941,10 @@ A template to render the tab title. The default just renders the title. If you
wish to include the tab-index as well, use something like: :code:`{index}:
{title}`. Useful if you have shortcuts mapped for :code:`goto_tab N`. If you
prefer to see the index as a superscript, use {sup.index}. In
addition you can use :code:`{layout_name}` for the current layout name and
:code:`{num_windows}` for the number of windows in the tab. Note that formatting
addition you can use :code:`{layout_name}` for the current layout name,
:code:`{num_windows}` for the number of windows in the tab and
:code:`{num_window_groups}` for the number of window groups
(not counting overlay windows) in the tab. Note that formatting
is done by Python's string formatting machinery, so you can use, for instance,
:code:`{layout_name[:2].upper()}` to show only the first two letters of the
layout name, upper-cased. If you want to style the text, you can use styling

View File

@@ -23,6 +23,7 @@ class TabBarData(NamedTuple):
is_active: bool
needs_attention: bool
num_windows: int
num_window_groups: int
layout_name: str
has_activity_since_last_focus: bool
@@ -135,12 +136,14 @@ def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int)
'index': index,
'layout_name': tab.layout_name,
'num_windows': tab.num_windows,
'num_window_groups': tab.num_window_groups,
'title': tab.title,
}
eval_locals = {
'index': index,
'layout_name': tab.layout_name,
'num_windows': tab.num_windows,
'num_window_groups': tab.num_window_groups,
'title': tab.title,
'fmt': Formatter,
'sup': SupSub(data),

View File

@@ -577,6 +577,10 @@ class Tab: # {{{
def __len__(self) -> int:
return len(self.windows)
@property
def num_window_groups(self) -> int:
return self.windows.num_groups
def __contains__(self, window: Window) -> bool:
return window in self.windows
@@ -874,7 +878,7 @@ class TabManager: # {{{
has_activity_since_last_focus = True
ans.append(TabBarData(
title, t is at, needs_attention,
len(t), t.current_layout.name or '',
len(t), t.num_window_groups, t.current_layout.name or '',
has_activity_since_last_focus
))
return ans