From bc41cc3a244bf47679d1c47d17006a2aa7356bc8 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 29 Jan 2019 16:16:45 -0800 Subject: 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. --- lib/consolecolor/init.nom | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/consolecolor/init.nom') 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 "") -- cgit v1.2.3