Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Midnight theme #2

Merged
merged 12 commits into from

2 participants

@asmeurer
Collaborator

This adds a midnight theme, based on a theme from Xcode of the same name, and also includes other improvements.

asmeurer added some commits
@asmeurer asmeurer Add midnight theme, based on XCode's midnight theme
This looks best in a terminal with green text and a black background
(especially the background part)
1b95a54
@asmeurer asmeurer Add the midnight theme to the list of themes 2f92bdf
@asmeurer asmeurer Add information about configuration to the help
This also includes a snazzy function to convert the list of themes into
a line broken list, so you don't have to update it with future themes.

I didn't add too much info on custom themes.  The documentation for this
needs to be updated elsewhere, i.e., in the example theme file.
e46ecd2
@asmeurer asmeurer Add string to the list of pygments tokens
Some of the themes were using this, but it didn't work without this
0522dfc
@asmeurer asmeurer Add more fine-grained string tokens to the themes
And update the midnight theme to use them.

So far, String.Single and String.Double do not work, but I think this is
a bug in pygments (see
https://bitbucket.org/birkenfeld/pygments-main/issue/685).  So hopefully
they fill fix it and it will start working :)
1ea6f71
@asmeurer asmeurer Add distribute files that setup.py downloads to the .gitignore file 70f80aa
@inducer
Owner

Looks good, except for the documentation for the settings file. Not sure that's neededed since there's the interactive config screen. What do you think?

@asmeurer
Collaborator

There's an interactive config screen?

I tried to find this, as it would have helped a lot, but reading the online help and even the source code, I didn't see any, so I figured it didn't exist. I wouldn't have even known there were configuration options if I hadn't read the git history, and I had to read the source to figure out where the config file was (I found the get_save_config_path function and imported it and ran it).

So as things are now, this documentation definitely needs to be there. But if there really is an online config screen, then this can be backported to that (with some improvements to make it more visible)

@inducer
Owner

Yep, just hit Ctrl-p. I tried to make it as visible as possible. The new 'welcome' screen tells you about it whenever you switch to a new version, and it's at the top of the online help.

@asmeurer
Collaborator

Ah, well the subtitle escaped me :)

I think it should show the preferences screen the first time it is opened (along with the welcome screen). I'll see if any of the documentation I wrote should be backported there. But you are right that it should be removed.

Also, I don't know what it looks like on your terminal, but the gray titles against the gray background in the preferences screen are unreadable.

asmeurer added some commits
@asmeurer asmeurer Revert "Add information about configuration to the help"
This reverts commit e46ecd2.

I didn't realize there was already a preferences screen.  I may backport
some of this info to there.
5ba12fd
@asmeurer asmeurer Show the configuration screen on the first run 7ee1d00
@asmeurer asmeurer Add some helpful info to the preferences dialog 7e9a0c5
@asmeurer asmeurer Replace urwid.AttrWrap with urwid.AttrMap
According to the urwid docs, AttrWrap is deprecated, and AttrMap should
be used instead.  This seems to still work the same everywhere, though I
didn't check it extensively.
af67e9c
@asmeurer asmeurer Use blue instead of black for group headers
The black on gray was very difficult to see, at least in my Terminal.
If you want, I can use a different color, or if you insist on having
black, I can add this only to the midnight theme.
996a3e1
@asmeurer asmeurer Display the location where the settings are saved in the preferences …
…screen
45f2f1d
@asmeurer
Collaborator

I pushed some more fixes, including one that reverts the documentation commit. I tried to make the settings screen a little more visible to new users, first by automatically showing it, and second, by adding some more useful help.

I changed the heading color to blue. If you don't like this, I can use a different color (though I don't know why you wouldn't like it, since you seem to love blue :-), or just put it in the midnight theme. But the black on gray was, at least in my terminal, almost invisible.

Another feature that would be nice is if the settings updated in real time. That way, people could try out the different themes without having to switch back and forth from the settings screen. I don't know any urwid (other than the little I just learned from doing this), so I may not be able to figure out how to do it. I'll let you know my progress.

@inducer inducer merged commit 3b79e1b into inducer:master
@asmeurer
Collaborator

