Add a new `neighboring_window` function to switch to neighboring windows in the current layout, similar to window movement in vim

Fixes #916
This commit is contained in:
Kovid Goyal
2018-09-08 08:59:11 +05:30
parent 9329b2c202
commit e39635ea16
5 changed files with 34 additions and 3 deletions

View File

@@ -271,6 +271,14 @@ class Tab: # {{{
def previous_window(self):
self._next_window(-1)
def neighboring_window(self, which):
neighbors = self.current_layout.neighbors(self.windows, self.active_window_idx)
candidates = neighbors.get(which)
if candidates:
self.active_window_idx = self.current_layout.set_active_window(self.windows, candidates[0])
self.relayout_borders()
glfw_post_empty_event()
def move_window(self, delta=1):
self.active_window_idx = self.current_layout.move_window(self.windows, self.active_window_idx, delta)
self.relayout()