MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / _edit_field

Method _edit_field

lib/utils/tui.py:285–343  ·  view source on GitHub ↗

Edit the current field

(self)

Source from the content-addressed store, hash-verified

283 return lines
284
285 def _edit_field(self):
286 """Edit the current field"""
287 tab = self.tabs[self.current_tab]
288 if self.current_field >= len(tab['options']):
289 return
290
291 option = tab['options'][self.current_field]
292
293 if option['type'] == 'bool':
294 # Toggle boolean
295 option['value'] = not option['value']
296 else:
297 # Text input
298 height, width = self.stdscr.getmaxyx()
299
300 # Create input window
301 input_win = curses.newwin(5, width - 20, height // 2 - 2, 10)
302 input_win.box()
303 input_win.attron(curses.color_pair(2))
304 input_win.addstr(0, 2, " Edit %s " % option['label'][:20])
305 input_win.attroff(curses.color_pair(2))
306 input_win.addstr(2, 2, "Value:")
307 input_win.refresh()
308
309 # Get input
310 curses.echo()
311 curses.curs_set(1)
312
313 # Pre-fill with existing value
314 current_value = str(option['value']) if option['value'] else ""
315 input_win.addstr(2, 9, current_value)
316 input_win.move(2, 9)
317
318 try:
319 new_value = input_win.getstr(2, 9, width - 32).decode('utf-8')
320
321 # Validate and convert based on type
322 if option['type'] == 'int':
323 try:
324 option['value'] = int(new_value) if new_value else None
325 except ValueError:
326 option['value'] = None
327 elif option['type'] == 'float':
328 try:
329 option['value'] = float(new_value) if new_value else None
330 except ValueError:
331 option['value'] = None
332 else:
333 option['value'] = new_value if new_value else None
334 except:
335 pass
336
337 curses.noecho()
338 curses.curs_set(0)
339
340 # Clear input window
341 input_win.clear()
342 input_win.refresh()

Callers 1

runMethod · 0.95

Calls 2

decodeMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected