Merge branch 'tab-open-implicit' of https://github.com/mlochbaum/qutebrowser into mlochbaum-tab-open-implicit

This commit is contained in:
Florian Bruhin 2016-08-03 09:16:49 +02:00
commit 1fb4aa3532
3 changed files with 45 additions and 32 deletions

View File

@ -115,7 +115,8 @@ class CommandDispatcher:
raise cmdexc.CommandError("No WebView available yet!")
return widget
def _open(self, url, tab=False, background=False, window=False):
def _open(self, url, tab=False, background=False, window=False,
explicit=True):
"""Helper function to open a page.
Args:
@ -131,9 +132,9 @@ class CommandDispatcher:
tabbed_browser = self._new_tabbed_browser()
tabbed_browser.tabopen(url)
elif tab:
tabbed_browser.tabopen(url, background=False, explicit=True)
tabbed_browser.tabopen(url, background=False, explicit=explicit)
elif background:
tabbed_browser.tabopen(url, background=True, explicit=True)
tabbed_browser.tabopen(url, background=True, explicit=explicit)
else:
widget = self._current_widget()
widget.openurl(url)
@ -232,7 +233,8 @@ class CommandDispatcher:
maxsplit=0, scope='window')
@cmdutils.argument('url', completion=usertypes.Completion.url)
@cmdutils.argument('count', count=True)
def openurl(self, url=None, bg=False, tab=False, window=False, count=None):
def openurl(self, url=None, implicit=False,
bg=False, tab=False, window=False, count=None):
"""Open a URL in the current/[count]th tab.
Args:
@ -240,6 +242,8 @@ class CommandDispatcher:
bg: Open in a new background tab.
tab: Open in a new tab.
window: Open in a new window.
implicit: If opening a new tab, treat the tab as implicit (like
clicking on a link).
count: The tab index to open the URL in, or None.
"""
if url is None:
@ -260,7 +264,7 @@ class CommandDispatcher:
message.error(self._win_id, str(e))
return
if tab or bg or window:
self._open(url, tab, bg, window)
self._open(url, tab, bg, window, not implicit)
else:
curtab = self._cntwidget(count)
if curtab is None:

View File

@ -1428,9 +1428,9 @@ KEY_DATA = collections.OrderedDict([
('set-cmd-text -s :open', ['o']),
('set-cmd-text :open {url:pretty}', ['go']),
('set-cmd-text -s :open -t', ['O']),
('set-cmd-text :open -t {url:pretty}', ['gO']),
('set-cmd-text :open -t -i {url:pretty}', ['gO']),
('set-cmd-text -s :open -b', ['xo']),
('set-cmd-text :open -b {url:pretty}', ['xO']),
('set-cmd-text :open -b -i {url:pretty}', ['xO']),
('set-cmd-text -s :open -w', ['wo']),
('set-cmd-text :open -w {url:pretty}', ['wO']),
('open -t', ['ga', '<Ctrl-T>']),
@ -1463,7 +1463,7 @@ KEY_DATA = collections.OrderedDict([
('hint images', [';i']),
('hint images tab', [';I']),
('hint links fill :open {hint-url}', [';o']),
('hint links fill :open -t {hint-url}', [';O']),
('hint links fill :open -t -i {hint-url}', [';O']),
('hint links yank', [';y']),
('hint links yank-primary', [';Y']),
('hint --rapid links tab-bg', [';r']),

View File

@ -43,31 +43,18 @@ Feature: Opening pages
When I run :tab-only
And I run :open -t http://localhost:(port)/data/numbers/4.txt
And I wait until data/numbers/4.txt is loaded
Then the session should look like:
windows:
- tabs:
- history:
- url: about:blank
- active: true
history:
- active: true
url: http://localhost:*/data/numbers/4.txt
Then the following tabs should be open:
- about:blank
- data/numbers/4.txt (active)
Scenario: Opening in a new background tab
Given I open about:blank
When I run :tab-only
And I run :open -b http://localhost:(port)/data/numbers/5.txt
And I wait until data/numbers/5.txt is loaded
Then the session should look like:
windows:
- tabs:
- active: true
history:
- active: true
url: about:blank
- history:
- active: true
url: http://localhost:*/data/numbers/5.txt
Then the following tabs should be open:
- about:blank (active)
- data/numbers/5.txt
Scenario: :open with count
Given I open about:blank
@ -86,11 +73,33 @@ Feature: Opening pages
- active: true
url: http://localhost:*/data/numbers/6.txt
Scenario: Opening in a new tab (explicit)
Given I open about:blank
When I set tabs -> new-tab-position-explicit to right
And I set tabs -> new-tab-position to left
And I run :tab-only
And I run :open -t http://localhost:(port)/data/numbers/7.txt
And I wait until data/numbers/7.txt is loaded
Then the following tabs should be open:
- about:blank
- data/numbers/7.txt (active)
Scenario: Opening in a new tab (implicit)
Given I open about:blank
When I set tabs -> new-tab-position-explicit to right
And I set tabs -> new-tab-position to left
And I run :tab-only
And I run :open -t -i http://localhost:(port)/data/numbers/8.txt
And I wait until data/numbers/8.txt is loaded
Then the following tabs should be open:
- data/numbers/8.txt (active)
- about:blank
Scenario: Opening in a new window
Given I open about:blank
When I run :tab-only
And I run :open -w http://localhost:(port)/data/numbers/7.txt
And I wait until data/numbers/7.txt is loaded
And I run :open -w http://localhost:(port)/data/numbers/9.txt
And I wait until data/numbers/9.txt is loaded
Then the session should look like:
windows:
- tabs:
@ -102,9 +111,9 @@ Feature: Opening pages
- active: true
history:
- active: true
url: http://localhost:*/data/numbers/7.txt
url: http://localhost:*/data/numbers/9.txt
Scenario: Opening a quickmark
When I run :quickmark-add http://localhost:(port)/data/numbers/8.txt quickmarktest
When I run :quickmark-add http://localhost:(port)/data/numbers/10.txt quickmarktest
And I run :open quickmarktest
Then data/numbers/8.txt should be loaded
Then data/numbers/10.txt should be loaded