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

Method get_widget

mitmproxy/tools/console/options.py:34–68  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

32 super().__init__(self.get_widget())
33
34 def get_widget(self):
35 val = self.opt.current()
36 if self.opt.typespec is bool:
37 displayval = "true" if val else "false"
38 elif not val:
39 displayval = ""
40 elif self.opt.typespec == Sequence[str]:
41 displayval = pprint.pformat(val, indent=1)
42 else:
43 displayval = str(val)
44
45 changed = self.walker.master.options.has_changed(self.opt.name)
46 if self.focused:
47 valstyle = "option_active_selected" if changed else "option_selected"
48 else:
49 valstyle = "option_active" if changed else "text"
50
51 if self.editing:
52 valw = urwid.Edit(edit_text=displayval)
53 else:
54 valw = urwid.AttrMap(
55 urwid.Padding(urwid.Text([(valstyle, displayval)])), valstyle
56 )
57
58 return urwid.Columns(
59 [
60 (
61 self.namewidth,
62 urwid.Text([("title", self.opt.name.ljust(self.namewidth))]),
63 ),
64 valw,
65 ],
66 dividechars=2,
67 focus_column=1,
68 )
69
70 def get_edit_text(self):
71 return self._w[1].get_edit_text()

Callers 1

__init__Method · 0.95

Calls 3

currentMethod · 0.45
has_changedMethod · 0.45
EditMethod · 0.45

Tested by

no test coverage detected