diff options
author | Ian Ward <ian@excess.org> | 2014-01-04 21:09:40 -0500 |
---|---|---|
committer | Ian Ward <ian@excess.org> | 2014-01-04 21:09:40 -0500 |
commit | 1193c0bfb5225d030db4d24af2fb3bcf697888f6 (patch) | |
tree | 8fc9b10ef85fb296663c827bb3213e572b4cbd55 /urwid/display_common.py | |
parent | b6ce62b9bc03cf1b4dfc80e616e4614d2222d9ab (diff) | |
download | urwid-1193c0bfb5225d030db4d24af2fb3bcf697888f6.tar.gz |
fix #24 register_palette_entry: "hX" form with X>15
Diffstat (limited to 'urwid/display_common.py')
-rwxr-xr-x | urwid/display_common.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/urwid/display_common.py b/urwid/display_common.py index fc513f0..52b1704 100755 --- a/urwid/display_common.py +++ b/urwid/display_common.py @@ -816,18 +816,29 @@ class BaseScreen(object): if mono is None: mono = DEFAULT mono = AttrSpec(mono, DEFAULT, 1) - + if foreground_high is None: foreground_high = foreground if background_high is None: background_high = background - high_88 = AttrSpec(foreground_high, background_high, 88) high_256 = AttrSpec(foreground_high, background_high, 256) + # 'hX' where X > 15 are different in 88/256 color, use + # basic colors for 88-color mode if high colors are specified + # in this way (also avoids crash when X > 87) + def large_h(desc): + if not desc.startswith('h'): + return False + num = int(desc[1:], 10) + return num > 15 + if large_h(foreground_high) or large_h(background_high): + high_88 = basic + else: + high_88 = AttrSpec(foreground_high, background_high, 88) + signals.emit_signal(self, UPDATE_PALETTE_ENTRY, name, basic, mono, high_88, high_256) self._palette[name] = (basic, mono, high_88, high_256) - def _test(): |