From 9f08215dfb179c3c37c18016fb0eafb7ec6e681e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 23 Jun 2018 18:04:11 -0700 Subject: Moved console colors from core/ into lib/ --- lib/consolecolor.nom | 19 +++++++++++++++++++ lib/version.nom | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 lib/consolecolor.nom (limited to 'lib') diff --git a/lib/consolecolor.nom b/lib/consolecolor.nom new file mode 100644 index 0000000..3a53849 --- /dev/null +++ b/lib/consolecolor.nom @@ -0,0 +1,19 @@ +use "core" + +%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 + with {%escapecode: "\27[\(%colornum)m"} + lua> ".." + nomsu.COMPILE_ACTIONS[\%name] = function(nomsu, tree) + return LuaCode.Value(tree.source, repr(\%escapecode)) + end + nomsu.COMPILE_ACTIONS[\%name.." %"] = function(nomsu, tree, text) + return LuaCode.Value(tree.source, repr(\%escapecode), "..", nomsu:compile(text), "..'\\\\27[0m'") + end diff --git a/lib/version.nom b/lib/version.nom index 3b90888..3e9a29d 100644 --- a/lib/version.nom +++ b/lib/version.nom @@ -1 +1 @@ -lua> "NOMSU_LIB_VERSION = 2" +lua> "NOMSU_LIB_VERSION = 3" -- cgit v1.2.3