]> cvs.zerfleddert.de Git - proxmark3-svn/blame - client/lualibs/ansicolors.lua
CHG: "hf legic write" - now writes on the limits better.
[proxmark3-svn] / client / lualibs / ansicolors.lua
CommitLineData
790e8eae 1local pairs = pairs
2local tostring = tostring
3local setmetatable = setmetatable
4local schar = string.char
5
6module 'ansicolors'
7
8local colormt = {}
9
10function colormt:__tostring()
11 return self.value
12end
13
14function colormt:__concat(other)
15 return tostring(self) .. tostring(other)
16end
17
18function colormt:__call(s)
19 return self .. s .. _M.reset
20end
21
22colormt.__metatable = {}
23
24local function makecolor(value)
25 return setmetatable({ value = schar(27) .. '[' .. tostring(value) .. 'm' }, colormt)
26end
27
28local colors = {
29 -- attributes
30 reset = 0,
31 clear = 0,
32 bright = 1,
33 dim = 2,
34 underscore = 4,
35 blink = 5,
36 reverse = 7,
37 hidden = 8,
38
39 -- foreground
40 black = 30,
41 red = 31,
42 green = 32,
43 yellow = 33,
44 blue = 34,
45 magenta = 35,
46 cyan = 36,
47 white = 37,
48
49 -- background
50 onblack = 40,
51 onred = 41,
52 ongreen = 42,
53 onyellow = 43,
54 onblue = 44,
55 onmagenta = 45,
56 oncyan = 46,
57 onwhite = 47,
58}
59
60for c, v in pairs(colors) do
61 _M[c] = makecolor(v)
62end
63
Impressum, Datenschutz