Allow showing the name of the current layout and the number of windows in tab titles
Fixes #2634
This commit is contained in:
parent
6edf00e699
commit
28fc9c69da
4 changed files with 25 additions and 6 deletions
|
|
@ -8,6 +8,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
|||
0.17.4 [future]
|
||||
--------------------
|
||||
|
||||
- Allow showing the name of the current layout and the number of windows
|
||||
in tab titles (:iss:`2634`)
|
||||
|
||||
- macOS: Fix a regression in the previous release that caused ligatures to be
|
||||
not be centered horizontally (:iss:`2591`)
|
||||
|
||||
|
|
|
|||
|
|
@ -870,6 +870,11 @@ def active_tab_title_template(x: str) -> Optional[str]:
|
|||
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`.
|
||||
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 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.
|
||||
'''))
|
||||
o('active_tab_title_template', 'none', option_type=active_tab_title_template, long_text=_('''
|
||||
Template to use for active tabs, if not specified falls back
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ class TabBarData(NamedTuple):
|
|||
title: str
|
||||
is_active: bool
|
||||
needs_attention: bool
|
||||
num_windows: int
|
||||
layout_name: str
|
||||
|
||||
|
||||
class DrawData(NamedTuple):
|
||||
|
|
@ -56,7 +58,7 @@ def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int)
|
|||
if tab.is_active and draw_data.active_title_template is not None:
|
||||
template = draw_data.active_title_template
|
||||
try:
|
||||
title = template.format(title=tab.title, index=index)
|
||||
title = template.format(title=tab.title, index=index, layout_name=tab.layout_name, num_windows=tab.num_windows)
|
||||
except Exception as e:
|
||||
if template not in template_failures:
|
||||
template_failures.add(template)
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ def _set_current_layout(self, layout_name: str) -> None:
|
|||
self._last_used_layout = self._current_layout_name
|
||||
self.current_layout = self.create_layout_object(layout_name)
|
||||
self._current_layout_name = layout_name
|
||||
self.mark_tab_bar_dirty()
|
||||
|
||||
def startup(self, session_tab: 'SessionTab') -> None:
|
||||
for cmd in session_tab.windows:
|
||||
|
|
@ -183,10 +184,13 @@ def active_window_idx(self, val: int) -> None:
|
|||
old_active_window.focus_changed(False)
|
||||
if new_active_window is not None:
|
||||
new_active_window.focus_changed(True)
|
||||
tm = self.tab_manager_ref()
|
||||
if tm is not None:
|
||||
self.relayout_borders()
|
||||
tm.mark_tab_bar_dirty()
|
||||
self.relayout_borders()
|
||||
self.mark_tab_bar_dirty()
|
||||
|
||||
def mark_tab_bar_dirty(self) -> None:
|
||||
tm = self.tab_manager_ref()
|
||||
if tm is not None:
|
||||
tm.mark_tab_bar_dirty()
|
||||
|
||||
@property
|
||||
def active_window(self) -> Optional[Window]:
|
||||
|
|
@ -330,6 +334,7 @@ def launch_child(
|
|||
def _add_window(self, window: Window, location: Optional[str] = None) -> None:
|
||||
self.active_window_idx = self.current_layout.add_window(self.windows, window, self.active_window_idx, location)
|
||||
self.relayout_borders()
|
||||
self.mark_tab_bar_dirty()
|
||||
|
||||
def new_window(
|
||||
self,
|
||||
|
|
@ -431,6 +436,7 @@ def remove_window(self, window: Window, destroy: bool = True) -> None:
|
|||
else:
|
||||
self.active_window_idx = active_window_idx
|
||||
self.relayout_borders()
|
||||
self.mark_tab_bar_dirty()
|
||||
active_window = self.active_window
|
||||
if active_window:
|
||||
self.title_changed(active_window)
|
||||
|
|
@ -804,7 +810,10 @@ def tab_bar_data(self) -> List[TabBarData]:
|
|||
if w.needs_attention:
|
||||
needs_attention = True
|
||||
break
|
||||
ans.append(TabBarData(title, t is at, needs_attention))
|
||||
ans.append(TabBarData(
|
||||
title, t is at, needs_attention,
|
||||
len(t), t.current_layout.name or ''
|
||||
))
|
||||
return ans
|
||||
|
||||
def activate_tab_at(self, x: int) -> None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue