hgext/color.py
changeset 10827 b66388f6adfa
parent 10826 717c35d55fb3
child 10831 441f5d66da03
equal deleted inserted replaced
10826:717c35d55fb3 10827:b66388f6adfa
   108     if not text:
   108     if not text:
   109         return text
   109         return text
   110     start = [str(_effects[e]) for e in ['none'] + effects.split()]
   110     start = [str(_effects[e]) for e in ['none'] + effects.split()]
   111     start = '\033[' + ';'.join(start) + 'm'
   111     start = '\033[' + ';'.join(start) + 'm'
   112     stop = '\033[' + str(_effects['none']) + 'm'
   112     stop = '\033[' + str(_effects['none']) + 'm'
   113     if text[-1] == '\n':
   113     return ''.join([start, text, stop])
   114         return ''.join([start, text[:-1], stop, '\n'])
       
   115     else:
       
   116         return ''.join([start, text, stop])
       
   117 
   114 
   118 def extstyles():
   115 def extstyles():
   119     for name, ext in extensions.extensions():
   116     for name, ext in extensions.extensions():
   120         _styles.update(getattr(ext, 'colortable', {}))
   117         _styles.update(getattr(ext, 'colortable', {}))
   121 
   118 
   139 def style(msg, label):
   136 def style(msg, label):
   140     effects = ''
   137     effects = ''
   141     for l in label.split():
   138     for l in label.split():
   142         effects += _styles.get(l, '')
   139         effects += _styles.get(l, '')
   143     if effects:
   140     if effects:
   144         return render_effects(msg, effects)
   141         return '\n'.join([render_effects(s, effects)
       
   142                           for s in msg.split('\n')])
   145     return msg
   143     return msg
   146 
   144 
   147 def popbuffer(orig, labeled=False):
   145 def popbuffer(orig, labeled=False):
   148     global _buffers
   146     global _buffers
   149     if labeled:
   147     if labeled: