aboutsummaryrefslogtreecommitdiff
path: root/lib/consolecolor
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-29 16:16:45 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-29 16:17:33 -0800
commitbc41cc3a244bf47679d1c47d17006a2aa7356bc8 (patch)
tree102ec25b54f795d7a24648faa129f4dbccef3619 /lib/consolecolor
parentfebe7e82e06e1071c312f449b1ced319ef9a6932 (diff)
Switched to have colors/utf8 be optional, fixed an issue with currently
running files leaking when errors occurred (causing spurious circular import errors), and improved tutorial.
Diffstat (limited to 'lib/consolecolor')
-rw-r--r--lib/consolecolor/init.nom15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/consolecolor/init.nom b/lib/consolecolor/init.nom
index 27823b8..606f4b6 100644
--- a/lib/consolecolor/init.nom
+++ b/lib/consolecolor/init.nom
@@ -17,9 +17,12 @@ $colors = {
}
for $name = $colornum in $colors:
- $colornum = "\$colornum"
- \($name \$text) compiles to:
- if $text:
- return (Lua "('\\027[\($colornum)m'..\($text as lua expr)..'\\027[0m')")
- ..else:
- return (Lua "'\\027[\($colornum)m'")
+ (nomsu environment).($name, as lua id) =
+ for $text:
+ if $(COLOR ENABLED):
+ if $text:
+ return "\x1B[\($colornum)m\$text\x1b[0m"
+ ..else:
+ return "\x1B[\($colornum)m"
+ ..else:
+ return ($text or "")