Allow using neighboring window operations in the stack layout

This commit is contained in:
Kovid Goyal
2021-07-09 08:54:22 +05:30
parent f62f94381e
commit 75b73f6821
2 changed files with 15 additions and 1 deletions

View File

@@ -21,6 +21,10 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Fix turning off cursor blink via escape codes not working (:iss:`3808`)
- Allow using neighboring window operations in the stack layout. The previous
window is considered the left and top neighbor and the next window is
considered the bottom and right neighbor (:iss:`3778`)
0.21.2 [2021-06-28]
----------------------

View File

@@ -2,9 +2,10 @@
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
from kitty.typing import WindowType
from kitty.window_list import WindowList
from .base import Layout
from .base import Layout, NeighborsMap
class Stack(Layout):
@@ -17,3 +18,12 @@ class Stack(Layout):
active_group = all_windows.active_group
for group in all_windows.iter_all_layoutable_groups():
self.layout_single_window_group(group, add_blank_rects=group is active_group)
def neighbors_for_window(self, window: WindowType, all_windows: WindowList) -> NeighborsMap:
wg = all_windows.group_for_window(window)
assert wg is not None
groups = tuple(all_windows.iter_all_layoutable_groups())
idx = groups.index(wg)
before = [] if wg is groups[0] else [groups[idx-1].id]
after = [] if wg is groups[-1] else [groups[idx+1].id]
return {'top': before, 'left': before, 'right': after, 'bottom': after}