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

Class NcursesUI

lib/utils/tui.py:29–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27from thirdparty.six.moves import configparser as _configparser
28
29class NcursesUI:
30 def __init__(self, stdscr, parser):
31 self.stdscr = stdscr
32 self.parser = parser
33 self.current_tab = 0
34 self.current_field = 0
35 self.scroll_offset = 0
36 self.tabs = []
37 self.fields = {}
38 self.running = False
39 self.process = None
40 self.queue = None
41
42 # Initialize colors
43 curses.start_color()
44 curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_CYAN) # Header
45 curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLUE) # Active tab
46 curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_WHITE) # Inactive tab
47 curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK) # Selected field
48 curses.init_pair(5, curses.COLOR_GREEN, curses.COLOR_BLACK) # Help text
49 curses.init_pair(6, curses.COLOR_RED, curses.COLOR_BLACK) # Error/Important
50 curses.init_pair(7, curses.COLOR_CYAN, curses.COLOR_BLACK) # Label
51
52 # Setup curses
53 curses.curs_set(1)
54 self.stdscr.keypad(1)
55
56 # Parse option groups
57 self._parse_options()
58
59 def _parse_options(self):
60 """Parse command line options into tabs and fields"""
61 for group in self.parser.option_groups:
62 tab_data = {
63 'title': group.title,
64 'description': group.get_description() if hasattr(group, 'get_description') and group.get_description() else "",
65 'options': []
66 }
67
68 for option in group.option_list:
69 field_data = {
70 'dest': option.dest,
71 'label': self._format_option_strings(option),
72 'help': option.help if option.help else "",
73 'type': option.type if hasattr(option, 'type') and option.type else 'bool',
74 'value': '',
75 'default': defaults.get(option.dest) if defaults.get(option.dest) else None
76 }
77 tab_data['options'].append(field_data)
78 self.fields[(group.title, option.dest)] = field_data
79
80 self.tabs.append(tab_data)
81
82 def _format_option_strings(self, option):
83 """Format option strings for display"""
84 parts = []
85 if hasattr(option, '_short_opts') and option._short_opts:
86 parts.extend(option._short_opts)

Callers 1

mainFunction · 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…