Thanks! I'll open a new pull request for auto-updating the prefs (I have it almost working).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 27, 2011
  1. @asmeurer

    Add midnight theme, based on XCode's midnight theme

    asmeurer authored
    This looks best in a terminal with green text and a black background
    (especially the background part)
  2. @asmeurer
  3. @asmeurer

    Add information about configuration to the help

    asmeurer authored
    This also includes a snazzy function to convert the list of themes into
    a line broken list, so you don't have to update it with future themes.
    
    I didn't add too much info on custom themes.  The documentation for this
    needs to be updated elsewhere, i.e., in the example theme file.
  4. @asmeurer

    Add string to the list of pygments tokens

    asmeurer authored
    Some of the themes were using this, but it didn't work without this
  5. @asmeurer

    Add more fine-grained string tokens to the themes

    asmeurer authored
    And update the midnight theme to use them.
    
    So far, String.Single and String.Double do not work, but I think this is
    a bug in pygments (see
    https://bitbucket.org/birkenfeld/pygments-main/issue/685).  So hopefully
    they fill fix it and it will start working :)
  6. @asmeurer
  7. @asmeurer

    Revert "Add information about configuration to the help"

    asmeurer authored
    This reverts commit e46ecd2.
    
    I didn't realize there was already a preferences screen.  I may backport
    some of this info to there.
  8. @asmeurer
  9. @asmeurer
  10. @asmeurer

    Replace urwid.AttrWrap with urwid.AttrMap

    asmeurer authored
    According to the urwid docs, AttrWrap is deprecated, and AttrMap should
    be used instead.  This seems to still work the same everywhere, though I
    didn't check it extensively.
  11. @asmeurer

    Use blue instead of black for group headers

    asmeurer authored
    The black on gray was very difficult to see, at least in my Terminal.
    If you want, I can use a different color, or if you insist on having
    black, I can add this only to the midnight theme.
  12. @asmeurer
This page is out of date. Refresh to see the latest.
View
1  .gitignore
@@ -4,3 +4,4 @@
*.egg-info
dist
build
+distribute-*
View
2  pudb/__init__.py
@@ -80,7 +80,7 @@ def quit_debugger(w, size, key):
% 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
63 pudb/debugger.py
@@ -285,7 +285,7 @@ def __init__(self, dbg):
FrameVarInfoKeeper.__init__(self)
self.debugger = dbg
- Attr = urwid.AttrWrap
+ Attr = urwid.AttrMap
self.search_box = None
self.last_module_filter = ""
@@ -296,7 +296,7 @@ def __init__(self, dbg):
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 @@ def __init__(self, dbg):
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 @@ def edit_inspector_detail(w, size, key):
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 @@ def insert_watch(w, size, key):
if self.dialog(
urwid.ListBox([
- urwid.AttrWrap(watch_edit, "value")
+ urwid.AttrMap(watch_edit, "value")
]),
[
("OK", True),
@@ -523,8 +523,8 @@ def examine_breakpoint(w, size, key):
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 @@ def go_to_line(w, size, key):
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 @@ def search(w, size, key):
_, 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 @@ def mod_exists(mod):
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 @@ def build_filtered_mod_list(filt_string=""):
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 @@ def keypress(self, size, key):
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 @@ def quit(w, size, key):
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 @@ def message(self, msg, title="Message", **kwargs):
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 @@ def __init__(subself, res):
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 @@ def esc(w, size, key): self.quit_event_loop = [False]
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 @@ def event_loop(self, toplevel=None):
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
23 pudb/settings.py
@@ -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
9 pudb/source_view.py
@@ -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
49 pudb/theme.py
@@ -1,4 +1,4 @@
-THEMES = ["classic", "vim", "dark vim"]
+THEMES = ["classic", "vim", "dark vim", "midnight"]
@@ -80,7 +80,7 @@ def add_setting(color, setting):
("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 add_setting(color, setting):
"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
6 pudb/ui_tools.py
@@ -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 @@ def keypress(self, size, key):
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
2  pudb/var_view.py
@@ -332,7 +332,7 @@ def add_item(self, prefix, var_label, value_str, id_path=None, attr_prefix=None)
# 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()
Something went wrong with that request. Please try again.