mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-30 14:58:38 +00:00
console: add console.key.edit.focus, bind to "enter"
This commit is contained in:
parent
e5f79abb4f
commit
2108bfb106
@ -425,16 +425,16 @@ class ConsoleAddon:
|
||||
return list(sorted(keymap.Contexts))
|
||||
|
||||
@command.command("console.key.bind")
|
||||
def key_bind(self, context: str, key: str, command: str) -> None:
|
||||
def key_bind(self, contexts: typing.Sequence[str], key: str, *command: str) -> None:
|
||||
"""
|
||||
Bind a shortcut key.
|
||||
"""
|
||||
try:
|
||||
self.master.keymap.add(
|
||||
key,
|
||||
command,
|
||||
[context],
|
||||
command
|
||||
" ".join(command),
|
||||
contexts,
|
||||
""
|
||||
)
|
||||
except ValueError as v:
|
||||
raise exceptions.CommandError(v)
|
||||
@ -477,6 +477,19 @@ class ConsoleAddon:
|
||||
b = self._keyfocus()
|
||||
self.console_command(b.command)
|
||||
|
||||
@command.command("console.key.edit.focus")
|
||||
def key_edit_focus(self) -> None:
|
||||
"""
|
||||
Execute the currently focused key binding.
|
||||
"""
|
||||
b = self._keyfocus()
|
||||
self.console_command(
|
||||
"console.key.bind",
|
||||
",".join(b.contexts),
|
||||
b.key,
|
||||
b.command,
|
||||
)
|
||||
|
||||
def running(self):
|
||||
self.started = True
|
||||
|
||||
|
@ -170,3 +170,9 @@ def map(km):
|
||||
["keybindings"],
|
||||
"Execute the currently focused key binding"
|
||||
)
|
||||
km.add(
|
||||
"enter",
|
||||
"console.key.edit.focus",
|
||||
["keybindings"],
|
||||
"Edit the currently focused key binding"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user