This commit is contained in:
Maximilian Hils 2019-12-12 15:34:32 +01:00
parent a58b8c9cdb
commit 005cb7cf5a

View File

@ -4,9 +4,9 @@ from typing import Optional
import urwid import urwid
import mitmproxy.tools.console.master # noqa import mitmproxy.tools.console.master # noqa
from mitmproxy.tools.console import commandexecutor
from mitmproxy.tools.console import common from mitmproxy.tools.console import common
from mitmproxy.tools.console import signals from mitmproxy.tools.console import signals
from mitmproxy.tools.console import commandexecutor
from mitmproxy.tools.console.commander import commander from mitmproxy.tools.console.commander import commander
@ -57,6 +57,7 @@ class ActionBar(urwid.WidgetWrap):
def cb(*args): def cb(*args):
if w == self._w: if w == self._w:
self.clear() self.clear()
signals.call_in.send(seconds=expire, callback=cb) signals.call_in.send(seconds=expire, callback=cb)
def prep_prompt(self, p): def prep_prompt(self, p):
@ -105,7 +106,13 @@ class ActionBar(urwid.WidgetWrap):
) )
if cursor is not None: if cursor is not None:
self._w.cbuf.cursor = cursor self._w.cbuf.cursor = cursor
self.prompting = commandexecutor.CommandExecutor(self.master) self.prompting = self.execute_command
def execute_command(self, txt):
if txt.strip():
self.master.commands.call("commands.history.add", txt)
execute = commandexecutor.CommandExecutor(self.master)
execute(txt)
def sig_prompt_onekey(self, sender, prompt, keys, callback, args=()): def sig_prompt_onekey(self, sender, prompt, keys, callback, args=()):
""" """
@ -140,7 +147,6 @@ class ActionBar(urwid.WidgetWrap):
elif k == "enter": elif k == "enter":
text = self._w.get_edit_text() text = self._w.get_edit_text()
self.prompt_execute(text) self.prompt_execute(text)
self.master.commands.call("commands.history.add", text)
else: else:
if common.is_keypress(k): if common.is_keypress(k):
self._w.keypress(size, k) self._w.keypress(size, k)