Merge branch 'yank-domain' of https://github.com/Carpetsmoker/qutebrowser into Carpetsmoker-yank-domain
This commit is contained in:
commit
c907572557
@ -642,13 +642,14 @@ Save open pages and quit.
|
|||||||
|
|
||||||
[[yank]]
|
[[yank]]
|
||||||
=== yank
|
=== yank
|
||||||
Syntax: +:yank [*--title*] [*--sel*]+
|
Syntax: +:yank [*--title*] [*--sel*] [*--domain*]+
|
||||||
|
|
||||||
Yank the current URL/title to the clipboard or primary selection.
|
Yank the current URL/title to the clipboard or primary selection.
|
||||||
|
|
||||||
==== optional arguments
|
==== optional arguments
|
||||||
* +*-t*+, +*--title*+: Yank the title instead of the URL.
|
* +*-t*+, +*--title*+: Yank the title instead of the URL.
|
||||||
* +*-s*+, +*--sel*+: Use the primary selection instead of the clipboard.
|
* +*-s*+, +*--sel*+: Use the primary selection instead of the clipboard.
|
||||||
|
* +*-d*+, +*--domain*+: Yank only the scheme, domain, and port number.
|
||||||
|
|
||||||
[[zoom]]
|
[[zoom]]
|
||||||
=== zoom
|
=== zoom
|
||||||
|
@ -696,19 +696,28 @@ class CommandDispatcher:
|
|||||||
frame.scroll(dx, dy)
|
frame.scroll(dx, dy)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||||
def yank(self, title=False, sel=False):
|
def yank(self, title=False, sel=False, domain=False):
|
||||||
"""Yank the current URL/title to the clipboard or primary selection.
|
"""Yank the current URL/title to the clipboard or primary selection.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
sel: Use the primary selection instead of the clipboard.
|
sel: Use the primary selection instead of the clipboard.
|
||||||
title: Yank the title instead of the URL.
|
title: Yank the title instead of the URL.
|
||||||
|
domain: Yank only the scheme, domain, and port number.
|
||||||
"""
|
"""
|
||||||
clipboard = QApplication.clipboard()
|
clipboard = QApplication.clipboard()
|
||||||
if title:
|
if title:
|
||||||
s = self._tabbed_browser.page_title(self._current_index())
|
s = self._tabbed_browser.page_title(self._current_index())
|
||||||
|
what = 'title'
|
||||||
|
elif domain:
|
||||||
|
port = self._current_url().port()
|
||||||
|
s = '{}://{}{}'.format(self._current_url().scheme(),
|
||||||
|
self._current_url().host(),
|
||||||
|
':' + str(port) if port > -1 else '')
|
||||||
|
what = 'domain'
|
||||||
else:
|
else:
|
||||||
s = self._current_url().toString(
|
s = self._current_url().toString(
|
||||||
QUrl.FullyEncoded | QUrl.RemovePassword)
|
QUrl.FullyEncoded | QUrl.RemovePassword)
|
||||||
|
what = 'URL'
|
||||||
if sel and clipboard.supportsSelection():
|
if sel and clipboard.supportsSelection():
|
||||||
mode = QClipboard.Selection
|
mode = QClipboard.Selection
|
||||||
target = "primary selection"
|
target = "primary selection"
|
||||||
@ -717,8 +726,8 @@ class CommandDispatcher:
|
|||||||
target = "clipboard"
|
target = "clipboard"
|
||||||
log.misc.debug("Yanking to {}: '{}'".format(target, s))
|
log.misc.debug("Yanking to {}: '{}'".format(target, s))
|
||||||
clipboard.setText(s, mode)
|
clipboard.setText(s, mode)
|
||||||
what = 'Title' if title else 'URL'
|
message.info(self._win_id, "Yanked {} to {}: {}".format(
|
||||||
message.info(self._win_id, "{} yanked to {}".format(what, target))
|
what, target, s))
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||||
count='count')
|
count='count')
|
||||||
|
@ -1204,6 +1204,8 @@ KEY_DATA = collections.OrderedDict([
|
|||||||
('yank -s', ['yY']),
|
('yank -s', ['yY']),
|
||||||
('yank -t', ['yt']),
|
('yank -t', ['yt']),
|
||||||
('yank -ts', ['yT']),
|
('yank -ts', ['yT']),
|
||||||
|
('yank -d', ['yd']),
|
||||||
|
('yank -ds', ['yD']),
|
||||||
('paste', ['pp']),
|
('paste', ['pp']),
|
||||||
('paste -s', ['pP']),
|
('paste -s', ['pP']),
|
||||||
('paste -t', ['Pp']),
|
('paste -t', ['Pp']),
|
||||||
|
Loading…
Reference in New Issue
Block a user