diff options
author | Simon Glass | 2012-12-15 04:42:02 -0600 |
---|---|---|
committer | Simon Glass | 2013-04-04 16:04:33 -0500 |
commit | 43bca004d698a2c6f457b32efeaa796e7751a72b (patch) | |
tree | c59e4b3da350ec00c449d5b60b8274772ad7be1a /tools | |
parent | bbd01435b9f3f1f60355b95f157170ec52c6353d (diff) | |
download | u-boot-43bca004d698a2c6f457b32efeaa796e7751a72b.tar.gz u-boot-43bca004d698a2c6f457b32efeaa796e7751a72b.tar.xz u-boot-43bca004d698a2c6f457b32efeaa796e7751a72b.zip |
patman: Use bright ANSI colours by default
Rather than the rather dull colours, use bright versions which normally
look better and are easier to read.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/patman/terminal.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tools/patman/terminal.py b/tools/patman/terminal.py index 8fad06eb55..337a2a43c0 100644 --- a/tools/patman/terminal.py +++ b/tools/patman/terminal.py | |||
@@ -34,7 +34,8 @@ class Color(object): | |||
34 | """Conditionally wraps text in ANSI color escape sequences.""" | 34 | """Conditionally wraps text in ANSI color escape sequences.""" |
35 | BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8) | 35 | BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8) |
36 | BOLD = -1 | 36 | BOLD = -1 |
37 | COLOR_START = '\033[1;%dm' | 37 | BRIGHT_START = '\033[1;%dm' |
38 | NORMAL_START = '\033[22;%dm' | ||
38 | BOLD_START = '\033[1m' | 39 | BOLD_START = '\033[1m' |
39 | RESET = '\033[0m' | 40 | RESET = '\033[0m' |
40 | 41 | ||
@@ -48,7 +49,7 @@ class Color(object): | |||
48 | self._enabled = (colored == COLOR_ALWAYS or | 49 | self._enabled = (colored == COLOR_ALWAYS or |
49 | (colored == COLOR_IF_TERMINAL and os.isatty(sys.stdout.fileno()))) | 50 | (colored == COLOR_IF_TERMINAL and os.isatty(sys.stdout.fileno()))) |
50 | 51 | ||
51 | def Start(self, color): | 52 | def Start(self, color, bright=True): |
52 | """Returns a start color code. | 53 | """Returns a start color code. |
53 | 54 | ||
54 | Args: | 55 | Args: |
@@ -59,7 +60,8 @@ class Color(object): | |||
59 | otherwise returns empty string | 60 | otherwise returns empty string |
60 | """ | 61 | """ |
61 | if self._enabled: | 62 | if self._enabled: |
62 | return self.COLOR_START % (color + 30) | 63 | base = self.BRIGHT_START if bright else self.NORMAL_START |
64 | return base % (color + 30) | ||
63 | return '' | 65 | return '' |
64 | 66 | ||
65 | def Stop(self): | 67 | def Stop(self): |
@@ -70,10 +72,10 @@ class Color(object): | |||
70 | returns empty string | 72 | returns empty string |
71 | """ | 73 | """ |
72 | if self._enabled: | 74 | if self._enabled: |
73 | return self.RESET | 75 | return self.RESET |
74 | return '' | 76 | return '' |
75 | 77 | ||
76 | def Color(self, color, text): | 78 | def Color(self, color, text, bright=True): |
77 | """Returns text with conditionally added color escape sequences. | 79 | """Returns text with conditionally added color escape sequences. |
78 | 80 | ||
79 | Keyword arguments: | 81 | Keyword arguments: |
@@ -85,9 +87,10 @@ class Color(object): | |||
85 | returns text with color escape sequences based on the value of color. | 87 | returns text with color escape sequences based on the value of color. |
86 | """ | 88 | """ |
87 | if not self._enabled: | 89 | if not self._enabled: |
88 | return text | 90 | return text |
89 | if color == self.BOLD: | 91 | if color == self.BOLD: |
90 | start = self.BOLD_START | 92 | start = self.BOLD_START |
91 | else: | 93 | else: |
92 | start = self.COLOR_START % (color + 30) | 94 | base = self.BRIGHT_START if bright else self.NORMAL_START |
95 | start = base % (color + 30) | ||
93 | return start + text + self.RESET | 96 | return start + text + self.RESET |