summaryrefslogtreecommitdiff
path: root/menuconfig.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2019-11-23 19:15:17 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2019-11-23 19:28:28 +0100
commit7a98bc7944f1b390e5a82e40c62d0ce7540befdc (patch)
tree3d71283eef830117e144770b99241eb777f001b2 /menuconfig.py
parent810ae682a3b80ed621fd1e20c01241ac48381156 (diff)
menuconfig: Check that bright named colors are < curses.COLORS
The bright colors in the range 8-15 are not ANSI and are not guaranteed to be available. Previously, the code assumed that all named colors are always available on color terminals, and skipped the check against curses.COLORS. This led to this error e.g. with TERM=xterm (as opposed to xterm-256color) and the aquatic theme, which uses 'brightwhite': _curses.error: init_pair() returned ERR Fix it by checking the number returned for named colors against curses.COLORS as well. Came up in https://github.com/espressif/esp-idf/issues/4387.
Diffstat (limited to 'menuconfig.py')
-rwxr-xr-xmenuconfig.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/menuconfig.py b/menuconfig.py
index 1f2e9fa..7b1dbce 100755
--- a/menuconfig.py
+++ b/menuconfig.py
@@ -550,9 +550,6 @@ def _style_to_curses(style_def):
def parse_color(color_def):
color_def = color_def.split(":", 1)[1]
- if color_def in _STYLE_STD_COLORS:
- return _color_from_num(_STYLE_STD_COLORS[color_def])
-
# HTML format, #RRGGBB
if re.match("#[A-Fa-f0-9]{6}", color_def):
return _color_from_rgb((
@@ -560,19 +557,20 @@ def _style_to_curses(style_def):
int(color_def[3:5], 16),
int(color_def[5:7], 16)))
- try:
- color_num = _color_from_num(int(color_def, 0))
- except ValueError:
- _warn("Ignoring color ", color_def, "that's neither predefined "
- "nor a number")
-
- return -1
+ if color_def in _STYLE_STD_COLORS:
+ color_num = _color_from_num(_STYLE_STD_COLORS[color_def])
+ else:
+ try:
+ color_num = _color_from_num(int(color_def, 0))
+ except ValueError:
+ _warn("Ignoring color", color_def, "that's neither "
+ "predefined nor a number")
+ return -1
if not -1 <= color_num < curses.COLORS:
_warn("Ignoring color {}, which is outside the range "
"-1..curses.COLORS-1 (-1..{})"
.format(color_def, curses.COLORS - 1))
-
return -1
return color_num