Documentation only, Terminal (#18696)
Add simple progress bar example to terminal module
This commit is contained in:
parent
52cc0a82ca
commit
b3e077863a
1 changed files with 15 additions and 1 deletions
|
|
@ -15,6 +15,21 @@
|
||||||
## code `exitprocs.addExitProc(resetAttributes)` to restore the defaults.
|
## code `exitprocs.addExitProc(resetAttributes)` to restore the defaults.
|
||||||
## Similarly, if you hide the cursor, make sure to unhide it with
|
## Similarly, if you hide the cursor, make sure to unhide it with
|
||||||
## `showCursor` before quitting.
|
## `showCursor` before quitting.
|
||||||
|
##
|
||||||
|
## Progress bar
|
||||||
|
## ============
|
||||||
|
##
|
||||||
|
## Basic progress bar example:
|
||||||
|
runnableExamples("-r:off"):
|
||||||
|
import std/[os, strutils]
|
||||||
|
|
||||||
|
for i in 0..100:
|
||||||
|
stdout.styledWriteLine(fgRed, "0% ", fgWhite, '#'.repeat i, if i > 50: fgGreen else: fgYellow, "\t", $i , "%")
|
||||||
|
sleep 42
|
||||||
|
cursorUp 1
|
||||||
|
eraseLine()
|
||||||
|
|
||||||
|
stdout.resetAttributes()
|
||||||
|
|
||||||
##[
|
##[
|
||||||
## Playing with colorful and styled text
|
## Playing with colorful and styled text
|
||||||
|
|
@ -43,7 +58,6 @@ runnableExamples("-r:off"):
|
||||||
|
|
||||||
stdout.styledWriteLine(fgRed, "red text ", styleBright, "bold red", fgDefault, " bold text")
|
stdout.styledWriteLine(fgRed, "red text ", styleBright, "bold red", fgDefault, " bold text")
|
||||||
|
|
||||||
|
|
||||||
import macros
|
import macros
|
||||||
import strformat
|
import strformat
|
||||||
from strutils import toLowerAscii, `%`
|
from strutils import toLowerAscii, `%`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue