Add a reset before and after colorized output
authorKevin Christen <kevin.christen@gmail.com>
Tue, 15 Jul 2008 18:10:37 -0500
changeset 6856 c6890cfc2253
parent 6855 09db2b8236ec
child 6857 e8c2dae47799
child 6858 8f256bf98219
Add a reset before and after colorized output This is how GNU's ls --color works, and it clears up problems in xterm and Windows command prompt windows.
hgext/color.py
--- a/hgext/color.py	Wed Jul 23 20:33:23 2008 -0500
+++ b/hgext/color.py	Tue Jul 15 18:10:37 2008 -0500
@@ -79,11 +79,12 @@
 
 def render_effects(text, *effects):
     'Wrap text in commands to turn on each effect.'
-    start = []
+    start = [ str(_effect_params['none'][0]) ]
     stop = []
     for effect in effects:
         start.append(str(_effect_params[effect][0]))
         stop.append(str(_effect_params[effect][1]))
+    stop.append(str(_effect_params['none'][1]))
     start = '\033[' + ';'.join(start) + 'm'
     stop = '\033[' + ';'.join(stop) + 'm'
     return start + text + stop