Merge branch 'master' into resize
Conflicts: pudb/debugger.py pudb/settings.py
This commit is contained in:
commit
9f04a9f3a5
@ -1,4 +1,4 @@
|
||||
NUM_VERSION = (2011, 2)
|
||||
NUM_VERSION = (2011, 3)
|
||||
VERSION = ".".join(str(nv) for nv in NUM_VERSION)
|
||||
|
||||
|
||||
|
@ -490,8 +490,15 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
|
||||
# stack listeners -----------------------------------------------------
|
||||
def examine_frame(w, size, key):
|
||||
from pudb import CONFIG
|
||||
|
||||
_, pos = self.stack_list._w.get_focus()
|
||||
self.debugger.set_frame_index(len(self.debugger.stack)-1-pos)
|
||||
if CONFIG["current_stack_frame"] == "top":
|
||||
self.debugger.set_frame_index(len(self.debugger.stack)-1-pos)
|
||||
elif CONFIG["current_stack_frame"] == "bottom":
|
||||
self.debugger.set_frame_index(pos)
|
||||
else:
|
||||
raise ValueError("invalid value for 'current_stack_frame' pref")
|
||||
|
||||
self.stack_list.listen("enter", examine_frame)
|
||||
|
||||
@ -1116,11 +1123,6 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
from pudb.settings import edit_config, save_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,
|
||||
@ -1223,7 +1225,8 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
self.message("Package 'pygments' not found. "
|
||||
"Syntax highlighting disabled.")
|
||||
|
||||
WELCOME_LEVEL = "d"
|
||||
from pudb import CONFIG
|
||||
WELCOME_LEVEL = "e000"
|
||||
if CONFIG["seen_welcome"] < WELCOME_LEVEL:
|
||||
CONFIG["seen_welcome"] = WELCOME_LEVEL
|
||||
from pudb import VERSION
|
||||
@ -1235,6 +1238,11 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
"a terminal. If you've worked with the excellent (but nowadays "
|
||||
"ancient) DOS-based Turbo Pascal or C tools, PuDB's UI might "
|
||||
"look familiar.\n\n"
|
||||
"If you're new here, welcome! The help screen (invoked by hitting "
|
||||
"'?' after this message) should get you on your way.\n\n"
|
||||
"New features in version 2011.3:\n\n"
|
||||
"- Finer-grained string highlighting (submitted by Aaron Meurer)\n"
|
||||
"- Prefs tweaks, instant-apply, top-down stack (submitted by Aaron Meurer)\n\n"
|
||||
"New features in version 2011.2:\n\n"
|
||||
"- Fix for post-mortem debugging (submitted by 'Sundance')\n\n"
|
||||
"New features in version 2011.1:\n\n"
|
||||
@ -1245,15 +1253,9 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
"- Stored preferences (no more pesky IPython prompt!)\n"
|
||||
"- Themes\n"
|
||||
"- Line numbers (optional)\n"
|
||||
"\nHit Ctrl-P to set up PuDB.\n\n"
|
||||
"If you're new here, welcome! The help screen (invoked by hitting "
|
||||
"'?' after this message) should get you on your way." % VERSION)
|
||||
|
||||
% VERSION)
|
||||
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()
|
||||
|
||||
|
||||
@ -1286,7 +1288,7 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
|
||||
from pudb import VERSION
|
||||
caption = [(None,
|
||||
u"PuDB %s - ?:help n:next s:step into b:breakpoint o:output "
|
||||
u"PuDB %s - ?:help n:next s:step into b:breakpoint o:output "
|
||||
"t:run to cursor !:python shell"
|
||||
% VERSION)]
|
||||
|
||||
@ -1424,8 +1426,17 @@ class DebuggerUI(FrameVarInfoKeeper):
|
||||
code.co_name, class_name,
|
||||
self._format_fname(code.co_filename), lineno)
|
||||
|
||||
self.stack_walker[:] = [make_frame_ui(fl)
|
||||
for fl in self.debugger.stack[::-1]]
|
||||
from pudb import CONFIG
|
||||
|
||||
if CONFIG["current_stack_frame"] == "top":
|
||||
self.stack_walker[:] = [make_frame_ui(fl)
|
||||
for fl in self.debugger.stack[::-1]]
|
||||
elif CONFIG["current_stack_frame"] == "bottom":
|
||||
self.stack_walker[:] = [make_frame_ui(fl)
|
||||
for fl in self.debugger.stack]
|
||||
else:
|
||||
raise ValueError("invalid value for 'current_stack_frame' pref")
|
||||
|
||||
|
||||
def show_exception(self, exc_type, exc_value, traceback):
|
||||
from traceback import format_exception
|
||||
|
@ -54,19 +54,22 @@ def load_config():
|
||||
conf_dict.setdefault("theme", "classic")
|
||||
conf_dict.setdefault("line_numbers", False)
|
||||
conf_dict.setdefault("seen_welcome", "a")
|
||||
|
||||
conf_dict.setdefault("sidebar_width", 0.5)
|
||||
conf_dict.setdefault("variables_height", 1)
|
||||
conf_dict.setdefault("stack_height", 1)
|
||||
conf_dict.setdefault("breakpoints_height", 1)
|
||||
|
||||
def hack_bool(name):
|
||||
conf_dict.setdefault("current_stack_frame", "top")
|
||||
|
||||
def normalize_bool_inplace(name):
|
||||
try:
|
||||
if conf_dict[name].lower() in ["0", "false", "off"]:
|
||||
conf_dict[name] = False
|
||||
except:
|
||||
pass
|
||||
|
||||
hack_bool("line_numbers")
|
||||
normalize_bool_inplace("line_numbers")
|
||||
|
||||
return conf_dict
|
||||
|
||||
@ -93,19 +96,47 @@ def save_config(conf_dict):
|
||||
|
||||
|
||||
|
||||
|
||||
def edit_config(ui, conf_dict):
|
||||
import urwid
|
||||
|
||||
heading = urwid.Text("This is the preferences screen for PuDB\n"
|
||||
def _update_config(check_box, new_state, option_newvalue):
|
||||
option, newvalue = option_newvalue
|
||||
new_conf_dict = {option: newvalue}
|
||||
if option == "theme":
|
||||
# only activate if the new state of the radio button is 'on'
|
||||
if new_state:
|
||||
if newvalue is None:
|
||||
newvalue = theme_edit.get_edit_text()
|
||||
|
||||
conf_dict.update(theme=newvalue)
|
||||
ui.setup_palette(ui.screen)
|
||||
|
||||
for sl in ui.source:
|
||||
sl._invalidate()
|
||||
|
||||
elif option == "line_numbers":
|
||||
new_conf_dict["line_numbers"] = not check_box.get_state()
|
||||
conf_dict.update(new_conf_dict)
|
||||
|
||||
for sl in ui.source:
|
||||
sl._invalidate()
|
||||
|
||||
elif option == "current_stack_frame":
|
||||
# only activate if the new state of the radio button is 'on'
|
||||
if new_state:
|
||||
conf_dict.update(new_conf_dict)
|
||||
ui.update_stack()
|
||||
|
||||
heading = urwid.Text("This is the preferences screen for PuDB. "
|
||||
"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())
|
||||
"Configuration settings are saved in "
|
||||
"%s.\n" % get_save_config_path())
|
||||
|
||||
cb_line_numbers = urwid.CheckBox("Show Line Numbers",
|
||||
bool(conf_dict["line_numbers"]))
|
||||
bool(conf_dict["line_numbers"]), on_state_change=_update_config,
|
||||
user_data=("line_numbers", None))
|
||||
|
||||
shell_info = urwid.Text("This is the shell that will be used when you hit !\n")
|
||||
shell_info = urwid.Text("This is the shell that will be used when you hit '!'.\n")
|
||||
shells = ["classic", "ipython"]
|
||||
|
||||
shell_rb_grp = []
|
||||
@ -122,17 +153,30 @@ def edit_config(ui, conf_dict):
|
||||
theme_edit = urwid.Edit(edit_text=conf_dict["theme"])
|
||||
theme_rbs = [
|
||||
urwid.RadioButton(theme_rb_grp, name,
|
||||
conf_dict["theme"] == name)
|
||||
conf_dict["theme"] == name, on_state_change=_update_config,
|
||||
user_data=("theme", name))
|
||||
for name in THEMES]+[
|
||||
urwid.RadioButton(theme_rb_grp, "Custom:",
|
||||
not known_theme),
|
||||
not known_theme, on_state_change=_update_config,
|
||||
user_data=("theme", None)),
|
||||
urwid.Padding(
|
||||
urwid.AttrMap(theme_edit, "value"),
|
||||
left=4),
|
||||
|
||||
urwid.Text("\nTo use a custom theme, see example-theme.py in the "
|
||||
"pudb distribution. Enter the full path to a file like it in the "
|
||||
"box above."),
|
||||
"box above. '~' will be expanded to your home directory."),
|
||||
]
|
||||
|
||||
stack_rb_group = []
|
||||
stack_opts = ["top", "bottom"]
|
||||
stack_info = urwid.Text("Show the current stack frame at the\n")
|
||||
stack_rbs = [
|
||||
urwid.RadioButton(stack_rb_group, name,
|
||||
conf_dict["current_stack_frame"] == name,
|
||||
on_state_change=_update_config,
|
||||
user_data=("current_stack_frame", name))
|
||||
for name in stack_opts
|
||||
]
|
||||
|
||||
if ui.dialog(
|
||||
@ -143,29 +187,24 @@ def edit_config(ui, conf_dict):
|
||||
+ [urwid.AttrMap(urwid.Text("Shell:\n"), "group head")]
|
||||
+ [shell_info]
|
||||
+ shell_rbs
|
||||
+ [urwid.AttrMap(urwid.Text("\nTheme:\n"), "group head")] + theme_rbs,
|
||||
+ [urwid.AttrMap(urwid.Text("\nTheme:\n"), "group head")]
|
||||
+ theme_rbs
|
||||
+ [urwid.AttrMap(urwid.Text("\nStack Order:\n"), "group head")]
|
||||
+ [stack_info]
|
||||
+ stack_rbs
|
||||
),
|
||||
[
|
||||
("OK", True),
|
||||
("Cancel", False),
|
||||
("Close", True),
|
||||
],
|
||||
title="Edit Preferences"):
|
||||
|
||||
# Only update the shell setting here. Instant-apply (above) takes care
|
||||
# of updating everything else.
|
||||
|
||||
for shell, shell_rb in zip(shells, shell_rbs):
|
||||
if shell_rb.get_state():
|
||||
conf_dict["shell"] = shell
|
||||
|
||||
saw_theme = False
|
||||
for theme, theme_rb in zip(THEMES, theme_rbs):
|
||||
if theme_rb.get_state():
|
||||
conf_dict["theme"] = theme
|
||||
saw_theme = True
|
||||
|
||||
if not saw_theme:
|
||||
conf_dict["theme"] = theme_edit.get_edit_text()
|
||||
|
||||
conf_dict["line_numbers"] = cb_line_numbers.get_state()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -99,6 +99,12 @@ def get_palette(may_use_fancy_formats, theme="classic"):
|
||||
("keyword", add_setting("white", "bold"), "dark blue"),
|
||||
("name", "light cyan", "dark blue"),
|
||||
("literal", "light magenta", "dark blue"),
|
||||
|
||||
("string", "light magenta", "dark blue"),
|
||||
("doublestring", "light magenta", "dark blue"),
|
||||
("singlestring", "light magenta", "dark blue"),
|
||||
("docstring", "light magenta", "dark blue"),
|
||||
|
||||
("punctuation", "light gray", "dark blue"),
|
||||
("comment", "light gray", "dark blue"),
|
||||
("bp_star", "dark red", "dark blue"),
|
||||
@ -115,8 +121,13 @@ def get_palette(may_use_fancy_formats, theme="classic"):
|
||||
"source": ("black", "default"),
|
||||
"keyword": ("brown", "default"),
|
||||
"kw_namespace": ("dark magenta", "default"),
|
||||
|
||||
"literal": ("black", "default"),
|
||||
"string": ("dark red", "default"),
|
||||
"doublestring": ("dark red", "default"),
|
||||
"singlestring": ("dark red", "default"),
|
||||
"docstring": ("dark red", "default"),
|
||||
|
||||
"punctuation": ("black", "default"),
|
||||
"comment": ("dark blue", "default"),
|
||||
"classname": ("dark cyan", "default"),
|
||||
@ -210,7 +221,13 @@ def get_palette(may_use_fancy_formats, theme="classic"):
|
||||
|
||||
"line number": ("dark gray", "black"),
|
||||
"keyword": ("yellow", "black"),
|
||||
|
||||
"literal": ("dark magenta", "black"),
|
||||
"string": ("dark magenta", "black"),
|
||||
"doublestring": ("dark magenta", "black"),
|
||||
"singlestring": ("dark magenta", "black"),
|
||||
"docstring": ("dark magenta", "black"),
|
||||
|
||||
"name": ("light cyan", "black"),
|
||||
"punctuation": ("yellow", "black"),
|
||||
"comment": ("light blue", "black"),
|
||||
@ -267,7 +284,9 @@ def get_palette(may_use_fancy_formats, theme="classic"):
|
||||
"palette": palette_dict,
|
||||
"add_setting": add_setting,
|
||||
}
|
||||
execfile(theme, symbols)
|
||||
|
||||
from os.path import expanduser
|
||||
execfile(expanduser(theme), symbols)
|
||||
except:
|
||||
print "Error when importing theme:"
|
||||
from traceback import print_exc
|
||||
|
Loading…
x
Reference in New Issue
Block a user