Show More
@@ -331,29 +331,7 b' class colorui(uimod.ui):' | |||
|
331 | 331 | def label(self, msg, label): |
|
332 | 332 | if self._colormode is None: |
|
333 | 333 | return super(colorui, self).label(msg, label) |
|
334 | return colorlabel(self, msg, label) | |
|
335 | ||
|
336 | def colorlabel(ui, msg, label): | |
|
337 | """add color control code according to the mode""" | |
|
338 | if ui._colormode == 'debug': | |
|
339 | if label and msg: | |
|
340 | if msg[-1] == '\n': | |
|
341 | msg = "[%s|%s]\n" % (label, msg[:-1]) | |
|
342 | else: | |
|
343 | msg = "[%s|%s]" % (label, msg) | |
|
344 | elif ui._colormode is not None: | |
|
345 | effects = [] | |
|
346 | for l in label.split(): | |
|
347 | s = color._styles.get(l, '') | |
|
348 | if s: | |
|
349 | effects.append(s) | |
|
350 | elif color.valideffect(l): | |
|
351 | effects.append(l) | |
|
352 | effects = ' '.join(effects) | |
|
353 | if effects: | |
|
354 | msg = '\n'.join([color._render_effects(line, effects) | |
|
355 | for line in msg.split('\n')]) | |
|
356 | return msg | |
|
334 | return color.colorlabel(self, msg, label) | |
|
357 | 335 | |
|
358 | 336 | def uisetup(ui): |
|
359 | 337 | if ui.plain(): |
@@ -175,6 +175,28 b' def _render_effects(text, effects):' | |||
|
175 | 175 | stop = '\033[' + str(_effects['none']) + 'm' |
|
176 | 176 | return ''.join([start, text, stop]) |
|
177 | 177 | |
|
178 | def colorlabel(ui, msg, label): | |
|
179 | """add color control code according to the mode""" | |
|
180 | if ui._colormode == 'debug': | |
|
181 | if label and msg: | |
|
182 | if msg[-1] == '\n': | |
|
183 | msg = "[%s|%s]\n" % (label, msg[:-1]) | |
|
184 | else: | |
|
185 | msg = "[%s|%s]" % (label, msg) | |
|
186 | elif ui._colormode is not None: | |
|
187 | effects = [] | |
|
188 | for l in label.split(): | |
|
189 | s = _styles.get(l, '') | |
|
190 | if s: | |
|
191 | effects.append(s) | |
|
192 | elif valideffect(l): | |
|
193 | effects.append(l) | |
|
194 | effects = ' '.join(effects) | |
|
195 | if effects: | |
|
196 | msg = '\n'.join([_render_effects(line, effects) | |
|
197 | for line in msg.split('\n')]) | |
|
198 | return msg | |
|
199 | ||
|
178 | 200 | w32effects = None |
|
179 | 201 | if pycompat.osname == 'nt': |
|
180 | 202 | import ctypes |
General Comments 0
You need to be logged in to leave comments.
Login now