Revert "it turns out that writeconsole in ansiterm.py is not needed"

This reverts commit 3deaeb241a.

Signed-off-by: Thomas Nagy <tnagy2pow10@gmail.com>
This commit is contained in:
Thomas Nagy 2014-03-14 21:47:19 +01:00
parent 0cd060c394
commit 9f7e6a1bfb
No known key found for this signature in database
GPG Key ID: 67A565EDFDF90E64
1 changed files with 25 additions and 7 deletions

View File

@ -82,11 +82,7 @@ else:
class AnsiTerm(object):
"""
Wrapper for cmd.exe stdio, to support vt100 escape codes
Notes:
- CR printed when the cursor is at EOL will do nothing,
whereas on UNIX, it will go to the line beginning.
emulate a vt100 terminal in cmd.exe
"""
def __init__(self, s):
self.stream = s
@ -271,7 +267,7 @@ else:
if cmd_func:
cmd_func(self, param)
else:
self.stream.write(txt)
self.writeconsole(txt)
else:
# no support for colors in the console, just output the text:
# eclipse or msys may be able to interpret the escape sequences
@ -279,11 +275,33 @@ else:
finally:
wlock.release()
def writeconsole(self, txt):
chars_written = c_int()
writeconsole = windll.kernel32.WriteConsoleA
if isinstance(txt, _type):
writeconsole = windll.kernel32.WriteConsoleW
# MSDN says that there is a shared buffer of 64 KB for the console
# writes. Attempt to not get ERROR_NOT_ENOUGH_MEMORY, see waf issue #746
done = 0
todo = len(txt)
chunk = 32<<10
while todo != 0:
doing = min(chunk, todo)
buf = txt[done:done+doing]
r = writeconsole(self.hconsole, buf, doing, byref(chars_written), None)
if r == 0:
chunk >>= 1
continue
done += doing
todo -= doing
def fileno(self):
return self.stream.fileno()
def flush(self):
return self.stream.flush()
pass
def isatty(self):
return self._isatty