diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-06-05 01:19:59 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-06-05 01:19:59 -0700 |
commit | 53cba2a2e649e409f14de9e74951bfbe5dffe438 (patch) | |
tree | 60e04926964a8fc6296867249a7650f8cd6dbecc /share | |
parent | d871095d0b9a707d32501482c6c908cfa18ddf13 (diff) |
Improved webconfig.py's handling of combined term256 and classic colors
Diffstat (limited to 'share')
-rwxr-xr-x | share/tools/web_config/webconfig.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 1acf64a9..5b4050cb 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -37,6 +37,16 @@ def parse_one_color(comp): # Unknown return '' +def better_color(c1, c2): + """ Indicate which color is "better", i.e. prefer term256 colors """ + if not c2: return c1 + if not c1: return c2 + if c1 == 'normal': return c2 + if c2 == 'normal': return c1 + if c2 in named_colors: return c1 + if c1 in named_colors: return c2 + return c1 + def parse_color(color_str): """ A basic function to parse a color string, for example, 'red' '--bold' """ @@ -53,11 +63,10 @@ def parse_color(color_str): underline = True elif comp.startswith('--background='): # Background color - background_color = parse_one_color(comp[len('--background='):]) + background_color = better_color(background_color, parse_one_color(comp[len('--background='):])) else: # Regular color - maybe_color = parse_one_color(comp) - if maybe_color: color = maybe_color + color = better_color(color, parse_one_color(comp)) return [color, background_color, bold, underline] |