diff options
author | Juan Carlos <juancarlospaco@gmail.com> | 2021-08-14 21:51:41 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-14 20:51:41 -0400 |
commit | b3e077863aa6985eebab0c37785ba127b3192c80 (patch) | |
tree | 178306952460cf69b70e056ddce3f5232be09be2 | |
parent | 52cc0a82cad856fa58ebbb16a9e7ad8c7012e8cf (diff) | |
download | Nim-b3e077863aa6985eebab0c37785ba127b3192c80.tar.gz |
Documentation only, Terminal (#18696)
Add simple progress bar example to terminal module
-rw-r--r-- | lib/pure/terminal.nim | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim index ce5660557..25b1a4cdd 100644 --- a/lib/pure/terminal.nim +++ b/lib/pure/terminal.nim @@ -15,6 +15,21 @@ ## code `exitprocs.addExitProc(resetAttributes)` to restore the defaults. ## Similarly, if you hide the cursor, make sure to unhide it with ## `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 @@ -43,7 +58,6 @@ runnableExamples("-r:off"): stdout.styledWriteLine(fgRed, "red text ", styleBright, "bold red", fgDefault, " bold text") - import macros import strformat from strutils import toLowerAscii, `%` |