aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2017-06-14 09:48:07 +1200
committerAldo Cortesi <aldo@corte.si>2017-06-14 09:48:07 +1200
commit2108bfb10626a71ca8871e72328f8bcb9be85d3b (patch)
tree5a523ddb926f02c02ba3e3ccdc0ee5f54384ee0e
parente5f79abb4f2d8af73e99d3dccfb5875c6ef4075e (diff)
downloadmitmproxy-2108bfb10626a71ca8871e72328f8bcb9be85d3b.tar.gz
mitmproxy-2108bfb10626a71ca8871e72328f8bcb9be85d3b.tar.bz2
mitmproxy-2108bfb10626a71ca8871e72328f8bcb9be85d3b.zip
console: add console.key.edit.focus, bind to "enter"
-rw-r--r--mitmproxy/tools/console/consoleaddons.py21
-rw-r--r--mitmproxy/tools/console/defaultkeys.py6
2 files changed, 23 insertions, 4 deletions
diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py
index 2a18fbb3..a65f0afe 100644
--- a/mitmproxy/tools/console/consoleaddons.py
+++ b/mitmproxy/tools/console/consoleaddons.py
@@ -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
diff --git a/mitmproxy/tools/console/defaultkeys.py b/mitmproxy/tools/console/defaultkeys.py
index 426dd10a..105be2be 100644
--- a/mitmproxy/tools/console/defaultkeys.py
+++ b/mitmproxy/tools/console/defaultkeys.py
@@ -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"
+ )