MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / StackWidget

Class StackWidget

mitmproxy/tools/console/window.py:21–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19
20
21class StackWidget(urwid.Frame):
22 def __init__(self, window, widget, title, focus):
23 self.is_focused = focus
24 self.window = window
25
26 if title:
27 header = urwid.AttrMap(
28 urwid.Text(title), "heading" if focus else "heading_inactive"
29 )
30 else:
31 header = None
32 super().__init__(widget, header=header)
33
34 def mouse_event(self, size, event, button, col, row, focus):
35 if event == "mouse press" and button == 1 and not self.is_focused:
36 self.window.switch()
37 return super().mouse_event(size, event, button, col, row, focus)
38
39 def keypress(self, size, key):
40 # Make sure that we don't propagate cursor events outside of the widget.
41 # Otherwise, in a horizontal layout, urwid's Pile would change the focused widget
42 # if we cannot scroll any further.
43 ret = super().keypress(size, key)
44 command = self._command_map[
45 ret
46 ] # awkward as they don't implement a full dict api
47 if command and command.startswith("cursor"):
48 return None
49 return ret
50
51
52class WindowStack:

Callers 1

wrappedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…