Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.debugger = dbg
from urwid import AttrMap
from pudb.ui_tools import SearchController
self.search_controller = SearchController(self)
self.last_module_filter = ""
# {{{ build ui
# {{{ left/source column
self.source = urwid.SimpleListWalker([])
self.source_list = urwid.ListBox(self.source)
self.source_sigwrap = SignalWrap(self.source_list)
self.source_attr = urwid.AttrMap(self.source_sigwrap, "source")
self.source_hscroll_start = 0
self.cmdline_history = []
self.cmdline_history_position = -1
self.cmdline_contents = urwid.SimpleFocusListWalker([])
self.cmdline_list = urwid.ListBox(self.cmdline_contents)
self.cmdline_edit = urwid.Edit([
("command line prompt", ">>> ")
])
cmdline_edit_attr = urwid.AttrMap(self.cmdline_edit, "command line edit")
self.cmdline_edit_sigwrap = SignalWrap(
cmdline_edit_attr, is_preemptive=True)
def clear_cmdline_history(btn):
def clear_cmdline_history(btn):
del self.cmdline_contents[:]
self.cmdline_edit_bar = urwid.Columns([
self.cmdline_edit_sigwrap,
("fixed", 10, AttrMap(
urwid.Button("Clear", clear_cmdline_history),
"command line clear button", "command line focused button"))
])
self.cmdline_pile = urwid.Pile([
("flow", urwid.Text("Command line: [Ctrl-X]")),
("weight", 1, urwid.AttrMap(self.cmdline_list, "command line output")),
("flow", self.cmdline_edit_bar),
])
self.cmdline_sigwrap = SignalWrap(
urwid.AttrMap(self.cmdline_pile, None, "focused sidebar")
)
self.cmdline_on = not CONFIG["hide_cmdline_win"]
self.cmdline_weight = 1
self.lhs_col = urwid.Pile([
("weight", 5, self.source_attr),
("weight", self.cmdline_weight if self.cmdline_on else 0,
self.cmdline_sigwrap),
])
# }}}
# {{{ right column
self.locals = urwid.SimpleListWalker([])
self.var_list = SignalWrap(
def dialog(self, content, buttons_and_results,
title=None, bind_enter_esc=True, focus_buttons=False,
extra_bindings=[]):
class ResultSetter:
def __init__(subself, res):
subself.res = res
def __call__(subself, btn):
self.quit_event_loop = [subself.res]
Attr = urwid.AttrMap
if bind_enter_esc:
content = SignalWrap(content)
def enter(w, size, key): self.quit_event_loop = [True]
def esc(w, *args): self.quit_event_loop = [False]
content.listen("enter", enter)
content.listen("esc", esc)
content.listen_mouse_event("mouse press", 3, esc)
button_widgets = []
for btn_descr in buttons_and_results:
if btn_descr is None:
button_widgets.append(urwid.Text(""))
else:
btn_text, btn_result = btn_descr
button_widgets.append(
Attr(urwid.Button(btn_text, ResultSetter(btn_result)),
"button", "focused button"))
Attr = urwid.AttrMap
self.search_box = None
self.last_module_filter = ""
self.source = urwid.SimpleListWalker([])
self.source_list = urwid.ListBox(self.source)
self.source_sigwrap = SignalWrap(self.source_list)
self.source_hscroll_start = 0
self.lhs_col = urwid.Pile([
("weight", 1, urwid.AttrMap(self.source_sigwrap, "source"))
])
self.locals = urwid.SimpleListWalker([])
self.var_list = SignalWrap(
urwid.ListBox(self.locals))
self.stack_walker = urwid.SimpleListWalker([])
self.stack_list = SignalWrap(
urwid.ListBox(self.stack_walker))
self.bp_walker = urwid.SimpleListWalker([])
self.bp_list = SignalWrap(
urwid.ListBox(self.bp_walker))
self.rhs_col = urwid.Pile([
("weight", float(CONFIG["variables_weight"]), Attr(urwid.Pile([
("flow", urwid.Text(make_hotkey_markup("_Variables:"))),
Attr(self.var_list, "variables"),
]), None, "focused sidebar"),),
("weight", float(CONFIG["stack_weight"]), Attr(urwid.Pile([
def dialog(self, content, buttons_and_results,
title=None, bind_enter_esc=True, focus_buttons=False,
extra_bindings=[]):
class ResultSetter:
def __init__(subself, res): # noqa
subself.res = res
def __call__(subself, btn): # noqa
self.quit_event_loop = [subself.res]
Attr = urwid.AttrMap # noqa
if bind_enter_esc:
content = SignalWrap(content)
def enter(w, size, key):
self.quit_event_loop = [True]
def esc(w, size, key):
self.quit_event_loop = [False]
content.listen("enter", enter)
content.listen("esc", esc)
button_widgets = []
for btn_descr in buttons_and_results:
if btn_descr is None:
button_widgets.append(urwid.Text(""))
else:
btn_text, btn_result = btn_descr
self.source = urwid.SimpleListWalker([])
self.source_list = urwid.ListBox(self.source)
self.source_sigwrap = SignalWrap(self.source_list)
self.source_hscroll_start = 0
self.lhs_col = urwid.Pile([
("weight", 1, urwid.AttrMap(self.source_sigwrap, "source"))
])
self.locals = urwid.SimpleListWalker([])
self.var_list = SignalWrap(
urwid.ListBox(self.locals))
self.stack_walker = urwid.SimpleListWalker([])
self.stack_list = SignalWrap(
urwid.ListBox(self.stack_walker))
self.bp_walker = urwid.SimpleListWalker([])
self.bp_list = SignalWrap(
urwid.ListBox(self.bp_walker))
self.rhs_col = urwid.Pile([
("weight", float(CONFIG["variables_weight"]), Attr(urwid.Pile([
("flow", urwid.Text(make_hotkey_markup("_Variables:"))),
Attr(self.var_list, "variables"),
]), None, "focused sidebar"),),
("weight", float(CONFIG["stack_weight"]), Attr(urwid.Pile([
("flow", urwid.Text(make_hotkey_markup("_Stack:"))),
Attr(self.stack_list, "stack"),
]), None, "focused sidebar"),),
("weight", float(CONFIG["breakpoints_weight"]), Attr(urwid.Pile([
content,
("fixed", 15, urwid.ListBox(button_widgets)),
], dividechars=1)
if focus_buttons:
w.set_focus_column(1)
if title is not None:
w = urwid.Pile([
("flow", urwid.AttrMap(
urwid.Text(title, align="center"),
"dialog title")),
("fixed", 1, urwid.SolidFill()),
w])
w = SignalWrap(w)
for key, binding in extra_bindings:
w.listen(key, binding)
w = urwid.LineBox(w)
w = urwid.Overlay(w, self.top,
align="center",
valign="middle",
width=('relative', 75),
height=('relative', 75),
)
w = Attr(w, "background")
return self.event_loop(w)[0]