-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathcolors.lua
More file actions
65 lines (58 loc) · 1.1 KB
/
colors.lua
File metadata and controls
65 lines (58 loc) · 1.1 KB
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
-- This Script is Part of the Prometheus Obfuscator by levno-710
--
-- colors.lua
--
-- This Script provides a simple method for syntax highlighting of Lua code
local keys = {
reset = 0,
bright = 1,
dim = 2,
underline = 4,
blink = 5,
reverse = 7,
hidden = 8,
black = 30,
pink = 91,
red = 31,
green = 32,
yellow = 33,
blue = 34,
magenta = 35,
cyan = 36,
grey = 37,
gray = 37,
white = 97,
blackbg = 40,
redbg = 41,
greenbg = 42,
yellowbg = 43,
bluebg = 44,
magentabg = 45,
cyanbg = 46,
greybg = 47,
graybg = 47,
whitebg = 107,
}
local escapeString = string.char(27) .. "[%dm"
local function escapeNumber(number)
return escapeString:format(number)
end
local settings = {
enabled = true,
}
local function colors(str, ...)
if not settings.enabled then
return str
end
str = tostring(str or "")
local escapes = {}
for _, name in ipairs({ ... }) do
table.insert(escapes, escapeNumber(keys[name]))
end
return escapeNumber(keys.reset) .. table.concat(escapes) .. str .. escapeNumber(keys.reset)
end
return setmetatable(settings, {
__call = function(_, ...)
return colors(...)
end,
})