Deprecate :paste-primary to :insert-text {primary}

This commit is contained in:
Jan Verbeek 2016-08-10 21:55:16 +02:00
parent db0f8fffcd
commit 4966debd61
5 changed files with 36 additions and 56 deletions

View File

@ -32,6 +32,7 @@
|<<hint,hint>>|Start hinting. |<<hint,hint>>|Start hinting.
|<<history-clear,history-clear>>|Clear all browsing history. |<<history-clear,history-clear>>|Clear all browsing history.
|<<home,home>>|Open main startpage in current tab. |<<home,home>>|Open main startpage in current tab.
|<<insert-text,insert-text>>|Insert text at cursor position.
|<<inspector,inspector>>|Toggle the web inspector. |<<inspector,inspector>>|Toggle the web inspector.
|<<jseval,jseval>>|Evaluate a JavaScript string. |<<jseval,jseval>>|Evaluate a JavaScript string.
|<<later,later>>|Execute a command after some time. |<<later,later>>|Execute a command after some time.
@ -402,6 +403,18 @@ Note this only clears the global history (e.g. `~/.local/share/qutebrowser/histo
=== home === home
Open main startpage in current tab. Open main startpage in current tab.
[[insert-text]]
=== insert-text
Syntax: +:insert-text 'text'+
Insert text at cursor position.
==== positional arguments
* +'text'+: The text to insert.
==== note
* This command does not split arguments after the last argument and handles quotes literally.
[[inspector]] [[inspector]]
=== inspector === inspector
Toggle the web inspector. Toggle the web inspector.
@ -919,7 +932,6 @@ How many steps to zoom out.
|<<enter-mode,enter-mode>>|Enter a key mode. |<<enter-mode,enter-mode>>|Enter a key mode.
|<<follow-hint,follow-hint>>|Follow a hint. |<<follow-hint,follow-hint>>|Follow a hint.
|<<follow-selected,follow-selected>>|Follow the selected text. |<<follow-selected,follow-selected>>|Follow the selected text.
|<<insert-text,insert-text>>|Insert text at cursor position.
|<<jump-mark,jump-mark>>|Jump to the mark named by `key`. |<<jump-mark,jump-mark>>|Jump to the mark named by `key`.
|<<leave-mode,leave-mode>>|Leave the mode we're currently in. |<<leave-mode,leave-mode>>|Leave the mode we're currently in.
|<<message-error,message-error>>|Show an error message in the statusbar. |<<message-error,message-error>>|Show an error message in the statusbar.
@ -1031,18 +1043,6 @@ Follow the selected text.
==== optional arguments ==== optional arguments
* +*-t*+, +*--tab*+: Load the selected link in a new tab. * +*-t*+, +*--tab*+: Load the selected link in a new tab.
[[insert-text]]
=== insert-text
Syntax: +:insert-text 'text'+
Insert text at cursor position.
==== positional arguments
* +'text'+: The text to insert.
==== note
* This command does not split arguments after the last argument and handles quotes literally.
[[jump-mark]] [[jump-mark]]
=== jump-mark === jump-mark
Syntax: +:jump-mark 'key'+ Syntax: +:jump-mark 'key'+

View File

@ -1486,6 +1486,7 @@ class CommandDispatcher:
raise cmdexc.CommandError("Element vanished while editing!") raise cmdexc.CommandError("Element vanished while editing!")
@cmdutils.register(instance='command-dispatcher', @cmdutils.register(instance='command-dispatcher',
deprecated="Use :insert-text {primary}",
modes=[KeyMode.insert], hide=True, scope='window', modes=[KeyMode.insert], hide=True, scope='window',
needs_js=True, backend=usertypes.Backend.QtWebKit) needs_js=True, backend=usertypes.Backend.QtWebKit)
def paste_primary(self): def paste_primary(self):

View File

@ -1585,7 +1585,7 @@ KEY_DATA = collections.OrderedDict([
('insert', collections.OrderedDict([ ('insert', collections.OrderedDict([
('open-editor', ['<Ctrl-E>']), ('open-editor', ['<Ctrl-E>']),
('paste-primary', ['<Shift-Ins>']), ('insert-text {primary}', ['<Shift-Ins>']),
])), ])),
('hint', collections.OrderedDict([ ('hint', collections.OrderedDict([
@ -1705,4 +1705,6 @@ CHANGED_KEY_COMMANDS = [
(re.compile(r'^completion-item-next'), r'completion-item-focus next'), (re.compile(r'^completion-item-next'), r'completion-item-focus next'),
(re.compile(r'^completion-item-prev'), r'completion-item-focus prev'), (re.compile(r'^completion-item-prev'), r'completion-item-focus prev'),
(re.compile(r'^paste-primary$'), r'insert-text {primary}'),
] ]

View File

@ -227,25 +227,21 @@ Feature: Yanking and pasting.
And I run :open -t {clipboard} And I run :open -t {clipboard}
Then no crash should happen Then no crash should happen
#### :paste-primary #### :insert-text
Scenario: Pasting the primary selection into an empty text field Scenario: Inserting text into an empty text field
When selection is supported When I open data/paste_primary.html
And I open data/paste_primary.html
And I put "Hello world" into the primary selection
# Click the text field # Click the text field
And I run :hint all And I run :hint all
And I run :follow-hint a And I run :follow-hint a
And I wait for "Clicked editable element!" in the log And I wait for "Clicked editable element!" in the log
And I run :paste-primary And I run :insert-text Hello world
# Compare # Compare
Then the text field should contain "Hello world" Then the text field should contain "Hello world"
Scenario: Pasting the primary selection into a text field at specific position Scenario: Inserting text into a text field at specific position
When selection is supported When I open data/paste_primary.html
And I open data/paste_primary.html
And I set the text field to "one two three four" And I set the text field to "one two three four"
And I put " Hello world" into the primary selection
# Click the text field # Click the text field
And I run :hint all And I run :hint all
And I run :follow-hint a And I run :follow-hint a
@ -254,55 +250,36 @@ Feature: Yanking and pasting.
And I press the keys "<Home>" And I press the keys "<Home>"
And I press the key "<Ctrl+Right>" And I press the key "<Ctrl+Right>"
And I press the key "<Ctrl+Right>" And I press the key "<Ctrl+Right>"
And I run :paste-primary And I run :insert-text Hello world
# Compare # Compare
Then the text field should contain "one twoHello world three four" Then the text field should contain "one twoHello world three four"
Scenario: Pasting the primary selection into a text field with undo Scenario: Inserting text into a text field with undo
When selection is supported When I open data/paste_primary.html
And I open data/paste_primary.html
# Click the text field # Click the text field
And I run :hint all And I run :hint all
And I run :follow-hint a And I run :follow-hint a
And I wait for "Clicked editable element!" in the log And I wait for "Clicked editable element!" in the log
# Paste and undo # Paste and undo
And I put "This text should be undone" into the primary selection And I run :insert-text This text should be undone
And I run :paste-primary
And I press the key "<Ctrl+z>" And I press the key "<Ctrl+z>"
# Paste final text # Paste final text
And I put "This text should stay" into the primary selection And I run :insert-text This text should stay
And I run :paste-primary
# Compare # Compare
Then the text field should contain "This text should stay" Then the text field should contain "This text should stay"
Scenario: Pasting the primary selection without a focused field Scenario: Inserting text without a focused field
When selection is supported When I open data/paste_primary.html
And I open data/paste_primary.html
And I put "test" into the primary selection
And I run :enter-mode insert And I run :enter-mode insert
And I run :paste-primary And I run :insert-text test
Then the error "No element focused!" should be shown Then the error "No element focused!" should be shown
Scenario: Pasting the primary selection with a read-only field Scenario: Inserting text with a read-only field
When selection is supported When I open data/paste_primary.html
And I open data/paste_primary.html
# Click the text field # Click the text field
And I run :hint all And I run :hint all
And I run :follow-hint s And I run :follow-hint s
And I wait for "Clicked non-editable element!" in the log And I wait for "Clicked non-editable element!" in the log
And I put "test" into the primary selection
And I run :enter-mode insert And I run :enter-mode insert
And I run :paste-primary And I run :insert-text test
Then the error "Focused element is not editable!" should be shown Then the error "Focused element is not editable!" should be shown
Scenario: :paste-primary without primary selection supported
When selection is not supported
And I open data/paste_primary.html
And I put "Hello world" into the clipboard
# Click the text field
And I run :hint all
And I run :follow-hint a
And I wait for "Clicked editable element!" in the log
And I run :paste-primary
# Compare
Then the text field should contain "Hello world"

View File

@ -46,7 +46,7 @@ def test_insert_mode(file_name, source, input_text, auto_insert, quteproc):
quteproc.press_keys(input_text) quteproc.press_keys(input_text)
elif source == 'clipboard': elif source == 'clipboard':
quteproc.send_cmd(':debug-set-fake-clipboard "{}"'.format(input_text)) quteproc.send_cmd(':debug-set-fake-clipboard "{}"'.format(input_text))
quteproc.send_cmd(':paste-primary') quteproc.send_cmd(':insert-text {primary}')
quteproc.send_cmd(':hint all') quteproc.send_cmd(':hint all')
quteproc.send_cmd(':follow-hint a') quteproc.send_cmd(':follow-hint a')