Shortcuts to change active tab
This commit is contained in:
parent
1b67195b7c
commit
f18a85db69
3 changed files with 21 additions and 3 deletions
|
|
@ -257,15 +257,17 @@ def on_key(self, window, key, scancode, action, mods):
|
|||
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 @@ def paste_from_clipboard(self):
|
|||
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)
|
||||
|
||||
# }}}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -191,6 +191,12 @@ def resize(self, only_tabs=False):
|
|||
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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue