Shortcuts to open and close tabs

This commit is contained in:
Kovid Goyal 2016-12-07 10:52:57 +05:30
parent c387a7897a
commit c205604294
3 changed files with 13 additions and 4 deletions

View File

@ -434,4 +434,6 @@ class Boss(Thread):
def previous_tab(self):
self.queue_action(self.tab_manager.next_tab, -1)
def new_tab(self):
self.tab_manager.new_tab()
# }}}

View File

@ -144,5 +144,7 @@ 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
map ctrl+shift+right next_tab
map ctrl+shift+left previous_tab
map ctrl+shift+t new_tab
map ctrl+shift+q close_tab

View File

@ -29,12 +29,13 @@ class Tab:
self.active_window_idx = 0
if session_tab is None:
self.cwd = args.directory
self.current_layout = self.enabled_layouts[0]
l = self.enabled_layouts[0]
queue_action(self.new_window)
else:
self.cwd = session_tab.cwd or args.directory
self.current_layout = all_layouts[session_tab.layout](opts, self.borders.border_width, self.windows)
l = session_tab.layout
queue_action(self.startup, session_tab)
self.current_layout = all_layouts[l](opts, self.borders.border_width, self.windows)
def startup(self, session_tab):
for cmd in session_tab.windows:
@ -210,6 +211,10 @@ class TabManager:
def __len__(self):
return len(self.tabs)
def new_tab(self):
self.active_tab_idx = len(self.tabs)
self.tabs.append(Tab(self.opts, self.args, self.title_changed))
@property
def active_tab(self):
return self.tabs[self.active_tab_idx] if self.tabs else None