mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-26 19:01:27 +00:00
DRYer
This commit is contained in:
parent
08d84aa211
commit
522aa7805b
2 changed files with 6 additions and 9 deletions
|
|
@ -815,15 +815,9 @@ class Tab: # {{{
|
|||
overlay_for = window.id
|
||||
|
||||
def set_active_window(self, x: Window | int, for_keep_focus: Window | None = None) -> None:
|
||||
if isinstance(x, int):
|
||||
for q in self:
|
||||
if q.id == x:
|
||||
x = q
|
||||
break
|
||||
else:
|
||||
return
|
||||
self.windows.set_active_window_group_for(x, for_keep_focus=for_keep_focus)
|
||||
self.windows.move_window_to_top_of_group(x)
|
||||
if (w := self.windows.window_for_id(x) if isinstance(x, int) else x) is not None:
|
||||
self.windows.set_active_window_group_for(w, for_keep_focus=for_keep_focus)
|
||||
self.windows.move_window_to_top_of_group(w)
|
||||
|
||||
def get_nth_window(self, n: int) -> Window | None:
|
||||
if self.windows:
|
||||
|
|
|
|||
|
|
@ -340,6 +340,9 @@ class WindowList:
|
|||
def num_groups(self) -> int:
|
||||
return len(self.groups)
|
||||
|
||||
def window_for_id(self, x: int) -> WindowType | None:
|
||||
return self.id_map.get(x)
|
||||
|
||||
def group_for_window(self, x: WindowOrId) -> WindowGroup | None:
|
||||
q = self.id_map[x] if isinstance(x, int) else x
|
||||
for g in self.groups:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue