option to close commandline by deleting the prefix

This commit is contained in:
Argn0 2018-01-10 19:59:34 +01:00
parent 1f8d6e2168
commit 5003432a55
4 changed files with 209 additions and 3 deletions

186
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,186 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceFolder}",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
},
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}",
"port": 3000,
"secret": "my_secret",
"host": "localhost"
},
{
"name": "Python: Terminal (integrated)",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "",
"console": "integratedTerminal",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": []
},
{
"name": "Python: Terminal (external)",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "",
"console": "externalTerminal",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": []
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceFolder}/manage.py",
"cwd": "${workspaceFolder}",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput",
"DjangoDebugging"
]
},
{
"name": "Python: Flask (0.11.x or later)",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",
"cwd": "${workspaceFolder}",
"env": {
"FLASK_APP": "${workspaceFolder}/quickstart/app.py"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
},
{
"name": "Python: Flask (0.10.x or earlier)",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceFolder}/run.py",
"cwd": "${workspaceFolder}",
"args": [],
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
},
{
"name": "Python: PySpark",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"osx": {
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
},
"windows": {
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit.cmd"
},
"linux": {
"pythonPath": "${env:SPARK_HOME}/bin/spark-submit"
},
"program": "${file}",
"cwd": "${workspaceFolder}",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
},
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"module": "module.name",
"cwd": "${workspaceFolder}",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
},
{
"name": "Python: Pyramid",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"cwd": "${workspaceFolder}",
"env": {},
"envFile": "${workspaceFolder}/.env",
"args": [
"${workspaceFolder}/development.ini"
],
"debugOptions": [
"RedirectOutput",
"Pyramid"
]
},
{
"name": "Python: Watson",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${workspaceFolder}/console.py",
"cwd": "${workspaceFolder}",
"args": [
"dev",
"runserver",
"--noreload=True"
],
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
}
]
}

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"python.pythonPath": "${workspaceFolder}/.venv/bin/python"
}

View File

@ -740,6 +740,11 @@ completion.use_best_match:
default: false
desc: Execute the best-matching command on a partial match.
completion.exit_prefix:
type: Bool
default: false
desc: Exit command mode if the prefix gets deleted.
## downloads
downloads.location.directory:
@ -2493,4 +2498,4 @@ bindings.commands:
keyboard.
* register: Entered when qutebrowser is waiting for a register name/key for
commands like `:set-mark`.
commands like `:set-mark`.

View File

@ -31,7 +31,6 @@ from qutebrowser.config import config
class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
"""The commandline part of the statusbar.
Attributes:
@ -55,6 +54,8 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
show_cmd = pyqtSignal()
hide_cmd = pyqtSignal()
prefixes = '/ : ?'
def __init__(self, *, win_id, private, parent=None):
misc.CommandLineEdit.__init__(self, parent=parent)
misc.MinimalLineEditMixin.__init__(self)
@ -68,6 +69,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
self.textChanged.connect(self.update_completion)
self.textChanged.connect(self.updateGeometry)
self.textChanged.connect(self._incremental_search)
self.textChanged.connect(self._exit_prefix)
def prefix(self):
"""Get the currently entered command prefix."""
@ -219,7 +221,10 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
if not text:
pass
elif text[0] in modeparsers.STARTCHARS:
super().set_prompt(text[0])
if config.val.completion.exit_prefix:
super().set_prompt('')
else:
super().set_prompt(text[0])
else:
raise utils.Unreachable("setText got called with invalid text "
"'{}'!".format(text))
@ -259,3 +264,10 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
if self.prefix() in ['/', '?']:
self.got_cmd[str].emit(search_prefixes[text[0]] + text[1:])
@pyqtSlot(str)
def _exit_prefix(self, text):
if config.val.completion.exit_prefix and
(not text or text[0] not in self.prefixes):
modeman.leave(self._win_id, usertypes.KeyMode.command,
'prefix deleted', maybe=True)