diff options
| author | Maximilian Hils <git@maximilianhils.com> | 2017-12-17 17:54:04 +0100 |
|---|---|---|
| committer | Maximilian Hils <git@maximilianhils.com> | 2017-12-17 17:54:04 +0100 |
| commit | 9d9439ef3b8947238c6a3f5d50e868cb0f6d000a (patch) | |
| tree | 1c0bc4adf895aed6ae33c26491b1af0e417d8600 | |
| parent | 9e4a443d4234149119e196ada3dbf2306173122e (diff) | |
| download | mitmproxy-9d9439ef3b8947238c6a3f5d50e868cb0f6d000a.tar.gz mitmproxy-9d9439ef3b8947238c6a3f5d50e868cb0f6d000a.tar.bz2 mitmproxy-9d9439ef3b8947238c6a3f5d50e868cb0f6d000a.zip | |
fix #2697
| -rw-r--r-- | mitmproxy/tools/console/window.py | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/mitmproxy/tools/console/window.py b/mitmproxy/tools/console/window.py index 4cd53a42..87680f6e 100644 --- a/mitmproxy/tools/console/window.py +++ b/mitmproxy/tools/console/window.py @@ -15,16 +15,30 @@ from mitmproxy.tools.console import grideditor from mitmproxy.tools.console import eventlog -class Header(urwid.Frame): +class StackWidget(urwid.Frame): def __init__(self, widget, title, focus): - super().__init__( - widget, + if title: header = urwid.AttrWrap( urwid.Text(title), "heading" if focus else "heading_inactive" ) + else: + header = None + super().__init__( + widget, + header=header ) + def keypress(self, size, key): + # Make sure that we don't propagate cursor events outside of the widget. + # Otherwise, in a horizontal layout, urwid's Pile would change the focused widget + # if we cannot scroll any further. + ret = super().keypress(size, key) + command = self._command_map[ret] # awkward as they don't implement a full dict api + if command and command.startswith("cursor"): + return None + return ret + class WindowStack: def __init__(self, master, base): @@ -142,12 +156,16 @@ class Window(urwid.Frame): self.pane = 0 def wrapped(idx): - window = self.stacks[idx].top_window() widget = self.stacks[idx].top_widget() - if self.master.options.console_layout_headers and window.title: - return Header(widget, window.title, self.pane == idx) + if self.master.options.console_layout_headers: + title = self.stacks[idx].top_window().title else: - return widget + title = None + return StackWidget( + widget, + title, + self.pane == idx + ) w = None if c == "single": |
