Merge branch 'forkbong-set-cmd-text-variables'
This commit is contained in:
commit
8193644a04
@ -157,9 +157,9 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* Artur Shaik
|
* Artur Shaik
|
||||||
* Nathan Isom
|
* Nathan Isom
|
||||||
* Thorsten Wißmann
|
* Thorsten Wißmann
|
||||||
|
* Panagiotis Ktistakis
|
||||||
* Kevin Velghe
|
* Kevin Velghe
|
||||||
* Austin Anderson
|
* Austin Anderson
|
||||||
* Panagiotis Ktistakis
|
|
||||||
* Jimmy
|
* Jimmy
|
||||||
* Alexey "Averrin" Nabrodov
|
* Alexey "Averrin" Nabrodov
|
||||||
* avk
|
* avk
|
||||||
|
@ -650,6 +650,8 @@ Syntax: +:set-cmd-text [*--space*] [*--append*] 'text'+
|
|||||||
|
|
||||||
Preset the statusbar to some text.
|
Preset the statusbar to some text.
|
||||||
|
|
||||||
|
You can use the `{url}` and `{url:pretty}` variables here which will get replaced by the encoded/decoded URL.
|
||||||
|
|
||||||
==== positional arguments
|
==== positional arguments
|
||||||
* +'text'+: The commandline to set.
|
* +'text'+: The commandline to set.
|
||||||
|
|
||||||
|
@ -1386,13 +1386,13 @@ KEY_DATA = collections.OrderedDict([
|
|||||||
('normal', collections.OrderedDict([
|
('normal', collections.OrderedDict([
|
||||||
('clear-keychain ;; search', ['<Escape>']),
|
('clear-keychain ;; search', ['<Escape>']),
|
||||||
('set-cmd-text -s :open', ['o']),
|
('set-cmd-text -s :open', ['o']),
|
||||||
('set-cmd-text :open {url}', ['go']),
|
('set-cmd-text :open {url:pretty}', ['go']),
|
||||||
('set-cmd-text -s :open -t', ['O']),
|
('set-cmd-text -s :open -t', ['O']),
|
||||||
('set-cmd-text :open -t {url}', ['gO']),
|
('set-cmd-text :open -t {url:pretty}', ['gO']),
|
||||||
('set-cmd-text -s :open -b', ['xo']),
|
('set-cmd-text -s :open -b', ['xo']),
|
||||||
('set-cmd-text :open -b {url}', ['xO']),
|
('set-cmd-text :open -b {url:pretty}', ['xO']),
|
||||||
('set-cmd-text -s :open -w', ['wo']),
|
('set-cmd-text -s :open -w', ['wo']),
|
||||||
('set-cmd-text :open -w {url}', ['wO']),
|
('set-cmd-text :open -w {url:pretty}', ['wO']),
|
||||||
('open -t', ['ga', '<Ctrl-T>']),
|
('open -t', ['ga', '<Ctrl-T>']),
|
||||||
('open -w', ['<Ctrl-N>']),
|
('open -w', ['<Ctrl-N>']),
|
||||||
('tab-close', ['d', '<Ctrl-W>']),
|
('tab-close', ['d', '<Ctrl-W>']),
|
||||||
|
@ -19,14 +19,14 @@
|
|||||||
|
|
||||||
"""The commandline in the statusbar."""
|
"""The commandline in the statusbar."""
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QUrl, QSize
|
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QSize
|
||||||
from PyQt5.QtWidgets import QSizePolicy
|
from PyQt5.QtWidgets import QSizePolicy
|
||||||
|
|
||||||
from qutebrowser.keyinput import modeman, modeparsers
|
from qutebrowser.keyinput import modeman, modeparsers
|
||||||
from qutebrowser.commands import cmdexc, cmdutils
|
from qutebrowser.commands import cmdexc, cmdutils, runners
|
||||||
from qutebrowser.misc import cmdhistory
|
from qutebrowser.misc import cmdhistory, split
|
||||||
from qutebrowser.misc import miscwidgets as misc
|
from qutebrowser.misc import miscwidgets as misc
|
||||||
from qutebrowser.utils import usertypes, log, objreg, qtutils
|
from qutebrowser.utils import usertypes, log, objreg
|
||||||
|
|
||||||
|
|
||||||
class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
||||||
@ -95,6 +95,9 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
def set_cmd_text_command(self, text, space=False, append=False):
|
def set_cmd_text_command(self, text, space=False, append=False):
|
||||||
"""Preset the statusbar to some text.
|
"""Preset the statusbar to some text.
|
||||||
|
|
||||||
|
You can use the `{url}` and `{url:pretty}` variables here which will get
|
||||||
|
replaced by the encoded/decoded URL.
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
Wrapper for set_cmd_text to check the arguments and allow multiple
|
Wrapper for set_cmd_text to check the arguments and allow multiple
|
||||||
@ -105,24 +108,9 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
space: If given, a space is added to the end.
|
space: If given, a space is added to the end.
|
||||||
append: If given, the text is appended to the current text.
|
append: If given, the text is appended to the current text.
|
||||||
"""
|
"""
|
||||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
args = split.simple_split(text)
|
||||||
window=self._win_id)
|
args = runners.replace_variables(self._win_id, args)
|
||||||
if '{url}' in text:
|
text = ' '.join(args)
|
||||||
try:
|
|
||||||
url = tabbed_browser.current_url().toString(
|
|
||||||
QUrl.FullyEncoded | QUrl.RemovePassword)
|
|
||||||
except qtutils.QtValueError as e:
|
|
||||||
msg = "Current URL is invalid"
|
|
||||||
if e.reason:
|
|
||||||
msg += " ({})".format(e.reason)
|
|
||||||
msg += "!"
|
|
||||||
raise cmdexc.CommandError(msg)
|
|
||||||
# FIXME we currently replace the URL in any place in the arguments,
|
|
||||||
# rather than just replacing it if it is a dedicated argument. We
|
|
||||||
# could split the args, but then trailing spaces would be lost, so
|
|
||||||
# I'm not sure what's the best thing to do here
|
|
||||||
# https://github.com/The-Compiler/qutebrowser/issues/123
|
|
||||||
text = text.replace('{url}', url)
|
|
||||||
|
|
||||||
if space:
|
if space:
|
||||||
text += ' '
|
text += ' '
|
||||||
|
@ -15,9 +15,21 @@ Feature: Various utility commands.
|
|||||||
|
|
||||||
Scenario: :set-cmd-text with URL replacement
|
Scenario: :set-cmd-text with URL replacement
|
||||||
When I open data/hello.txt
|
When I open data/hello.txt
|
||||||
When I run :set-cmd-text :message-info >{url}<
|
And I run :set-cmd-text :message-info {url}
|
||||||
And I run :command-accept
|
And I run :command-accept
|
||||||
Then the message ">http://localhost:*/hello.txt<" should be shown
|
Then the message "http://localhost:*/hello.txt" should be shown
|
||||||
|
|
||||||
|
Scenario: :set-cmd-text with URL replacement with encoded spaces
|
||||||
|
When I open data/title with spaces.html
|
||||||
|
And I run :set-cmd-text :message-info {url}
|
||||||
|
And I run :command-accept
|
||||||
|
Then the message "http://localhost:*/title%20with%20spaces.html" should be shown
|
||||||
|
|
||||||
|
Scenario: :set-cmd-text with URL replacement with decoded spaces
|
||||||
|
When I open data/title with spaces.html
|
||||||
|
And I run :set-cmd-text :message-info "> {url:pretty} <"
|
||||||
|
And I run :command-accept
|
||||||
|
Then the message "> http://localhost:*/title with spaces.html <" should be shown
|
||||||
|
|
||||||
Scenario: :set-cmd-text with -s and -a
|
Scenario: :set-cmd-text with -s and -a
|
||||||
When I run :set-cmd-text -s :message-info "foo
|
When I run :set-cmd-text -s :message-info "foo
|
||||||
|
Loading…
Reference in New Issue
Block a user