mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 07:55:10 +02:00
Finish serialization to session file
This commit is contained in:
@@ -501,6 +501,16 @@ class Boss:
|
|||||||
'background_opacity': bo,
|
'background_opacity': bo,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def serialize_state_as_session(self) -> Iterator[str]:
|
||||||
|
s = {current_focused_os_window_id(): 2, last_focused_os_window_id(): 1}
|
||||||
|
|
||||||
|
def skey(os_window_id: int) -> int:
|
||||||
|
return s.get(os_window_id, 0)
|
||||||
|
|
||||||
|
for os_window_id in sorted(self.os_window_map, key=skey):
|
||||||
|
tm = self.os_window_map[os_window_id]
|
||||||
|
yield from tm.serialize_state_as_session()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def all_tab_managers(self) -> Iterator[TabManager]:
|
def all_tab_managers(self) -> Iterator[TabManager]:
|
||||||
yield from self.os_window_map.values()
|
yield from self.os_window_map.values()
|
||||||
|
|||||||
@@ -1186,6 +1186,22 @@ class TabManager: # {{{
|
|||||||
'active_tab_idx': self.active_tab_idx,
|
'active_tab_idx': self.active_tab_idx,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def serialize_state_as_session(self) -> list[str]:
|
||||||
|
tmap = {tab.id: tab for tab in self}
|
||||||
|
ans = []
|
||||||
|
for tab_id in self.active_tab_history:
|
||||||
|
tab = tmap.get(tab_id)
|
||||||
|
if tab is not None:
|
||||||
|
ans.extend(tab.serialize_state_as_session())
|
||||||
|
if ans:
|
||||||
|
prefix = ['new_os_window']
|
||||||
|
if self.wm_class:
|
||||||
|
prefix.append(f'os_window_class {self.wm_class}')
|
||||||
|
if self.wm_name:
|
||||||
|
prefix.append(f'os_window_name {self.wm_name}')
|
||||||
|
ans = prefix + ans
|
||||||
|
return ans
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def active_tab(self) -> Tab | None:
|
def active_tab(self) -> Tab | None:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user