##// END OF EJS Templates
color: extract the label code into its own function...
Pierre-Yves David -
r31085:3422de9b default
parent child Browse files
Show More
@@ -331,16 +331,17 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)
334 335
335 if self._colormode == 'debug':
336 def colorlabel(ui, msg, label):
337 """add color control code according to the mode"""
338 if ui._colormode == 'debug':
336 339 if label and msg:
337 340 if msg[-1] == '\n':
338 return "[%s|%s]\n" % (label, msg[:-1])
341 msg = "[%s|%s]\n" % (label, msg[:-1])
339 342 else:
340 return "[%s|%s]" % (label, msg)
341 else:
342 return msg
343
343 msg = "[%s|%s]" % (label, msg)
344 elif ui._colormode is not None:
344 345 effects = []
345 346 for l in label.split():
346 347 s = color._styles.get(l, '')
@@ -350,7 +351,7 class colorui(uimod.ui):
350 351 effects.append(l)
351 352 effects = ' '.join(effects)
352 353 if effects:
353 return '\n'.join([color._render_effects(line, effects)
354 msg = '\n'.join([color._render_effects(line, effects)
354 355 for line in msg.split('\n')])
355 356 return msg
356 357
General Comments 0
You need to be logged in to leave comments. Login now