add --sel option to prompt-yank

This commit is contained in:
Marc Jauvin 2018-01-26 22:06:05 -05:00
parent ddcc960aa5
commit fe4dd579f9
4 changed files with 23 additions and 10 deletions

View File

@ -1404,7 +1404,7 @@ How many steps to zoom out.
|<<prompt-accept,prompt-accept>>|Accept the current prompt.
|<<prompt-item-focus,prompt-item-focus>>|Shift the focus of the prompt file completion menu to another item.
|<<prompt-open-download,prompt-open-download>>|Immediately open a download.
|<<prompt-yank,prompt-yank>>|Yank URL.
|<<prompt-yank,prompt-yank>>|Yank URL to clipboard or primary selection.
|<<rl-backward-char,rl-backward-char>>|Move back a character.
|<<rl-backward-delete-char,rl-backward-delete-char>>|Delete the character before the cursor.
|<<rl-backward-kill-word,rl-backward-kill-word>>|Remove chars from the cursor to the beginning of the word.
@ -1612,7 +1612,12 @@ If no specific command is given, this will use the system's default application
[[prompt-yank]]
=== prompt-yank
Yank URL.
Syntax: +:prompt-yank [*--sel*]+
Yank URL to clipboard or primary selection.
==== optional arguments
* +*-s*+, +*--sel*+: Use the primary selection instead of the clipboard.
[[rl-backward-char]]
=== rl-backward-char

View File

@ -623,11 +623,11 @@ Default:
* +pass:[&lt;Ctrl-F&gt;]+: +pass:[rl-forward-char]+
* +pass:[&lt;Ctrl-H&gt;]+: +pass:[rl-backward-delete-char]+
* +pass:[&lt;Ctrl-K&gt;]+: +pass:[rl-kill-line]+
* +pass:[&lt;Ctrl-Shift-Y&gt;]+: +pass:[prompt-yank --sel]+
* +pass:[&lt;Ctrl-U&gt;]+: +pass:[rl-unix-line-discard]+
* +pass:[&lt;Ctrl-W&gt;]+: +pass:[rl-unix-word-rubout]+
* +pass:[&lt;Ctrl-X&gt;]+: +pass:[prompt-open-download]+
* +pass:[&lt;Ctrl-Y&gt;]+: +pass:[rl-yank]+
* +pass:[&lt;Ctrl-y&gt;]+: +pass:[prompt-yank]+
* +pass:[&lt;Ctrl-Y&gt;]+: +pass:[prompt-yank]+
* +pass:[&lt;Down&gt;]+: +pass:[prompt-item-focus next]+
* +pass:[&lt;Escape&gt;]+: +pass:[leave-mode]+
* +pass:[&lt;Return&gt;]+: +pass:[prompt-accept]+

View File

@ -2349,8 +2349,8 @@ bindings.default:
<Alt-D>: rl-kill-word
<Ctrl-W>: rl-unix-word-rubout
<Alt-Backspace>: rl-backward-kill-word
<Ctrl-Y>: rl-yank
<Ctrl-y>: prompt-yank
<Ctrl-Y>: prompt-yank
<Ctrl-Shift-Y>: prompt-yank --sel
<Ctrl-?>: rl-delete-char
<Ctrl-H>: rl-backward-delete-char
<Escape>: leave-mode

View File

@ -425,15 +425,23 @@ class PromptContainer(QWidget):
@cmdutils.register(
instance='prompt-container', scope='window',
modes=[usertypes.KeyMode.prompt, usertypes.KeyMode.yesno])
def prompt_yank(self):
"""Yank URL."""
def prompt_yank(self, sel=False):
"""Yank URL to clipboard or primary selection.
Args:
sel: Use the primary selection instead of the clipboard.
"""
question = self._prompt.question
if not question.url:
message.error('No URL found.')
return
s = question.url
utils.set_clipboard(s)
message.info("Yanked to clipboard: {}".format(s))
target = 'primary selection'
if not (sel and utils.supports_selection()):
target = 'clipboard'
sel = False
utils.set_clipboard(s, sel)
message.info("Yanked to {}: {}".format(target, s))
class LineEdit(QLineEdit):