diff --git a/kitty/kitty.conf b/kitty/kitty.conf index f3534763b..95aaeb53a 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -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 diff --git a/kitty/layout.py b/kitty/layout.py index 13aea2ef9..0f239364b 100644 --- a/kitty/layout.py +++ b/kitty/layout.py @@ -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 diff --git a/kitty/tabs.py b/kitty/tabs.py index 4fbab11d4..23bd74471 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -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)