25 lines
928 B
Plaintext
25 lines
928 B
Plaintext
#!/usr/bin/env nomsu -V7.0.0
|
|
### A progress bar
|
|
use "consolecolor"
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
test:
|
|
assume (0 / 1 progress bar)
|
|
assume (10 wide 0.5 progress bar)
|
|
|
|
external:
|
|
($x / $w progress bar) means:
|
|
$x = ($x clamped between 0 and $w)
|
|
if $(COLOR ENABLED):
|
|
$bits = [" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"]
|
|
$middle = ("" if ($x == $w) else $bits.(1 + (floor (#$bits * ($x mod 1)))))
|
|
return ("
|
|
\(reset color)[\(green)\($bits, last, rep (floor $x))\($middle)\
|
|
..\(" ", rep ($w - ((floor $x) + 1)))\(reset color)]
|
|
")
|
|
..else:
|
|
### Probably not unicode support either:
|
|
return "[\("#", rep ($x, rounded down))\("-", rep ($w - ($x, rounded down)))]"
|
|
|
|
($w wide $ progress bar) means (($ * $w) / $w progress bar) |