-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.lua
84 lines (74 loc) · 1.88 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
function ansi(open, close, text)
if text == nil then return '\27[' .. open .. 'm' end
return '\27[' .. open .. 'm' .. text .. '\27[' .. close .. 'm'
end
local Lunacolors = {
formatColors = {
boldOff = ansi(22),
underlineOff = ansi(24)
},
version = 'v0.2.1'
}
function init(name, codes)
Lunacolors[name] = function(text)
return ansi(codes[1], codes[2], text)
end
Lunacolors.formatColors[name] = ansi(codes[1])
end
-- Define colors
-- Modifiers
init('reset', {0, 0})
init('bold', {1, 22})
init('dim', {2, 22})
init('italic', {3, 23})
init('underline', {4, 24})
init('invert', {7, 27})
init('hidden', {8, 28})
init('strikethrough', {9, 29})
-- Colors
init('black', {30, 39})
init('red', {31, 39})
init('green', {32, 39})
init('yellow', {33, 39})
init('blue', {34, 39})
init('magenta', {35, 39})
init('cyan', {36, 39})
init('white', {37, 39})
-- Background colors
init('blackBg', {40, 49})
init('redBg', {41, 49})
init('greenBg', {42, 49})
init('yellowBg', {43, 49})
init('blueBg', {44, 49})
init('magentaBg', {45, 49})
init('cyanBg', {46, 49})
init('whiteBg', {47, 49})
-- Bright colors
init('brightBlack', {90, 39})
init('gray', {90, 39})
init('grey', {90, 39})
init('brightRed', {91, 39})
init('brightGreen', {92, 39})
init('brightYellow', {93, 39})
init('brightBlue', {94, 39})
init('brightMagenta', {95, 39})
init('brightCyan', {96, 39})
init('brightWhite', {97, 39})
-- Bright background
init('brightBlackBg', {100, 49})
init('grayBg', {100, 49})
init('greyBg', {100, 49})
init('brightRedBg', {101, 49})
init('brightGreenBg', {102, 49})
init('brightYellowBg', {103, 49})
init('brightBlueBg', {104, 49})
init('brightMagentaBg', {105, 49})
init('brightCyanBg', {106, 49})
init('brightWhiteBg', {107, 49})
Lunacolors.format = function(text)
for k, v in pairs(Lunacolors.formatColors) do
text = text:gsub('{' .. k .. '}', v)
end
return text .. Lunacolors.formatColors.reset
end
return Lunacolors