aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2018-01-04 12:58:09 +0100
committerMaximilian Hils <git@maximilianhils.com>2018-01-04 15:57:07 +0100
commit3b22433ca73b7e2810bfba519cf7deb451107c8e (patch)
tree48392b7f08179b5d85e6bc1af2eb3df20778cc94
parenteb53cc7ed26f451855755164f061ea9f49014f8d (diff)
downloadmitmproxy-3b22433ca73b7e2810bfba519cf7deb451107c8e.tar.gz
mitmproxy-3b22433ca73b7e2810bfba519cf7deb451107c8e.tar.bz2
mitmproxy-3b22433ca73b7e2810bfba519cf7deb451107c8e.zip
fix #2738
-rw-r--r--mitmproxy/tools/console/window.py34
1 files changed, 20 insertions, 14 deletions
diff --git a/mitmproxy/tools/console/window.py b/mitmproxy/tools/console/window.py
index 87680f6e..6d49e8b1 100644
--- a/mitmproxy/tools/console/window.py
+++ b/mitmproxy/tools/console/window.py
@@ -234,28 +234,34 @@ class Window(urwid.Frame):
self.view_changed()
self.focus_changed()
- def current(self, keyctx):
+ def stacks_sorted_by_focus(self):
"""
- Returns the active widget, but only the current focus or overlay has
- a matching key context.
+ Returns:
+ self.stacks, with the focused stack first.
"""
- t = self.focus_stack().top_widget()
- if t.keyctx == keyctx:
- return t
+ stacks = self.stacks.copy()
+ stacks.insert(0, stacks.pop(self.pane))
+ return stacks
- def current_window(self, keyctx):
+ def current(self, keyctx):
"""
- Returns the active window, ignoring overlays.
+ Returns the active widget with a matching key context, including overlays.
+ If multiple stacks have an active widget with a matching key context,
+ the currently focused stack is preferred.
"""
- t = self.focus_stack().top_window()
- if t.keyctx == keyctx:
- return t
+ for s in self.stacks_sorted_by_focus():
+ t = s.top_widget()
+ if t.keyctx == keyctx:
+ return t
- def any(self, keyctx):
+ def current_window(self, keyctx):
"""
- Returns the top window of either stack if they match the context.
+ Returns the active window with a matching key context, ignoring overlays.
+ If multiple stacks have an active widget with a matching key context,
+ the currently focused stack is preferred.
"""
- for t in [x.top_window() for x in self.stacks]:
+ for s in self.stacks_sorted_by_focus():
+ t = s.top_window()
if t.keyctx == keyctx:
return t