##// END OF EJS Templates
color: handle non-standard stdout on win32
Patrick Mezard -
r10989:9fb09fc3 default
parent child Browse files
Show More
@@ -217,7 +217,7 b" commands.globalopts.append(('', 'color',"
217 _("when to colorize (always, auto, or never)")))
217 _("when to colorize (always, auto, or never)")))
218
218
219 try:
219 try:
220 import re
220 import re, pywintypes
221 from win32console import *
221 from win32console import *
222
222
223 # http://msdn.microsoft.com/en-us/library/ms682088%28VS.85%29.aspx
223 # http://msdn.microsoft.com/en-us/library/ms682088%28VS.85%29.aspx
@@ -243,7 +243,13 b' try:'
243 }
243 }
244
244
245 stdout = GetStdHandle(STD_OUTPUT_HANDLE)
245 stdout = GetStdHandle(STD_OUTPUT_HANDLE)
246 origattr = stdout.GetConsoleScreenBufferInfo()['Attributes']
246 try:
247 origattr = stdout.GetConsoleScreenBufferInfo()['Attributes']
248 except pywintypes.error:
249 # stdout may be defined but not support
250 # GetConsoleScreenBufferInfo(), when called from subprocess or
251 # redirected.
252 raise ImportError()
247 ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)', re.MULTILINE | re.DOTALL)
253 ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)', re.MULTILINE | re.DOTALL)
248
254
249 def win32print(text, orig, **opts):
255 def win32print(text, orig, **opts):
General Comments 0
You need to be logged in to leave comments. Login now