updated terminal.nim

This commit is contained in:
Araq 2014-08-29 01:02:04 +02:00
commit 28c3de7d3e

View file

@ -33,7 +33,7 @@ when defined(windows):
var c: TCONSOLESCREENBUFFERINFO var c: TCONSOLESCREENBUFFERINFO
if GetConsoleScreenBufferInfo(conHandle, addr(c)) == 0: if GetConsoleScreenBufferInfo(conHandle, addr(c)) == 0:
raiseOSError(osLastError()) raiseOSError(osLastError())
return (int(c.dwCursorPosition.x), int(c.dwCursorPosition.y)) return (int(c.dwCursorPosition.X), int(c.dwCursorPosition.Y))
proc getAttributes(): int16 = proc getAttributes(): int16 =
var c: TCONSOLESCREENBUFFERINFO var c: TCONSOLESCREENBUFFERINFO
@ -50,8 +50,8 @@ proc setCursorPos*(x, y: int) =
## upper left of the screen. ## upper left of the screen.
when defined(windows): when defined(windows):
var c: TCOORD var c: TCOORD
c.x = int16(x) c.X = int16(x)
c.y = int16(y) c.Y = int16(y)
if SetConsoleCursorPosition(conHandle, c) == 0: raiseOSError(osLastError()) if SetConsoleCursorPosition(conHandle, c) == 0: raiseOSError(osLastError())
else: else:
stdout.write("\e[" & $y & ';' & $x & 'f') stdout.write("\e[" & $y & ';' & $x & 'f')
@ -65,7 +65,7 @@ proc setCursorXPos*(x: int) =
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0:
raiseOSError(osLastError()) raiseOSError(osLastError())
var origin = scrbuf.dwCursorPosition var origin = scrbuf.dwCursorPosition
origin.x = int16(x) origin.X = int16(x)
if SetConsoleCursorPosition(conHandle, origin) == 0: if SetConsoleCursorPosition(conHandle, origin) == 0:
raiseOSError(osLastError()) raiseOSError(osLastError())
else: else:
@ -81,7 +81,7 @@ when defined(windows):
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0:
raiseOSError(osLastError()) raiseOSError(osLastError())
var origin = scrbuf.dwCursorPosition var origin = scrbuf.dwCursorPosition
origin.y = int16(y) origin.Y = int16(y)
if SetConsoleCursorPosition(conHandle, origin) == 0: if SetConsoleCursorPosition(conHandle, origin) == 0:
raiseOSError(osLastError()) raiseOSError(osLastError())
else: else:
@ -163,7 +163,7 @@ proc eraseLine* =
if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0: if GetConsoleScreenBufferInfo(hStdout, addr(scrbuf)) == 0:
raiseOSError(osLastError()) raiseOSError(osLastError())
var origin = scrbuf.dwCursorPosition var origin = scrbuf.dwCursorPosition
origin.x = 0'i16 origin.X = 0'i16
if SetConsoleCursorPosition(conHandle, origin) == 0: if SetConsoleCursorPosition(conHandle, origin) == 0:
raiseOSError(osLastError()) raiseOSError(osLastError())
var ht = scrbuf.dwSize.Y - origin.Y var ht = scrbuf.dwSize.Y - origin.Y