summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Cebzanov <tonycpsu@gmail.com>2020-04-15 14:43:36 -0400
committerTony Cebzanov <tonycpsu@gmail.com>2020-04-15 14:43:36 -0400
commitb747f28e520cf9f817b66d82ce008aab69870e9b (patch)
tree1b401fad8e3a36273f5442fbdf95c5b5e7d2745b
parent9c70860b79ea9e68a1b188d14c3c89ff161718d3 (diff)
downloadurwid-fix_404_high_color.tar.gz
Fix 256-color mode on some terminals. Addresses #404.fix_404_high_color
The initial 24-bit color implementation has problems when the terminal supports 256 but not 24-bit. This resulted from a mistake in how palette entries are registered, and should be fixed with this commit.
-rwxr-xr-xurwid/display_common.py6
-rw-r--r--urwid/raw_display.py2
2 files changed, 5 insertions, 3 deletions
diff --git a/urwid/display_common.py b/urwid/display_common.py
index 9717b61..131c0aa 100755
--- a/urwid/display_common.py
+++ b/urwid/display_common.py
@@ -920,6 +920,8 @@ class BaseScreen(with_metaclass(signals.MetaSignals, object)):
foreground_high = foreground
if background_high is None:
background_high = background
+
+ high_256 = AttrSpec(foreground_high, background_high, 256)
high_true = AttrSpec(foreground_high, background_high, 2**24)
# 'hX' where X > 15 are different in 88/256 color, use
@@ -938,8 +940,8 @@ class BaseScreen(with_metaclass(signals.MetaSignals, object)):
high_88 = AttrSpec(foreground_high, background_high, 88)
signals.emit_signal(self, UPDATE_PALETTE_ENTRY,
- name, basic, mono, high_88, high_true)
- self._palette[name] = (basic, mono, high_88, high_true)
+ name, basic, mono, high_88, high_256, high_true)
+ self._palette[name] = (basic, mono, high_88, high_256, high_true)
def _test():
diff --git a/urwid/raw_display.py b/urwid/raw_display.py
index f07c50d..4c90a68 100644
--- a/urwid/raw_display.py
+++ b/urwid/raw_display.py
@@ -101,7 +101,7 @@ class Screen(BaseScreen, RealTerminal):
def _on_update_palette_entry(self, name, *attrspecs):
# copy the attribute to a dictionary containing the escape seqences
- a = attrspecs[{16:0,1:1,88:2,256:3,2**24:3}[self.colors]]
+ a = attrspecs[{16:0,1:1,88:2,256:3,2**24:4}[self.colors]]
self._pal_attrspec[name] = a
self._pal_escape[name] = self._attrspec_to_escape(a)