diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index be151f6ee..97fd8fcb5 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -32,6 +32,7 @@ |<>|Start hinting. |<>|Clear all browsing history. |<>|Open main startpage in current tab. +|<>|Insert text at cursor position. |<>|Toggle the web inspector. |<>|Evaluate a JavaScript string. |<>|Execute a command after some time. @@ -402,6 +403,18 @@ Note this only clears the global history (e.g. `~/.local/share/qutebrowser/histo === home 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 Toggle the web inspector. @@ -919,7 +932,6 @@ How many steps to zoom out. |<>|Enter a key mode. |<>|Follow a hint. |<>|Follow the selected text. -|<>|Insert text at cursor position. |<>|Jump to the mark named by `key`. |<>|Leave the mode we're currently in. |<>|Show an error message in the statusbar. @@ -1031,18 +1043,6 @@ Follow the selected text. ==== optional arguments * +*-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 Syntax: +:jump-mark 'key'+ diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index e0ac9f495..e0202f277 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1486,6 +1486,7 @@ class CommandDispatcher: raise cmdexc.CommandError("Element vanished while editing!") @cmdutils.register(instance='command-dispatcher', + deprecated="Use :insert-text {primary}", modes=[KeyMode.insert], hide=True, scope='window', needs_js=True, backend=usertypes.Backend.QtWebKit) def paste_primary(self): diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index b62968904..be004b943 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -1585,7 +1585,7 @@ KEY_DATA = collections.OrderedDict([ ('insert', collections.OrderedDict([ ('open-editor', ['']), - ('paste-primary', ['']), + ('insert-text {primary}', ['']), ])), ('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-prev'), r'completion-item-focus prev'), + + (re.compile(r'^paste-primary$'), r'insert-text {primary}'), ] diff --git a/tests/end2end/features/yankpaste.feature b/tests/end2end/features/yankpaste.feature index c453b2e42..8c02612a0 100644 --- a/tests/end2end/features/yankpaste.feature +++ b/tests/end2end/features/yankpaste.feature @@ -227,25 +227,21 @@ Feature: Yanking and pasting. And I run :open -t {clipboard} Then no crash should happen - #### :paste-primary + #### :insert-text - Scenario: Pasting the primary selection into an empty text field - When selection is supported - And I open data/paste_primary.html - And I put "Hello world" into the primary selection + Scenario: Inserting text into an empty text field + When I open data/paste_primary.html # 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 + And I run :insert-text Hello world # Compare Then the text field should contain "Hello world" - Scenario: Pasting the primary selection into a text field at specific position - When selection is supported - And I open data/paste_primary.html + Scenario: Inserting text into a text field at specific position + When I open data/paste_primary.html And I set the text field to "one two three four" - And I put " Hello world" into the primary selection # Click the text field And I run :hint all And I run :follow-hint a @@ -254,55 +250,36 @@ Feature: Yanking and pasting. And I press the keys "" And I press the key "" And I press the key "" - And I run :paste-primary + And I run :insert-text Hello world # Compare - Then the text field should contain "one two Hello 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 - When selection is supported - And I open data/paste_primary.html + Scenario: Inserting text into a text field with undo + When I open data/paste_primary.html # 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 # Paste and undo - And I put "This text should be undone" into the primary selection - And I run :paste-primary + And I run :insert-text This text should be undone And I press the key "" # Paste final text - And I put "This text should stay" into the primary selection - And I run :paste-primary + And I run :insert-text This text should stay # Compare Then the text field should contain "This text should stay" - Scenario: Pasting the primary selection without a focused field - When selection is supported - And I open data/paste_primary.html - And I put "test" into the primary selection + Scenario: Inserting text without a focused field + When I open data/paste_primary.html 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 - Scenario: Pasting the primary selection with a read-only field - When selection is supported - And I open data/paste_primary.html + Scenario: Inserting text with a read-only field + When I open data/paste_primary.html # Click the text field And I run :hint all And I run :follow-hint s 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 :paste-primary + And I run :insert-text test 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" diff --git a/tests/end2end/test_insert_mode.py b/tests/end2end/test_insert_mode.py index c8a7f32de..d6c5022aa 100644 --- a/tests/end2end/test_insert_mode.py +++ b/tests/end2end/test_insert_mode.py @@ -46,7 +46,7 @@ def test_insert_mode(file_name, source, input_text, auto_insert, quteproc): quteproc.press_keys(input_text) elif source == 'clipboard': 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(':follow-hint a')