From 3627621fd220f62d5217add194d4a4437cba37b4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 28 Mar 2026 13:46:25 +0530 Subject: [PATCH] DRYer --- kitty/tab_bar.py | 34 +++++++++++++++++----------------- kitty/tabs.py | 9 ++------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/kitty/tab_bar.py b/kitty/tab_bar.py index d52bfa389..ccc121b3b 100644 --- a/kitty/tab_bar.py +++ b/kitty/tab_bar.py @@ -38,23 +38,23 @@ from .utils import color_as_int, log_error, sgr_sanitizer_pat class TabBarData(NamedTuple): title: str - is_active: bool - needs_attention: bool - tab_id: int - os_window_id: int - num_windows: int - num_window_groups: int - layout_name: str - has_activity_since_last_focus: bool - active_fg: int | None - active_bg: int | None - inactive_fg: int | None - inactive_bg: int | None - num_of_windows_with_progress: int - total_progress: int - last_focused_window_with_progress_id: int - session_name: str - active_session_name: str + is_active: bool = False + needs_attention: bool = False + tab_id: int = -1 + os_window_id: int = 0 + num_windows: int = 0 + num_window_groups: int = 0 + layout_name: str = '' + has_activity_since_last_focus: bool = False + active_fg: int | None = None + active_bg: int | None = None + inactive_fg: int | None = None + inactive_bg: int | None = None + num_of_windows_with_progress: int = 0 + total_progress: int = 0 + last_focused_window_with_progress_id: int = 0 + session_name: str = '' + active_session_name: str = '' class DrawData(NamedTuple): diff --git a/kitty/tabs.py b/kitty/tabs.py index d4a0dd1c0..23e2a7d36 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -1602,12 +1602,6 @@ class TabManager: # {{{ self.mark_tab_bar_dirty() removed_tab.destroy() - def _new_tab_drop_indicator(self) -> TabBarData: - return TabBarData( - '+', self.window_drag_target_tab_id == -1, False, -1, self.os_window_id, - 0, 0, '', False, None, None, None, None, 0, 0, 0, '', '', - ) - @property def tab_bar_data(self) -> Sequence[TabBarData]: at = self.active_tab @@ -1623,7 +1617,8 @@ class TabManager: # {{{ else: tabs = tuple(t.data_for_tab_bar(t is at or t.id == wdtt) for t in self.tabs_to_be_shown_in_tab_bar) if window_drag_active or get_options().tab_bar_show_new_tab_button: - tabs = tabs + (self._new_tab_drop_indicator(),) + tabs = tabs + (TabBarData( + title='+', is_active=self.window_drag_target_tab_id == -1, os_window_id=self.os_window_id),) return tabs tmap = {t.id:t for t in self.tabs} at = self.active_tab