diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2019-11-27 00:00:33 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2019-11-27 01:41:44 +0100 |
| commit | 7020b86d437c149ed3582454daeb3aeca1429364 (patch) | |
| tree | e1ed0630e2e704221299ff1e4f2e6bb18633bf66 /menuconfig.py | |
| parent | 4b9de8d901af1f00253c1403bcfd3abed9349def (diff) | |
menuconfig: Ignore MENUCONFIG_STYLE on non-color terminals
Assume that the environment is non-standard/broken on terminals that
don't support color, and that any custom styling applied to the
'monochrome' theme is likely to mess things up (though any colors will
be ignored).
The menuconfig really needs more than two colors to not look ugly
anyway, because of the borderless design.
Diffstat (limited to 'menuconfig.py')
| -rwxr-xr-x | menuconfig.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/menuconfig.py b/menuconfig.py index d7776c8..8ae0cc8 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -137,13 +137,16 @@ If there's an error in the style definition or if a missing style is assigned to, the assignment will be ignored, along with a warning being printed on stderr. -The 'default' theme is always implicitly parsed first (or the 'monochrome' -theme if the terminal lacks colors), so the following two settings have the -same effect: +The 'default' theme is always implicitly parsed first, so the following two +settings have the same effect: MENUCONFIG_STYLE="selection=fg:white,bg:red" MENUCONFIG_STYLE="default selection=fg:white,bg:red" +If the terminal doesn't support colors, the 'monochrome' theme is used, and +MENUCONFIG_STYLE is ignored. The assumption is that the environment is broken +somehow, and that the important thing is to get something usable. + Other features ============== @@ -605,13 +608,16 @@ def _init_styles(): if curses.has_colors(): curses.use_default_colors() - # Use the 'monochrome' style template as the base on terminals without - # color - _parse_style("default" if curses.has_colors() else "monochrome", True) - - # Add any user-defined style from the environment - if "MENUCONFIG_STYLE" in os.environ: - _parse_style(os.environ["MENUCONFIG_STYLE"], False) + # Use the 'default' theme as the base, and add any user-defined style + # settings from the environment + _parse_style("default", True) + if "MENUCONFIG_STYLE" in os.environ: + _parse_style(os.environ["MENUCONFIG_STYLE"], False) + else: + # Force the 'monochrome' theme if the terminal doesn't support colors. + # MENUCONFIG_STYLE is likely to mess things up here (though any colors + # would be ignored), so ignore it. + _parse_style("monochrome", True) # color_attribs holds the color pairs we've already created, indexed by a |
