Add T command / refactor focus_tab
This commit is contained in:
parent
e6af8bb7ae
commit
87e94a2c68
3
TODO
3
TODO
@ -284,9 +284,6 @@ Open quickmark in a new tab (command tab_quickmark, aliases: tabqmarks).
|
||||
tab-handling
|
||||
------------
|
||||
|
||||
[n]T
|
||||
Focus nth tab, first tab if n is omitted or last tab if n is 0. (command focus_tab, aliases: tab).
|
||||
|
||||
C-Tab
|
||||
Toggle between current and last focused tab (command toggle_tab, aliases: ttab)
|
||||
|
||||
|
@ -548,6 +548,7 @@ DATA = OrderedDict([
|
||||
('ga', 'tabopen about:blank'),
|
||||
('d', 'tabclose'),
|
||||
('co', 'only'),
|
||||
('T', 'focus_tab'),
|
||||
('J', 'tabnext'),
|
||||
('K', 'tabprev'),
|
||||
('r', 'reload'),
|
||||
|
@ -364,15 +364,23 @@ class TabbedBrowser(TabWidget):
|
||||
Args:
|
||||
index: The tab index to focus, starting with 1.
|
||||
"""
|
||||
if ((index is None and count is None) or
|
||||
(index is not None and count is not None)):
|
||||
if index is not None and count is not None:
|
||||
message.error("Either argument or count must be given!")
|
||||
return
|
||||
try:
|
||||
idx = int(index) if index is not None else count
|
||||
except ValueError:
|
||||
message.error("Argument ({}) needs to be a number!".format(index))
|
||||
return
|
||||
elif index is not None:
|
||||
try:
|
||||
idx = int(index)
|
||||
except ValueError:
|
||||
message.error("Argument ({}) needs to be a number!".format(
|
||||
index))
|
||||
return
|
||||
elif count is not None:
|
||||
if count == 0:
|
||||
idx = self.count()
|
||||
else:
|
||||
idx = count
|
||||
else:
|
||||
idx = 1
|
||||
if 1 <= idx <= self.count():
|
||||
self.setCurrentIndex(idx - 1)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user