code / nomsu

Lines6.6K Lua5.1K PEG1.3K make117
2 others 83
Markdown60 Bourne Again Shell23
(29 lines)
1 #!/usr/bin/env nomsu -V7.0.0
2 ###
3 This file defines actions for ANSI console color escape codes.
5 test:
6 $ = (bright "\(green)Color test passed.")
8 $colors = {
9 .normal = 0, ."reset color" = 0, .bright = 1, .bold = 1, .dim = 2, .italic = 3
10 .underscore = 4, ."slow blink" = 5, ."fast blink" = 6, .reverse = 7, .inverse = 7
11 .inverted = 7, .hidden = 8
13 ### There's some other codes, but they're not currently implemented
14 .black = 30, .red = 31, .green = 32, .yellow = 33, .blue = 34, .magenta = 35
15 .cyan = 36, .white = 37, ."on black" = 40, ."on red" = 41, ."on green" = 42
16 ."on yellow" = 43, ."on blue" = 44, ."on magenta" = 45, ."on cyan" = 46
17 ."on white" = 47
20 for ($name = $colornum) in $colors:
21 (nomsu environment).($name, as lua id) =
22 for $text:
23 if $(COLOR ENABLED):
24 if $text:
25 return "\027[\($colornum)m\($text)\027[0m"
26 ..else:
27 return "\027[\($colornum)m"
28 ..else:
29 return ($text or "")