Merge branch 'edit-url' of https://github.com/rcorre/qutebrowser into rcorre-edit-url

This commit is contained in:
Florian Bruhin 2016-04-05 18:28:50 +02:00
commit 332e045f54
2 changed files with 39 additions and 0 deletions

View File

@ -20,6 +20,7 @@
|<<download-open,download-open>>|Open the last/[count]th download.
|<<download-remove,download-remove>>|Remove the last/[count]th download from the list.
|<<download-retry,download-retry>>|Retry the first failed/[count]th download.
|<<edit-url,edit-url>>|Compose a url in an external editor and navigate to it.
|<<fake-key,fake-key>>|Send a fake keypress or key string to the website or qutebrowser.
|<<forward,forward>>|Go forward in the history of the current tab.
|<<fullscreen,fullscreen>>|Toggle fullscreen mode.
@ -223,6 +224,21 @@ Retry the first failed/[count]th download.
==== count
The index of the download to retry.
[[edit-url]]
=== edit-url
Syntax: +:edit-url [*--bg*] [*--tab*] [*--window*] ['url']+
Open a URL in an external editor and navigate to it upon closing the editor.
==== optional arguments
* +'url'+: A URL to pre-populate the editor with; defaults to the current URL.
* +*-b*+, +*--bg*+: Open in a new background tab.
* +*-t*+, +*--tab*+: Open in a new tab.
* +*-w*+, +*--window*+: Open in a new window.
==== count
The tab index to open the URL in.
[[fake-key]]
=== fake-key
Syntax: +:fake-key [*--global*] 'keystring'+

View File

@ -1847,3 +1847,26 @@ class CommandDispatcher:
"""Clear remembered SSL error answers."""
nam = self._current_widget().page().networkAccessManager()
nam.clear_all_ssl_errors()
@cmdutils.register(instance='command-dispatcher', scope='window')
def edit_url(self, url=None, bg=False, tab=False, window=False, count=None):
"""Navigate to a url formed in an external editor.
The editor which should be launched can be configured via the
`general -> editor` config option.
Args:
url: URL to edit; defaults to the current page url.
bg: Open in a new background tab.
tab: Open in a new tab.
window: Open in a new window.
count: The tab index to open the URL in, or None.
"""
ed = editor.ExternalEditor(self._win_id, self._tabbed_browser)
# Passthrough for openurl args (e.g. -t, -b, -w)
ed.editing_finished.connect(
functools.partial(self.openurl,
bg=bg, tab=tab, window=window, count=count))
ed.edit(url or self._current_url().toString())