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

Class GridRow

mitmproxy/tools/console/grideditor/base.py:80–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78
79
80class GridRow(urwid.WidgetWrap):
81 def __init__(
82 self,
83 focused: int | None,
84 editing: bool,
85 editor: "GridEditor",
86 values: tuple[Iterable[bytes], Container[int]],
87 ) -> None:
88 self.focused = focused
89 self.editor = editor
90 self.edit_col: Cell | None = None
91
92 errors = values[1]
93 self.fields: Sequence[Any] = []
94 for i, v in enumerate(values[0]):
95 if focused == i and editing:
96 self.edit_col = self.editor.columns[i].Edit(v)
97 self.fields.append(self.edit_col)
98 else:
99 w = self.editor.columns[i].Display(v)
100 if focused == i:
101 if i in errors:
102 w = urwid.AttrMap(w, "focusfield_error")
103 else:
104 w = urwid.AttrMap(w, "focusfield")
105 elif i in errors:
106 w = urwid.AttrMap(w, "field_error")
107 self.fields.append(w)
108
109 fspecs = self.fields[:]
110 if len(self.fields) > 1:
111 fspecs[0] = ("fixed", self.editor.first_width + 2, fspecs[0])
112 w = urwid.Columns(fspecs, dividechars=2)
113 if focused is not None:
114 w.focus_position = focused
115 super().__init__(w)
116
117 def keypress(self, s, k):
118 if self.edit_col:
119 w = self._w.column_widths(s)[self.focused]
120 k = self.edit_col.keypress((w,), k)
121 return k
122
123 def selectable(self):
124 return True
125
126
127class GridWalker(urwid.ListWalker):

Callers 4

start_editMethod · 0.85
get_focusMethod · 0.85
get_nextMethod · 0.85
get_prevMethod · 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…