Add window groups to kitty @ ls output

Fixes #6655
This commit is contained in:
Kovid Goyal
2023-09-26 18:41:52 +05:30
parent bda9155be1
commit ef7d4934d2
2 changed files with 11 additions and 0 deletions

View File

@@ -81,6 +81,7 @@ class TabDict(TypedDict):
layout_opts: Dict[str, Any] layout_opts: Dict[str, Any]
enabled_layouts: List[str] enabled_layouts: List[str]
windows: List[WindowDict] windows: List[WindowDict]
groups: List[Dict[str, Any]]
active_window_history: List[int] active_window_history: List[int]
@@ -781,6 +782,9 @@ class Tab: # {{{
is_focused=w.os_window_id == current_focused_os_window_id() and w is active_window, is_focused=w.os_window_id == current_focused_os_window_id() and w is active_window,
is_self=w is self_window) is_self=w is self_window)
def list_groups(self) -> List[Dict[str, Any]]:
return [g.as_simple_dict() for g in self.windows.groups]
def matches_query(self, field: str, query: str, active_tab_manager: Optional['TabManager'] = None) -> bool: def matches_query(self, field: str, query: str, active_tab_manager: Optional['TabManager'] = None) -> bool:
if field == 'title': if field == 'title':
return re.search(query, self.effective_title) is not None return re.search(query, self.effective_title) is not None
@@ -1036,6 +1040,7 @@ class TabManager: # {{{
'layout_opts': tab.current_layout.layout_opts.serialized(), 'layout_opts': tab.current_layout.layout_opts.serialized(),
'enabled_layouts': tab.enabled_layouts, 'enabled_layouts': tab.enabled_layouts,
'windows': windows, 'windows': windows,
'groups': tab.list_groups(),
'active_window_history': list(tab.windows.active_window_history), 'active_window_history': list(tab.windows.active_window_history),
} }

View File

@@ -91,6 +91,12 @@ class WindowGroup:
'windows': [w.serialize_state() for w in self.windows] 'windows': [w.serialize_state() for w in self.windows]
} }
def as_simple_dict(self) -> Dict[str, Any]:
return {
'id': self.id,
'windows': [w.id for w in self.windows],
}
def decoration(self, which: EdgeLiteral, border_mult: int = 1, is_single_window: bool = False) -> int: def decoration(self, which: EdgeLiteral, border_mult: int = 1, is_single_window: bool = False) -> int:
if not self.windows: if not self.windows:
return 0 return 0