bugfix terminal compiles for windows again
This commit is contained in:
parent
783273032f
commit
77d045b3ac
1 changed files with 9 additions and 9 deletions
|
|
@ -22,7 +22,7 @@ when defined(windows):
|
||||||
# = createFile("CONOUT$", GENERIC_WRITE, 0, nil, OPEN_ALWAYS, 0, 0)
|
# = createFile("CONOUT$", GENERIC_WRITE, 0, nil, OPEN_ALWAYS, 0, 0)
|
||||||
|
|
||||||
block:
|
block:
|
||||||
var hTemp = GetStdHandle(STD_OUTPUT_HANDLE())
|
var hTemp = GetStdHandle(STD_OUTPUT_HANDLE)
|
||||||
if DuplicateHandle(GetCurrentProcess(), hTemp, GetCurrentProcess(),
|
if DuplicateHandle(GetCurrentProcess(), hTemp, GetCurrentProcess(),
|
||||||
addr(conHandle), 0, 1, DUPLICATE_SAME_ACCESS) == 0:
|
addr(conHandle), 0, 1, DUPLICATE_SAME_ACCESS) == 0:
|
||||||
OSError()
|
OSError()
|
||||||
|
|
@ -54,9 +54,9 @@ proc setCursorPos*(x, y: int) =
|
||||||
if SetConsoleCursorPosition(conHandle, c) == 0: OSError()
|
if SetConsoleCursorPosition(conHandle, c) == 0: OSError()
|
||||||
else:
|
else:
|
||||||
stdout.write("\e[" & $y & ';' & $x & 'f')
|
stdout.write("\e[" & $y & ';' & $x & 'f')
|
||||||
|
|
||||||
proc setCursorXPos*(x: int) =
|
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.
|
## not changed.
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO
|
var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO
|
||||||
|
|
@ -64,13 +64,13 @@ proc setCursorXPos*(x: int) =
|
||||||
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()
|
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()
|
||||||
var origin = scrbuf.dwCursorPosition
|
var origin = scrbuf.dwCursorPosition
|
||||||
origin.x = int16(x)
|
origin.x = int16(x)
|
||||||
if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
|
if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
|
||||||
else:
|
else:
|
||||||
stdout.write("\e[" & $x & 'G')
|
stdout.write("\e[" & $x & 'G')
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
proc setCursorYPos*(y: int) =
|
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!
|
## not changed. **Warning**: This is not supported on UNIX!
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO
|
var scrbuf: TCONSOLE_SCREEN_BUFFER_INFO
|
||||||
|
|
@ -78,7 +78,7 @@ when defined(windows):
|
||||||
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()
|
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: OSError()
|
||||||
var origin = scrbuf.dwCursorPosition
|
var origin = scrbuf.dwCursorPosition
|
||||||
origin.y = int16(y)
|
origin.y = int16(y)
|
||||||
if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
|
if SetConsoleCursorPosition(conHandle, origin) == 0: OSError()
|
||||||
else:
|
else:
|
||||||
nil
|
nil
|
||||||
|
|
||||||
|
|
@ -168,7 +168,7 @@ proc EraseLine* =
|
||||||
scrbuf.dwCursorPosition, addr(numwrote)) == 0:
|
scrbuf.dwCursorPosition, addr(numwrote)) == 0:
|
||||||
OSError()
|
OSError()
|
||||||
else:
|
else:
|
||||||
stdout.write("\e[2K")
|
stdout.write("\e[2K")
|
||||||
setCursorXPos(0)
|
setCursorXPos(0)
|
||||||
|
|
||||||
proc EraseScreen* =
|
proc EraseScreen* =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue