fix length check when reading a dictionary file
[RRG-proxmark3.git] / client / lualibs / ansicolors.lua
blob3815310da2caa7e924e6e9c35c198ff3309af914
1 local pairs = pairs
2 local tostring = tostring
3 local setmetatable = setmetatable
4 local schar = string.char
6 local colormt = {}
8 function colormt:__tostring()
9 return self.value
10 end
12 function colormt:__concat(other)
13 return tostring(self) .. tostring(other)
14 end
16 function colormt:__call(s)
17 return self .. s .. _M.reset
18 end
20 colormt.__metatable = {}
22 local function makecolor(value)
23 return setmetatable({ value = schar(27) .. '[' .. tostring(value) .. 'm' }, colormt)
24 end
26 local colors = {
27 -- attributes
28 reset = 0,
29 clear = 0,
30 bright = 1,
31 dim = 2,
32 underscore = 4,
33 blink = 5,
34 reverse = 7,
35 hidden = 8,
37 -- foreground
38 black = 30,
39 red = 31,
40 green = 32,
41 yellow = 33,
42 blue = 34,
43 magenta = 35,
44 cyan = 36,
45 white = 37,
47 -- background
48 onblack = 40,
49 onred = 41,
50 ongreen = 42,
51 onyellow = 43,
52 onblue = 44,
53 onmagenta = 45,
54 oncyan = 46,
55 onwhite = 47,
58 local Ansicolors = {}
59 for c, v in pairs(colors) do
60 Ansicolors[c] = makecolor(v)
61 end
63 return Ansicolors