From 73774c1249fb22f28b28346bd9ca5819104ce4c6 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Thu, 6 Feb 2014 16:58:23 -0800 Subject: [PATCH] Spack message text is just bold, not bold white now. - added capability for just bold and just underline to color.py - Make tty.msg() display bold text instead of bold white --- lib/spack/spack/color.py | 23 ++++++++++++++--------- lib/spack/spack/tty.py | 6 +++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/spack/spack/color.py b/lib/spack/spack/color.py index 8d6a1d0218..9d75824aa8 100644 --- a/lib/spack/spack/color.py +++ b/lib/spack/spack/color.py @@ -42,6 +42,8 @@ @r Turn on red coloring @R Turn on bright red coloring + @*{foo} Bold foo, but don't change text color + @_{bar} Underline bar, but don't change text color @*b Turn on bold, blue text @_B Turn on bright blue text with an underline @. Revert to plain formatting @@ -80,9 +82,9 @@ def __init__(self, message): super(ColorParseError, self).__init__(message) # Text styles for ansi codes -styles = {'*' : '1;%s', # bold - '_' : '4:%s', # underline - None : '0;%s' } # plain +styles = {'*' : '1', # bold + '_' : '4', # underline + None : '0' } # plain # Dim and bright ansi colors colors = {'k' : 30, 'K' : 90, # black @@ -120,19 +122,22 @@ def __call__(self, match): return '@' elif m == '@.': return self.escape(0) - elif m == '@' or (style and not color): + elif m == '@': raise ColorParseError("Incomplete color format: '%s' in %s" % (m, match.string)) - elif color not in colors: - raise ColorParseError("invalid color specifier: '%s' in '%s'" - % (color, match.string)) + + string = styles[style] + if color: + if color not in colors: + raise ColorParseError("invalid color specifier: '%s' in '%s'" + % (color, match.string)) + string += ';' + str(colors[color]) colored_text = '' if text: colored_text = text + self.escape(0) - color_code = self.escape(styles[style] % colors[color]) - return color_code + colored_text + return self.escape(string) + colored_text def colorize(string, **kwargs): diff --git a/lib/spack/spack/tty.py b/lib/spack/spack/tty.py index 02cd0364f6..5a2ba92275 100644 --- a/lib/spack/spack/tty.py +++ b/lib/spack/spack/tty.py @@ -29,7 +29,7 @@ indent = " " def msg(message, *args): - cprint("@*b{==>} @*w{%s}" % cescape(message)) + cprint("@*b{==>} @*{%s}" % cescape(message)) for arg in args: print indent + str(arg) @@ -43,12 +43,12 @@ def info(message, *args, **kwargs): def verbose(message, *args): if spack.verbose: - info(message, *args, format='*g') + info(message, *args, format='c') def debug(*args): if spack.debug: - info("Debug: " + message, *args, format='*c') + info("Debug: " + message, *args, format='*g') def error(message, *args):