Merge branch 'master' of github.com:inducer/pudb

This commit is contained in:
Andreas Kloeckner 2011-07-27 18:48:23 -04:00
commit 64dd089ee6
8 changed files with 113 additions and 42 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
*.egg-info
dist
build
distribute-*

View File

@ -80,7 +80,7 @@ def runscript(mainpyfile, args=None, pre_run="", steal_output=False):
% status_msg),
urwid.Text("\n\nIf you decide to restart, this command will be run prior to "
"actually restarting:"),
urwid.AttrWrap(pre_run_edit, "value")
urwid.AttrMap(pre_run_edit, "value")
]),
[
("Restart", "restart"),

View File

@ -285,7 +285,7 @@ class DebuggerUI(FrameVarInfoKeeper):
FrameVarInfoKeeper.__init__(self)
self.debugger = dbg
Attr = urwid.AttrWrap
Attr = urwid.AttrMap
self.search_box = None
self.last_module_filter = ""
@ -296,7 +296,7 @@ class DebuggerUI(FrameVarInfoKeeper):
self.source_hscroll_start = 0
self.lhs_col = urwid.Pile([
("weight", 1, urwid.AttrWrap(self.source_sigwrap, "source"))
("weight", 1, urwid.AttrMap(self.source_sigwrap, "source"))
])
self.locals = urwid.SimpleListWalker([])
@ -334,9 +334,9 @@ class DebuggerUI(FrameVarInfoKeeper):
dividechars=1)
self.caption = urwid.Text("")
header = urwid.AttrWrap(self.caption, "header")
header = urwid.AttrMap(self.caption, "header")
self.top = SignalWrap(urwid.Frame(
urwid.AttrWrap(self.columns, "background"),
urwid.AttrMap(self.columns, "background"),
header))
# variable listeners --------------------------------------------------
@ -374,7 +374,7 @@ class DebuggerUI(FrameVarInfoKeeper):
watch_edit = urwid.Edit([
("label", "Watch expression: ")
], var.watch_expr.expression)
id_segment = [urwid.AttrWrap(watch_edit, "value"), urwid.Text("")]
id_segment = [urwid.AttrMap(watch_edit, "value"), urwid.Text("")]
buttons.extend([None, ("Delete", "del")])
@ -439,7 +439,7 @@ class DebuggerUI(FrameVarInfoKeeper):
if self.dialog(
urwid.ListBox([
urwid.AttrWrap(watch_edit, "value")
urwid.AttrMap(watch_edit, "value")
]),
[
("OK", True),
@ -523,8 +523,8 @@ class DebuggerUI(FrameVarInfoKeeper):
labelled_value("Hits: ", bp.hits),
urwid.Text(""),
enabled_checkbox,
urwid.AttrWrap(cond_edit, "value", "value"),
urwid.AttrWrap(ign_count_edit, "value", "value"),
urwid.AttrMap(cond_edit, "value", "value"),
urwid.AttrMap(ign_count_edit, "value", "value"),
])
result = self.dialog(lb, [
@ -634,7 +634,7 @@ class DebuggerUI(FrameVarInfoKeeper):
if self.dialog(
urwid.ListBox([
labelled_value("File :", self.shown_file),
urwid.AttrWrap(lineno_edit, "value")
urwid.AttrMap(lineno_edit, "value")
]),
[
("OK", True),
@ -674,18 +674,18 @@ class DebuggerUI(FrameVarInfoKeeper):
_, search_start = self.source.get_focus()
self.search_box = SearchBox(self)
self.search_attrwrap = urwid.AttrWrap(
self.search_AttrMap = urwid.AttrMap(
self.search_box, "search box")
self.lhs_col.item_types.insert(
0, ("flow", None))
self.lhs_col.widget_list.insert( 0, self.search_attrwrap)
self.lhs_col.widget_list.insert( 0, self.search_AttrMap)
self.columns.set_focus(self.lhs_col)
self.lhs_col.set_focus(self.search_attrwrap)
self.lhs_col.set_focus(self.search_AttrMap)
else:
self.columns.set_focus(self.lhs_col)
self.lhs_col.set_focus(self.search_attrwrap)
self.lhs_col.set_focus(self.search_AttrMap)
self.search_box.restart_search()
def search_next(w, size, key):
@ -762,7 +762,7 @@ class DebuggerUI(FrameVarInfoKeeper):
return ext == ".py"
new_mod_text = SelectableText("-- update me --")
new_mod_entry = urwid.AttrWrap(new_mod_text,
new_mod_entry = urwid.AttrMap(new_mod_text,
None, "focused selectable")
def build_filtered_mod_list(filt_string=""):
@ -770,7 +770,7 @@ class DebuggerUI(FrameVarInfoKeeper):
for name, mod in sys.modules.items()
if mod_exists(mod))
result = [urwid.AttrWrap(SelectableText(mod),
result = [urwid.AttrMap(SelectableText(mod),
None, "focused selectable")
for mod in modules if filt_string in mod]
new_mod_text.set_text("<<< IMPORT MODULE '%s' >>>" % filt_string)
@ -806,9 +806,9 @@ class DebuggerUI(FrameVarInfoKeeper):
lb = urwid.ListBox(mod_list)
w = urwid.Pile([
("flow", urwid.AttrWrap(filt_edit, "value")),
("flow", urwid.AttrMap(filt_edit, "value")),
("fixed", 1, urwid.SolidFill()),
urwid.AttrWrap(lb, "selectable")])
urwid.AttrMap(lb, "selectable")])
while True:
result = self.dialog(w, [
@ -972,14 +972,7 @@ class DebuggerUI(FrameVarInfoKeeper):
end()
def do_edit_config(w, size, key):
from pudb.settings import edit_config, save_config
from pudb import CONFIG
edit_config(self, CONFIG)
save_config(CONFIG)
self.setup_palette(self.screen)
for sl in self.source:
sl._invalidate()
self.run_edit_config()
def help(w, size, key):
self.message(HELP_TEXT, title="PuDB Help")
@ -1021,6 +1014,17 @@ class DebuggerUI(FrameVarInfoKeeper):
urwid.ListBox([urwid.Text(msg)]),
[("OK", True)], title=title, **kwargs)
def run_edit_config(self):
from pudb.settings import edit_config, save_config
from pudb import CONFIG
edit_config(self, CONFIG)
save_config(CONFIG)
self.setup_palette(self.screen)
for sl in self.source:
sl._invalidate()
def dialog(self, content, buttons_and_results,
title=None, bind_enter_esc=True, focus_buttons=False,
extra_bindings=[]):
@ -1031,7 +1035,7 @@ class DebuggerUI(FrameVarInfoKeeper):
def __call__(subself, btn):
self.quit_event_loop = [subself.res]
Attr = urwid.AttrWrap
Attr = urwid.AttrMap
if bind_enter_esc:
content = SignalWrap(content)
@ -1060,7 +1064,7 @@ class DebuggerUI(FrameVarInfoKeeper):
if title is not None:
w = urwid.Pile([
("flow", urwid.AttrWrap(
("flow", urwid.AttrMap(
urwid.Text(title, align="center"),
"dialog title")),
("fixed", 1, urwid.SolidFill()),
@ -1152,6 +1156,11 @@ class DebuggerUI(FrameVarInfoKeeper):
from pudb.settings import save_config
save_config(CONFIG)
self.message("Since this is the first time you've used PuDB, \n"
"I will show you a configuration screen. Hit Ctrl-P at any \n"
"time to get back to it.")
self.run_edit_config()
try:
if toplevel is None:

View File

@ -93,13 +93,19 @@ def save_config(conf_dict):
def edit_config(ui, conf_dict):
import urwid
heading = urwid.Text("This is the preferences screen for PuDB\n"
"Hit Ctrl-P at any time to get back to it.\n\n"
"Configuration settings are saved in \n"
"%s\n" % get_save_config_path())
cb_line_numbers = urwid.CheckBox("Show Line Numbers",
bool(conf_dict["line_numbers"]))
shell_info = urwid.Text("This is the shell that will be used when you hit !\n")
shells = ["classic", "ipython"]
shell_rb_grp = []
shell_rbs = [
shell_rbs = [
urwid.RadioButton(shell_rb_grp, name,
conf_dict["shell"] == name)
for name in shells]
@ -110,14 +116,14 @@ def edit_config(ui, conf_dict):
theme_rb_grp = []
theme_edit = urwid.Edit(edit_text=conf_dict["theme"])
theme_rbs = [
theme_rbs = [
urwid.RadioButton(theme_rb_grp, name,
conf_dict["theme"] == name)
for name in THEMES]+[
urwid.RadioButton(theme_rb_grp, "Custom:",
not known_theme),
urwid.Padding(
urwid.AttrWrap(theme_edit, "value"),
urwid.AttrMap(theme_edit, "value"),
left=4),
urwid.Text("\nTo use a custom theme, see example-theme.py in the "
@ -127,15 +133,18 @@ def edit_config(ui, conf_dict):
if ui.dialog(
urwid.ListBox(
[cb_line_numbers]
[heading]
+ [cb_line_numbers]
+ [urwid.Text("")]
+ [urwid.AttrWrap(urwid.Text("Shell:\n"), "group head")] + shell_rbs
+ [urwid.AttrWrap(urwid.Text("\nTheme:\n"), "group head")] + theme_rbs,
+ [urwid.AttrMap(urwid.Text("Shell:\n"), "group head")]
+ [shell_info]
+ shell_rbs
+ [urwid.AttrMap(urwid.Text("\nTheme:\n"), "group head")] + theme_rbs,
),
[
("OK", True),
("Cancel", False),
],
],
title="Edit Preferences"):
for shell, shell_rb in zip(shells, shell_rbs):
if shell_rb.get_state():

View File

@ -101,7 +101,7 @@ def format_source(debugger_ui, lines, breakpoints):
import pygments
except ImportError:
return [SourceLine(debugger_ui,
line.rstrip("\n\r").replace("\t", 8*" "),
line.rstrip("\n\r").replace("\t", 8*" "),
lineno_format % (i+1), None,
has_breakpoint=i+1 in breakpoints)
for i, line in enumerate(lines)]
@ -120,6 +120,13 @@ def format_source(debugger_ui, lines, breakpoints):
t.Name.Function: "name",
t.Name.Class: "name",
t.Punctuation: "punctuation",
t.String: "string",
# XXX: Single and Double don't actually work yet.
# See https://bitbucket.org/birkenfeld/pygments-main/issue/685
t.String.Double: "doublestring",
t.String.Single: "singlestring",
t.String.Backtick: "backtick",
t.String.Doc: "docstring",
t.Comment: "comment",
}

View File

@ -1,4 +1,4 @@
THEMES = ["classic", "vim", "dark vim"]
THEMES = ["classic", "vim", "dark vim", "midnight"]
@ -80,7 +80,7 @@ def get_palette(may_use_fancy_formats, theme="classic"):
("label", "black", "light gray"),
("value", "yellow", "dark blue"),
("fixed value", "light gray", "dark blue"),
("group head", add_setting("black", "bold"), "light gray"),
("group head", add_setting("dark blue", "bold"), "light gray"),
("search box", "black", "dark cyan"),
("search not found", "white", "dark red"),
@ -216,6 +216,51 @@ def get_palette(may_use_fancy_formats, theme="classic"):
"comment": ("light blue", "black"),
"bp_star": ("dark red", "black"),
})
elif theme == "midnight":
# Based on XCode's midnight theme
# Looks best in a console with green text against black background
palette_dict.update({
"variables": ("white", "default"),
"var label": ("dark blue", "default"),
"var value": ("white", "default"),
"stack": ("white", "default"),
"frame name": ("white", "default"),
"frame class": ("dark blue", "default"),
"frame location": ("light cyan", "default"),
"current frame name": (add_setting("white", "bold"), "default"),
"current frame class": ("dark blue", "default"),
"current frame location": ("light cyan", "default"),
"breakpoint": ("default", "default"),
"search box": ("default", "default"),
"source": ("white", "default"),
"highlighted source": ("white", "light cyan"),
"current source": ("white", "light gray"),
"current focused source": ("white", "brown"),
"line number": ("light gray", "default"),
"keyword": ("dark magenta", "default"),
"name": ("white", "default"),
"literal": ("dark cyan", "default"),
"string": ("dark red", "default"),
"doublestring": ("dark red", "default"),
"singlestring": ("light blue", "default"),
"docstring": ("light red", "default"),
"backtick": ("light green", "default"),
"punctuation": ("white", "default"),
"comment": ("dark green", "default"),
"classname": ("dark cyan", "default"),
"funcname": ("white", "default"),
"bp_star": ("dark red", "default"),
})
else:
try:
symbols = {

View File

@ -54,7 +54,7 @@ def make_hotkey_markup(s):
def labelled_value(label, value):
return urwid.AttrWrap(urwid.Text([
return urwid.AttrMap(urwid.Text([
("label", label), str(value)]),
"fixed value", "fixed value")
@ -205,9 +205,9 @@ class SearchBox(urwid.Edit):
return None
else:
if self.do_search(1, self.search_start):
self.ui.search_attrwrap.set_attr("search box")
self.ui.search_AttrMap.set_attr("search box")
else:
self.ui.search_attrwrap.set_attr("search not found")
self.ui.search_AttrMap.set_attr("search not found")
return result

View File

@ -332,7 +332,7 @@ class TopAndMainVariableWalker(ValueWalker):
# top level -------------------------------------------------------------------
SEPARATOR = urwid.AttrWrap(urwid.Text(""), "variable separator")
SEPARATOR = urwid.AttrMap(urwid.Text(""), "variable separator")
def make_var_view(frame_var_info, locals, globals):
vars = locals.keys()