Add a set-cmd-text command.
This commit is contained in:
parent
76ff8aa30a
commit
d60ff5ed27
@ -38,7 +38,7 @@ import qutebrowser.browser.quickmarks as quickmarks
|
||||
import qutebrowser.utils.log as log
|
||||
import qutebrowser.utils.url as urlutils
|
||||
from qutebrowser.utils.qt import (check_overflow, check_print_compat,
|
||||
qt_ensure_valid, QtValueError)
|
||||
qt_ensure_valid)
|
||||
from qutebrowser.utils.editor import ExternalEditor
|
||||
from qutebrowser.commands.exceptions import CommandError
|
||||
from qutebrowser.commands.userscripts import UserscriptRunner
|
||||
@ -451,24 +451,6 @@ class CommandDispatcher:
|
||||
raise CommandError(e)
|
||||
self._tabs.tabopen(url, background=True)
|
||||
|
||||
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
|
||||
def open_tab_cur(self):
|
||||
"""Set the statusbar to :tabopen and the current URL."""
|
||||
urlstr = self._tabs.current_url().toDisplayString(QUrl.FullyEncoded)
|
||||
message.set_cmd_text(':open-tab ' + urlstr)
|
||||
|
||||
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
|
||||
def open_cur(self):
|
||||
"""Set the statusbar to :open and the current URL."""
|
||||
urlstr = self._tabs.current_url().toDisplayString(QUrl.FullyEncoded)
|
||||
message.set_cmd_text(':open ' + urlstr)
|
||||
|
||||
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
|
||||
def open_tab_bg_cur(self):
|
||||
"""Set the statusbar to :tabopen-bg and the current URL."""
|
||||
urlstr = self._tabs.current_url().toDisplayString(QUrl.FullyEncoded)
|
||||
message.set_cmd_text(':open-tab-bg ' + urlstr)
|
||||
|
||||
@cmdutils.register(instance='mainwindow.tabs.cmd')
|
||||
def undo(self):
|
||||
"""Re-open a closed tab (optionally skipping [count] tabs)."""
|
||||
|
@ -598,11 +598,11 @@ DATA = OrderedDict([
|
||||
('keybind', sect.ValueList(
|
||||
types.KeyBindingName(), types.KeyBinding(),
|
||||
('o', 'open'),
|
||||
('go', 'open-cur'),
|
||||
('go', 'set-cmd-text :open {url}'),
|
||||
('O', 'open-tab'),
|
||||
('gO', 'open-tab-cur'),
|
||||
('gO', 'set-cmd-text :open-tab {url}'),
|
||||
('xo', 'open-tab-bg'),
|
||||
('xO', 'open-tab-bg-cur'),
|
||||
('xO', 'set-cmd-text :open-tab-bg {url}'),
|
||||
('ga', 'open-tab about:blank'),
|
||||
('d', 'tab-close'),
|
||||
('co', 'tab-only'),
|
||||
|
@ -31,6 +31,7 @@ from qutebrowser.keyinput.modeparsers import STARTCHARS
|
||||
from qutebrowser.utils.log import completion as logger
|
||||
from qutebrowser.models.cmdhistory import (History, HistoryEmptyError,
|
||||
HistoryEndReachedError)
|
||||
from qutebrowser.commands.exceptions import CommandError
|
||||
|
||||
|
||||
class Command(MinimalLineEdit):
|
||||
@ -154,7 +155,7 @@ class Command(MinimalLineEdit):
|
||||
"""Preset the statusbar to some text.
|
||||
|
||||
Args:
|
||||
text: The text to set (string).
|
||||
text: The text to set as string.
|
||||
|
||||
Emit:
|
||||
update_completion: Emitted if the text changed.
|
||||
@ -168,6 +169,23 @@ class Command(MinimalLineEdit):
|
||||
self.setFocus()
|
||||
self.show_cmd.emit()
|
||||
|
||||
@cmdutils.register(instance='mainwindow.status.cmd', name='set-cmd-text')
|
||||
def set_cmd_text_command(self, *strings):
|
||||
"""Preset the statusbar to some text.
|
||||
|
||||
//
|
||||
|
||||
Wrapper for set_cmd_text to check the arguments and allow multiple
|
||||
strings which will get joined.
|
||||
|
||||
Args:
|
||||
strings: A list of strings to set.
|
||||
"""
|
||||
text = ' '.join(strings)
|
||||
if not any(text.startswith(c) for c in STARTCHARS):
|
||||
raise CommandError("Invalid command text '{}'.".format(text))
|
||||
self.set_cmd_text(text)
|
||||
|
||||
@pyqtSlot(str, bool)
|
||||
def on_change_completed_part(self, newtext, immediate):
|
||||
"""Change the part we're currently completing in the commandline.
|
||||
|
Loading…
Reference in New Issue
Block a user