Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add 256 color support to syntax highlighting.

  • Loading branch information...
commit 98a048167a849709cc267aaf1a931ef980c2d654 1 parent 3ee234b
@kemist kemist authored
Showing with 42 additions and 3 deletions.
  1. +17 −0 example-theme.py
  2. +8 −1 pudb/debugger.py
  3. +17 −2 pudb/theme.py
View
17 example-theme.py
@@ -1,3 +1,20 @@
+# Supported 16 color values:
+# 'h0' (color number 0) through 'h15' (color number 15)
+# or
+# 'default' (use the terminal's default foreground),
+# 'black', 'dark red', 'dark green', 'brown', 'dark blue',
+# 'dark magenta', 'dark cyan', 'light gray', 'dark gray',
+# 'light red', 'light green', 'yellow', 'light blue',
+# 'light magenta', 'light cyan', 'white'
+#
+# Supported 256 color values:
+# 'h0' (color number 0) through 'h255' (color number 255)
+#
+# 256 color chart: http://en.wikipedia.org/wiki/File:Xterm_color_chart.png
+#
+# "setting_name": (foreground_color, background_color),
+
palette.update({
"source": (add_setting("black", "underline"), "dark green"),
+ "comment": ("h250", "default")
})
View
9 pudb/debugger.py
@@ -325,7 +325,7 @@ def _runscript(self, filename):
SelectableText, SignalWrap, StackFrame, BreakpointFrame
from pudb.var_view import FrameVarInfoKeeper
-
+import curses
from urwid.raw_display import Screen
@@ -1145,6 +1145,13 @@ def help(w, size, key):
# {{{ setup
self.screen = ThreadsafeScreen()
+
+ curses.setupterm()
+ color_support = curses.tigetnum('colors')
+
+ if color_support == 256:
+ self.screen.colors = 256
+
self.setup_palette(self.screen)
self.show_count = 0
View
19 pudb/theme.py
@@ -1,6 +1,7 @@
THEMES = ["classic", "vim", "dark vim", "midnight"]
from pudb.py3compat import execfile, raw_input
+import urwid
def get_palette(may_use_fancy_formats, theme="classic"):
if may_use_fancy_formats:
@@ -291,6 +292,20 @@ def add_setting(color, setting):
from traceback import print_exc
print_exc()
raw_input("Hit enter:")
-
- return [(key,)+value for key, value in palette_dict.items()]
+
+ palette_list = []
+ for setting_name, color_values in palette_dict.items():
+ fg_color = color_values[0].lower().strip()
+ bg_color = color_values[1].lower().strip()
+
+ # Convert hNNN syntax to equivalent #RGB value (workaround for urwid issue)
+ if fg_color.startswith('h') or bg_color.startswith('h'):
+ attr = urwid.AttrSpec(fg_color, bg_color, colors=256)
+ palette_list.append((setting_name, 'default', 'default', 'default',
+ attr.foreground,
+ attr.background))
+ else:
+ palette_list.append((setting_name,) + color_values)
+
+ return palette_list
Please sign in to comment.
Something went wrong with that request. Please try again.