##// 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 if label and msg:
337 if msg[-1] == '\n':
338 return "[%s|%s]\n" % (label, msg[:-1])
339 else:
340 return "[%s|%s]" % (label, msg)
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])
341 342 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,9 +351,9 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 for line in msg.split('\n')])
355 return msg
354 msg = '\n'.join([color._render_effects(line, effects)
355 for line in msg.split('\n')])
356 return msg
356 357
357 358 def uisetup(ui):
358 359 if ui.plain():
General Comments 0
You need to be logged in to leave comments. Login now