code / nomsu

Lines6.6K Lua5.1K PEG1.3K make117
2 others 83
Markdown60 Bourne Again Shell23
(25 lines)
1 #!/usr/bin/env nomsu -V7.0.0
2 ### A progress bar
3 use "consolecolor"
5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 test:
8 assume (0 / 1 progress bar)
9 assume (10 wide 0.5 progress bar)
11 external:
12 ($x / $w progress bar) means:
13 $x = ($x clamped between 0 and $w)
14 if $(COLOR ENABLED):
15 $bits = [" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"]
16 $middle = ("" if ($x == $w) else $bits.(1 + (floor (#$bits * ($x mod 1)))))
17 return ("
18 \(reset color)[\(green)\($bits, last, rep (floor $x))\($middle)\
19 ..\(" ", rep ($w - ((floor $x) + 1)))\(reset color)]
20 ")
21 ..else:
22 ### Probably not unicode support either:
23 return "[\("#", rep ($x, rounded down))\("-", rep ($w - ($x, rounded down)))]"
25 ($w wide $ progress bar) means (($ * $w) / $w progress bar)