##// END OF EJS Templates
color: add ui to effect rendering...
Pierre-Yves David -
r31112:7f056fdb default
parent child Browse files
Show More
@@ -260,7 +260,7 b' def configstyles(ui):'
260 if cfgeffects:
260 if cfgeffects:
261 good = []
261 good = []
262 for e in cfgeffects:
262 for e in cfgeffects:
263 if valideffect(e):
263 if valideffect(ui, e):
264 good.append(e)
264 good.append(e)
265 else:
265 else:
266 ui.warn(_("ignoring unknown color/effect %r "
266 ui.warn(_("ignoring unknown color/effect %r "
@@ -268,13 +268,13 b' def configstyles(ui):'
268 % (e, status))
268 % (e, status))
269 _styles[status] = ' '.join(good)
269 _styles[status] = ' '.join(good)
270
270
271 def valideffect(effect):
271 def valideffect(ui, effect):
272 'Determine if the effect is valid or not.'
272 'Determine if the effect is valid or not.'
273 return ((not _terminfo_params and effect in _effects)
273 return ((not _terminfo_params and effect in _effects)
274 or (effect in _terminfo_params
274 or (effect in _terminfo_params
275 or effect[:-11] in _terminfo_params))
275 or effect[:-11] in _terminfo_params))
276
276
277 def _effect_str(effect):
277 def _effect_str(ui, effect):
278 '''Helper function for render_effects().'''
278 '''Helper function for render_effects().'''
279
279
280 bg = False
280 bg = False
@@ -295,14 +295,14 b' def _effect_str(effect):'
295 else:
295 else:
296 return curses.tparm(curses.tigetstr('setaf'), val)
296 return curses.tparm(curses.tigetstr('setaf'), val)
297
297
298 def _render_effects(text, effects):
298 def _render_effects(ui, text, effects):
299 'Wrap text in commands to turn on each effect.'
299 'Wrap text in commands to turn on each effect.'
300 if not text:
300 if not text:
301 return text
301 return text
302 if _terminfo_params:
302 if _terminfo_params:
303 start = ''.join(_effect_str(effect)
303 start = ''.join(_effect_str(ui, effect)
304 for effect in ['none'] + effects.split())
304 for effect in ['none'] + effects.split())
305 stop = _effect_str('none')
305 stop = _effect_str(ui, 'none')
306 else:
306 else:
307 start = [str(_effects[e]) for e in ['none'] + effects.split()]
307 start = [str(_effects[e]) for e in ['none'] + effects.split()]
308 start = '\033[' + ';'.join(start) + 'm'
308 start = '\033[' + ';'.join(start) + 'm'
@@ -323,11 +323,11 b' def colorlabel(ui, msg, label):'
323 s = _styles.get(l, '')
323 s = _styles.get(l, '')
324 if s:
324 if s:
325 effects.append(s)
325 effects.append(s)
326 elif valideffect(l):
326 elif valideffect(ui, l):
327 effects.append(l)
327 effects.append(l)
328 effects = ' '.join(effects)
328 effects = ' '.join(effects)
329 if effects:
329 if effects:
330 msg = '\n'.join([_render_effects(line, effects)
330 msg = '\n'.join([_render_effects(ui, line, effects)
331 for line in msg.split('\n')])
331 for line in msg.split('\n')])
332 return msg
332 return msg
333
333
General Comments 0
You need to be logged in to leave comments. Login now