changeset 10827:b66388f6adfa

color: don't split colors across lines (which confuses less -R) Currently, less -R doesn't support colors spanning multiple lines; only the first line will be colorized. Instead of allowing colors to span multiple lines, the color extension now applies colors to each line it receives, even when ui.write() is given multiple lines in one call.
author Brodie Rao <brodie@bitheap.org>
date Fri, 02 Apr 2010 15:22:19 -0500
parents 717c35d55fb3
children 1aa9464ce9ae
files hgext/color.py tests/test-eolfilename.out
diffstat 2 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/color.py	Fri Apr 02 15:22:17 2010 -0500
+++ b/hgext/color.py	Fri Apr 02 15:22:19 2010 -0500
@@ -110,10 +110,7 @@
     start = [str(_effects[e]) for e in ['none'] + effects.split()]
     start = '\033[' + ';'.join(start) + 'm'
     stop = '\033[' + str(_effects['none']) + 'm'
-    if text[-1] == '\n':
-        return ''.join([start, text[:-1], stop, '\n'])
-    else:
-        return ''.join([start, text, stop])
+    return ''.join([start, text, stop])
 
 def extstyles():
     for name, ext in extensions.extensions():
@@ -141,7 +138,8 @@
     for l in label.split():
         effects += _styles.get(l, '')
     if effects:
-        return render_effects(msg, effects)
+        return '\n'.join([render_effects(s, effects)
+                          for s in msg.split('\n')])
     return msg
 
 def popbuffer(orig, labeled=False):
--- a/tests/test-eolfilename.out	Fri Apr 02 15:22:17 2010 -0500
+++ b/tests/test-eolfilename.out	Fri Apr 02 15:22:19 2010 -0500
@@ -14,7 +14,7 @@
 o  hell
 o
 % test issue2039
-? foo
-bar
-? foo
-bar.baz
+? foo
+bar
+? foo
+bar.baz