From f18a85db6906aae375b5681dcbd3892818c89d4d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 7 Dec 2016 10:19:17 +0530 Subject: [PATCH] Shortcuts to change active tab --- kitty/boss.py | 14 +++++++++++--- kitty/kitty.conf | 4 ++++ kitty/tabs.py | 6 ++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/kitty/boss.py b/kitty/boss.py index fb828ed70..d355cebc4 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -257,15 +257,17 @@ class Boss(Thread): self.start_cursor_blink() if action == GLFW_PRESS or action == GLFW_REPEAT: func = get_shortcut(self.opts.keymap, mods, key) - tab = self.active_tab - if tab is None: - return + import pprint + pprint.pprint(self.opts.keymap) if func is not None: f = getattr(self, func, None) if f is not None: passthrough = f() if not passthrough: return + tab = self.active_tab + if tab is None: + return window = self.active_window if window is not None: yield window @@ -428,4 +430,10 @@ class Boss(Thread): if w is not None: self.queue_action(w.paste, text) + def next_tab(self): + self.queue_action(self.tab_manager.next_tab) + + def previous_tab(self): + self.queue_action(self.tab_manager.next_tab, -1) + # }}} diff --git a/kitty/kitty.conf b/kitty/kitty.conf index 44eab444d..55567c379 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -142,3 +142,7 @@ map ctrl+shift+] next_window map ctrl+shift+[ previous_window map ctrl+shift+w close_window map ctrl+shift+l next_layout + +# Tab management +map ctrl+shift+right next_tab +map ctrl+shift+left previous_tab diff --git a/kitty/tabs.py b/kitty/tabs.py index e111f4336..51d4cb4c0 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -191,6 +191,12 @@ class TabManager: self.screen = s self.can_render = True + def next_tab(self, delta=1): + if len(self.tabs) > 1: + self.active_tab_idx = (self.active_tab_idx + len(self.tabs) + delta) % len(self.tabs) + self.tabbar_dirty = True + glfw_post_empty_event() + def __iter__(self): return iter(self.tabs)