Minor update to terminal docs (#19056)

* Update terminal.nim

- Added some extra docs to cursorUp/Down/Forward/Backward
- I was able to use hideCursor and showCursor without adding stdout, removed the parameter
- Added docs to terminalHeight()* and terminalWidth()*

* Update lib/pure/terminal.nim

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* Update lib/pure/terminal.nim

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

* Added back f: file to cursor movement

* Removed unnecessary comments

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
This commit is contained in:
Netsu
2021-10-26 21:42:22 +02:00
committed by GitHub
parent dde556665a
commit f50bcf82c3

View File

@@ -170,6 +170,7 @@ when defined(windows):
return 0
proc terminalWidth*(): int =
## Returns the terminal width in columns.
var w: int = 0
w = terminalWidthIoctl([getStdHandle(STD_INPUT_HANDLE),
getStdHandle(STD_OUTPUT_HANDLE),
@@ -178,6 +179,7 @@ when defined(windows):
return 80
proc terminalHeight*(): int =
## Returns the terminal height in rows.
var h: int = 0
h = terminalHeightIoctl([getStdHandle(STD_INPUT_HANDLE),
getStdHandle(STD_OUTPUT_HANDLE),
@@ -389,6 +391,9 @@ when defined(windows):
proc cursorUp*(f: File, count = 1) =
## Moves the cursor up by `count` rows.
runnableExamples("-r:off"):
stdout.cursorUp(2)
write(stdout, "Hello World!") # anything written at that location will be erased/replaced with this
when defined(windows):
let h = conHandle(f)
var p = getCursorPos(h)
@@ -399,6 +404,9 @@ proc cursorUp*(f: File, count = 1) =
proc cursorDown*(f: File, count = 1) =
## Moves the cursor down by `count` rows.
runnableExamples("-r:off"):
stdout.cursorDown(2)
write(stdout, "Hello World!") # anything written at that location will be erased/replaced with this
when defined(windows):
let h = conHandle(f)
var p = getCursorPos(h)
@@ -409,6 +417,9 @@ proc cursorDown*(f: File, count = 1) =
proc cursorForward*(f: File, count = 1) =
## Moves the cursor forward by `count` columns.
runnableExamples("-r:off"):
stdout.cursorForward(2)
write(stdout, "Hello World!") # anything written at that location will be erased/replaced with this
when defined(windows):
let h = conHandle(f)
var p = getCursorPos(h)
@@ -419,6 +430,9 @@ proc cursorForward*(f: File, count = 1) =
proc cursorBackward*(f: File, count = 1) =
## Moves the cursor backward by `count` columns.
runnableExamples("-r:off"):
stdout.cursorBackward(2)
write(stdout, "Hello World!") # anything written at that location will be erased/replaced with this
when defined(windows):
let h = conHandle(f)
var p = getCursorPos(h)