aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/utils.nom30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/utils.nom b/lib/utils.nom
index 608e72f..55503e1 100644
--- a/lib/utils.nom
+++ b/lib/utils.nom
@@ -84,3 +84,33 @@ compile [max of %items by %value_expr] to:
| return \(%value_expr as lua)
|end)
+# String utilities
+compile [nl, newline, line feed, linefeed, lf] to: ".."
+ |"\n"
+compile [tab] to: ".."
+ |"\t"
+compile [bell] to: ".."
+ |"\a"
+compile [cr, carriage return] to: ".."
+ |"\r"
+compile [backspace] to: ".."
+ |"\b"
+compile [form feed, formfeed] to: ".."
+ |"\f"
+compile [vertical tab] to: ".."
+ |"\v"
+
+lua code ".."
+ |do;
+ | local colors = {
+ | ["reset color"] = 0, bright = 1, dim = 2, underscore = 4, blink = 5,
+ | inverse = 7, hidden = 8, 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,code in pairs(colors) do;
+ | local escape = "\\"\\\\27["..tostring(code).."m\\""
+ | nomsu:defmacro(name, function() return escape end, "");
+ | end;
+ |end;