Fix setCursorPos and setCursorXPos on POSIX (#8310)
This commit is contained in:
parent
f8723cd1e3
commit
692d1da95d
2 changed files with 7 additions and 2 deletions
|
|
@ -54,6 +54,11 @@
|
||||||
- The procs ``parseHexInt`` and ``parseOctInt`` now fail on empty strings
|
- The procs ``parseHexInt`` and ``parseOctInt`` now fail on empty strings
|
||||||
and strings containing only valid prefixes, e.g. "0x" for hex integers.
|
and strings containing only valid prefixes, e.g. "0x" for hex integers.
|
||||||
|
|
||||||
|
- ``terminal.setCursorPos`` and ``terminal.setCursorXPos`` now work correctly
|
||||||
|
with 0-based coordinates on POSIX (previously, you needed to use
|
||||||
|
1-based coordinates on POSIX for correct behaviour; the Windows behaviour
|
||||||
|
was always correct).
|
||||||
|
|
||||||
|
|
||||||
#### Breaking changes in the compiler
|
#### Breaking changes in the compiler
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -308,7 +308,7 @@ proc setCursorPos*(f: File, x, y: int) =
|
||||||
let h = conHandle(f)
|
let h = conHandle(f)
|
||||||
setCursorPos(h, x, y)
|
setCursorPos(h, x, y)
|
||||||
else:
|
else:
|
||||||
f.write(fmt"{stylePrefix}{y};{x}f")
|
f.write(fmt"{stylePrefix}{y+1};{x+1}f")
|
||||||
|
|
||||||
proc setCursorXPos*(f: File, x: int) =
|
proc setCursorXPos*(f: File, x: int) =
|
||||||
## Sets the terminal's cursor to the x position.
|
## Sets the terminal's cursor to the x position.
|
||||||
|
|
@ -323,7 +323,7 @@ proc setCursorXPos*(f: File, x: int) =
|
||||||
if setConsoleCursorPosition(h, origin) == 0:
|
if setConsoleCursorPosition(h, origin) == 0:
|
||||||
raiseOSError(osLastError())
|
raiseOSError(osLastError())
|
||||||
else:
|
else:
|
||||||
f.write(fmt"{stylePrefix}{x}G")
|
f.write(fmt"{stylePrefix}{x+1}G")
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
proc setCursorYPos*(f: File, y: int) =
|
proc setCursorYPos*(f: File, y: int) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue