Implement shortcut for previous window
This commit is contained in:
parent
3ae25bc374
commit
cbe1cf58e8
@ -131,5 +131,6 @@ map ctrl+shift+end scroll_end
|
||||
# Window management
|
||||
map ctrl+shift+enter new_window
|
||||
map ctrl+shift+] next_window
|
||||
map ctrl+shift+[ previous_window
|
||||
map ctrl+shift+w close_window
|
||||
map ctrl+shift+l next_layout
|
||||
|
||||
@ -39,8 +39,8 @@ class Layout:
|
||||
self.opts = opts
|
||||
self.border_width = border_width
|
||||
|
||||
def next_window(self, windows, active_window_idx):
|
||||
active_window_idx = (active_window_idx + 1) % len(windows)
|
||||
def next_window(self, windows, active_window_idx, delta=1):
|
||||
active_window_idx = (active_window_idx + len(windows) + delta) % len(windows)
|
||||
self.set_active_window(windows, active_window_idx)
|
||||
return active_window_idx
|
||||
|
||||
|
||||
@ -146,12 +146,18 @@ class Tab:
|
||||
self.borders(self.windows, self.active_window, self.current_layout.needs_window_borders and len(self.windows) > 1)
|
||||
glfw_post_empty_event()
|
||||
|
||||
def next_window(self):
|
||||
def _next_window(self, delta=1):
|
||||
if len(self.windows) > 1:
|
||||
self.active_window_idx = self.current_layout.next_window(self.windows, self.active_window_idx)
|
||||
self.active_window_idx = self.current_layout.next_window(self.windows, self.active_window_idx, delta)
|
||||
self.borders(self.windows, self.active_window, self.current_layout.needs_window_borders and len(self.windows) > 1)
|
||||
glfw_post_empty_event()
|
||||
|
||||
def next_window(self):
|
||||
self._next_window()
|
||||
|
||||
def previous_window(self):
|
||||
self._next_window(-1)
|
||||
|
||||
def __iter__(self):
|
||||
yield from iter(self.windows)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user