diff options
author | John Novak <john.novak@otherlevels.com> | 2018-07-17 19:35:26 +1000 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-07-17 11:35:26 +0200 |
commit | 692d1da95d82adc30e0ba650124330f1a098a697 (patch) | |
tree | 8e79f4a8e272ca5efa1122e8c6e4142660122a5c | |
parent | f8723cd1e36ec939cc8e0e5bd4f181ff9ec5e99a (diff) | |
download | Nim-692d1da95d82adc30e0ba650124330f1a098a697.tar.gz |
Fix setCursorPos and setCursorXPos on POSIX (#8310)
-rw-r--r-- | changelog.md | 5 | ||||
-rw-r--r-- | lib/pure/terminal.nim | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/changelog.md b/changelog.md index 681b4b0a4..43b351ef1 100644 --- a/changelog.md +++ b/changelog.md @@ -54,6 +54,11 @@ - The procs ``parseHexInt`` and ``parseOctInt`` now fail on empty strings 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 diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim index 904274ade..2e138b27e 100644 --- a/lib/pure/terminal.nim +++ b/lib/pure/terminal.nim @@ -308,7 +308,7 @@ proc setCursorPos*(f: File, x, y: int) = let h = conHandle(f) setCursorPos(h, x, y) else: - f.write(fmt"{stylePrefix}{y};{x}f") + f.write(fmt"{stylePrefix}{y+1};{x+1}f") proc setCursorXPos*(f: File, x: int) = ## Sets the terminal's cursor to the x position. @@ -323,7 +323,7 @@ proc setCursorXPos*(f: File, x: int) = if setConsoleCursorPosition(h, origin) == 0: raiseOSError(osLastError()) else: - f.write(fmt"{stylePrefix}{x}G") + f.write(fmt"{stylePrefix}{x+1}G") when defined(windows): proc setCursorYPos*(f: File, y: int) = |