bugfix terminal compiles for windows again

This commit is contained in:
Araq
2011-02-07 00:04:31 +01:00
parent 783273032f
commit 77d045b3ac

View File

@@ -22,7 +22,7 @@ when defined(windows):
# = createFile("CONOUT$", GENERIC_WRITE, 0, nil, OPEN_ALWAYS, 0, 0)
block:
var hTemp = GetStdHandle(STD_OUTPUT_HANDLE())
var hTemp = GetStdHandle(STD_OUTPUT_HANDLE)
if DuplicateHandle(GetCurrentProcess(), hTemp, GetCurrentProcess(),
addr(conHandle), 0, 1, DUPLICATE_SAME_ACCESS) == 0:
OSError()
@@ -54,9 +54,9 @@ proc setCursorPos*(x, y: int) =
if SetConsoleCursorPosition(conHandle, c) == 0: OSError()
else:
stdout.write("\e[" & $y & ';' & $x & 'f')
proc setCursorXPos*(x: int) =
## sets the terminal's cursor to the x position. The y position is
## sets the terminal's cursor to the x position. The y position is
## not changed.
when defined(windows):
var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO
@@ -64,13 +64,13 @@ proc setCursorXPos*(x: int) =
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()
var origin = scrbuf.dwCursorPosition
origin.x = int16(x)
if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
else:
stdout.write("\e[" & $x & 'G')
when defined(windows):
when defined(windows):
proc setCursorYPos*(y: int) =
## sets the terminal's cursor to the y position. The x position is
## sets the terminal's cursor to the y position. The x position is
## not changed. **Warning**: This is not supported on UNIX!
when defined(windows):
var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO
@@ -78,7 +78,7 @@ when defined(windows):
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()
var origin = scrbuf.dwCursorPosition
origin.y = int16(y)
if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
else:
nil
@@ -168,7 +168,7 @@ proc EraseLine* =
scrbuf.dwCursorPosition, addr(numwrote)) == 0:
OSError()
else:
stdout.write("\e[2K")
stdout.write("\e[2K")
setCursorXPos(0)
proc EraseScreen* =