mirror of https://gitlab.com/ita1024/waf.git
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:
parent
0cd060c394
commit
9f7e6a1bfb
|
@ -82,11 +82,7 @@ else:
|
||||||
|
|
||||||
class AnsiTerm(object):
|
class AnsiTerm(object):
|
||||||
"""
|
"""
|
||||||
Wrapper for cmd.exe stdio, to support vt100 escape codes
|
emulate a vt100 terminal in cmd.exe
|
||||||
|
|
||||||
Notes:
|
|
||||||
- CR printed when the cursor is at EOL will do nothing,
|
|
||||||
whereas on UNIX, it will go to the line beginning.
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, s):
|
def __init__(self, s):
|
||||||
self.stream = s
|
self.stream = s
|
||||||
|
@ -271,7 +267,7 @@ else:
|
||||||
if cmd_func:
|
if cmd_func:
|
||||||
cmd_func(self, param)
|
cmd_func(self, param)
|
||||||
else:
|
else:
|
||||||
self.stream.write(txt)
|
self.writeconsole(txt)
|
||||||
else:
|
else:
|
||||||
# no support for colors in the console, just output the text:
|
# no support for colors in the console, just output the text:
|
||||||
# eclipse or msys may be able to interpret the escape sequences
|
# eclipse or msys may be able to interpret the escape sequences
|
||||||
|
@ -279,11 +275,33 @@ else:
|
||||||
finally:
|
finally:
|
||||||
wlock.release()
|
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):
|
def fileno(self):
|
||||||
return self.stream.fileno()
|
return self.stream.fileno()
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
return self.stream.flush()
|
pass
|
||||||
|
|
||||||
def isatty(self):
|
def isatty(self):
|
||||||
return self._isatty
|
return self._isatty
|
||||||
|
|
Loading…
Reference in New Issue