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

View File

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

View File

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