aboutsummaryrefslogtreecommitdiff
path: root/lib/consolecolor/init.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-14 15:42:48 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-14 15:43:24 -0800
commitc1c32688a4afc43f6addb99b8b5fa878944a70e3 (patch)
treec886f21b5b08a9053aa74fcba4b241dae5ede76d /lib/consolecolor/init.nom
parent2309b696fc34b24f05f6658b94f9105ca8ee76e4 (diff)
Overhaul in progress, mostly working. Moved all the nomsu packages into
lib/, including core/*. Changes to how nomsu environments and importing work.
Diffstat (limited to 'lib/consolecolor/init.nom')
-rw-r--r--lib/consolecolor/init.nom26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/consolecolor/init.nom b/lib/consolecolor/init.nom
new file mode 100644
index 0000000..d1da247
--- /dev/null
+++ b/lib/consolecolor/init.nom
@@ -0,0 +1,26 @@
+#!/usr/bin/env nomsu -V6.14
+#
+ This file defines actions for ANSI console color escape codes.
+
+test:
+ $ = (bright "\(green)Color test passed.")
+
+$colors = {
+ .normal = 0, ."reset color" = 0, .bright = 1, .bold = 1, .dim = 2, .italic = 3
+ .underscore = 4, ."slow blink" = 5, ."fast blink" = 6, .reverse = 7, .inverse = 7
+ .inverted = 7, .hidden = 8
+ # There's some other codes, but they're not currently implemented
+ .black = 30, .red = 31, .green = 32, .yellow = 33, .blue = 34, .magenta = 35
+ .cyan = 36, .white = 37, ."on black" = 40, ."on red" = 41, ."on green" = 42
+ ."on yellow" = 43, ."on blue" = 44, ."on magenta" = 45, ."on cyan" = 46
+ ."on white" = 47
+}
+
+for $name = $colornum in $colors:
+ $colornum = "\$colornum"
+ $(COMPILE RULES).$name =
+ for ($compile $text):
+ if $text:
+ return (Lua "('\\027[\($colornum)m'..\($text as lua expr)..'\\027[0m')")
+ ..else:
+ return (Lua "'\\027[\($colornum)m'")