equal
deleted
inserted
replaced
286 else: |
286 else: |
287 origattr = csbi.wAttributes |
287 origattr = csbi.wAttributes |
288 ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)', |
288 ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)', |
289 re.MULTILINE | re.DOTALL) |
289 re.MULTILINE | re.DOTALL) |
290 |
290 |
291 def win32print(text, orig, **opts): |
291 def win32print(text, writefunc, **opts): |
292 label = opts.get('label', '') |
292 label = opts.get('label', '') |
293 attr = origattr |
293 attr = origattr |
294 |
294 |
295 def mapcolor(val, attr): |
295 def mapcolor(val, attr): |
296 if val == -1: |
296 if val == -1: |
323 while m: |
323 while m: |
324 for sattr in m.group(1).split(';'): |
324 for sattr in m.group(1).split(';'): |
325 if sattr: |
325 if sattr: |
326 attr = mapcolor(int(sattr), attr) |
326 attr = mapcolor(int(sattr), attr) |
327 _kernel32.SetConsoleTextAttribute(stdout, attr) |
327 _kernel32.SetConsoleTextAttribute(stdout, attr) |
328 orig(m.group(2), **opts) |
328 writefunc(m.group(2), **opts) |
329 m = re.match(ansire, m.group(3)) |
329 m = re.match(ansire, m.group(3)) |
330 finally: |
330 finally: |
331 # Explicitly reset original attributes |
331 # Explicitly reset original attributes |
332 _kernel32.SetConsoleTextAttribute(stdout, origattr) |
332 _kernel32.SetConsoleTextAttribute(stdout, origattr) |