MCPcopy
hub / github.com/mitmproxy/mitmproxy / keypress

Method keypress

mitmproxy/tools/console/options.py:165–217  ·  view source on GitHub ↗
(self, size, key)

Source from the content-addressed store, hash-verified

163 signals.status_message.send(message=str(e))
164
165 def keypress(self, size, key):
166 if self.walker.editing:
167 if key == "enter":
168 foc, idx = self.get_focus()
169 v = self.walker.get_edit_text()
170 try:
171 self.master.options.set(f"{foc.opt.name}={v}")
172 except exceptions.OptionsError as v:
173 signals.status_message.send(message=str(v))
174 self.walker.stop_editing()
175 return None
176 elif key == "esc":
177 self.walker.stop_editing()
178 return None
179 else:
180 if key == "m_start":
181 self.set_focus(0)
182 self.walker._modified()
183 elif key == "m_end":
184 self.set_focus(len(self.walker.opts) - 1)
185 self.walker._modified()
186 elif key == "m_select":
187 foc, idx = self.get_focus()
188 if foc.opt.typespec is bool:
189 self.master.options.toggler(foc.opt.name)()
190 # Bust the focus widget cache
191 self.set_focus(self.walker.index)
192 elif can_edit_inplace(foc.opt):
193 self.walker.start_editing()
194 self.walker._modified()
195 elif foc.opt.choices:
196 self.master.overlay(
197 overlay.Chooser(
198 self.master,
199 foc.opt.name,
200 foc.opt.choices,
201 foc.opt.current(),
202 self.master.options.setter(foc.opt.name),
203 )
204 )
205 elif foc.opt.typespec in (Sequence[str], typing.Sequence[str]):
206 self.master.overlay(
207 overlay.OptionsOverlay(
208 self.master,
209 foc.opt.name,
210 foc.opt.current(),
211 HELP_HEIGHT + 5,
212 ),
213 valign="top",
214 )
215 else:
216 raise NotImplementedError()
217 return super().keypress(size, key)
218
219
220class OptionHelp(urwid.Frame):

Callers

nothing calls this directly

Calls 14

can_edit_inplaceFunction · 0.85
stop_editingMethod · 0.80
_modifiedMethod · 0.80
togglerMethod · 0.80
start_editingMethod · 0.80
overlayMethod · 0.80
get_focusMethod · 0.45
get_edit_textMethod · 0.45
setMethod · 0.45
sendMethod · 0.45
set_focusMethod · 0.45
currentMethod · 0.45

Tested by

no test coverage detected