summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/color.py23
-rw-r--r--lib/spack/spack/tty.py6
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 @@ Here are some example color expressions:
@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 @@ class ColorParseError(spack.error.SpackError):
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 @@ class match_to_ansi(object):
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 @@ from spack.color import *
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):