Shortcuts to change active tab

This commit is contained in:
Kovid Goyal 2016-12-07 10:19:17 +05:30
parent 1b67195b7c
commit f18a85db69
3 changed files with 21 additions and 3 deletions

View File

@ -257,15 +257,17 @@ class Boss(Thread):
self.start_cursor_blink() self.start_cursor_blink()
if action == GLFW_PRESS or action == GLFW_REPEAT: if action == GLFW_PRESS or action == GLFW_REPEAT:
func = get_shortcut(self.opts.keymap, mods, key) func = get_shortcut(self.opts.keymap, mods, key)
tab = self.active_tab import pprint
if tab is None: pprint.pprint(self.opts.keymap)
return
if func is not None: if func is not None:
f = getattr(self, func, None) f = getattr(self, func, None)
if f is not None: if f is not None:
passthrough = f() passthrough = f()
if not passthrough: if not passthrough:
return return
tab = self.active_tab
if tab is None:
return
window = self.active_window window = self.active_window
if window is not None: if window is not None:
yield window yield window
@ -428,4 +430,10 @@ class Boss(Thread):
if w is not None: if w is not None:
self.queue_action(w.paste, text) 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)
# }}} # }}}

View File

@ -142,3 +142,7 @@ map ctrl+shift+] next_window
map ctrl+shift+[ previous_window map ctrl+shift+[ previous_window
map ctrl+shift+w close_window map ctrl+shift+w close_window
map ctrl+shift+l next_layout map ctrl+shift+l next_layout
# Tab management
map ctrl+shift+right next_tab
map ctrl+shift+left previous_tab

View File

@ -191,6 +191,12 @@ class TabManager:
self.screen = s self.screen = s
self.can_render = True 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): def __iter__(self):
return iter(self.tabs) return iter(self.tabs)