forked from izaya/LuPPC
color works now \o/
This commit is contained in:
parent
3246aa2d65
commit
b4fefd4c0f
@ -45,6 +45,10 @@ local fg = 256
|
||||
local bg = 1
|
||||
local w, h = 1, 1
|
||||
|
||||
local function rgb(i)
|
||||
return i>>16&0xFF, i>>8&0xFF, i&0xFF
|
||||
end
|
||||
|
||||
local unsub, fullRefresh
|
||||
local function set(x, y, text, f, b, safe)
|
||||
if x > w or x < 1 or y > h or y < 1 or not tbuffer[y] then
|
||||
@ -69,7 +73,8 @@ local function set(x, y, text, f, b, safe)
|
||||
f .. fbuffer[y]:sub(x + len)
|
||||
else
|
||||
local F = mapping[f]
|
||||
write("\27[38;2;", F&0xFF0000>>16, ";", F&0x00FF00>>8, ";", F&0x0000FF, "m")
|
||||
local r, g, _b = rgb(F)
|
||||
write("\27[38;2;", r, ";", g, ";", _b, "m")
|
||||
fbuffer[y] = fbuffer[y]:sub(1, x - 1) ..
|
||||
string.rep(string.char(f - 1), len) .. fbuffer[y]:sub(x + len)
|
||||
end
|
||||
@ -78,7 +83,8 @@ local function set(x, y, text, f, b, safe)
|
||||
b .. bbuffer[y]:sub(x + len)
|
||||
else
|
||||
local B = mapping[b]
|
||||
write("\27[48;2;", B&0xFF0000>>16, ";", B&0x00FF00>>8, ";", B&0x0000FF, "m")
|
||||
local r, g, _b = rgb(B)
|
||||
write("\27[48;2;", r, ";", g, ";", _b, "m")
|
||||
bbuffer[y] = bbuffer[y]:sub(1, x - 1) ..
|
||||
string.rep(string.char(b - 1), len) .. bbuffer[y]:sub(x + len)
|
||||
end
|
||||
@ -99,13 +105,13 @@ fullRefresh = function()
|
||||
pb = bc
|
||||
local B = mapping[bc:byte() + 1]
|
||||
str = str .. string.format("\27[48;2;%d;%d;%dm",
|
||||
B&0xFF0000>>16, B&0x00FF00>>8, B&0x0000FF)
|
||||
rgb(B))
|
||||
end
|
||||
if fc ~= pf then
|
||||
pf = fc
|
||||
local F = mapping[fc:byte() + 1]
|
||||
str = str .. string.format("\27[38;2;%d;%d;%dm",
|
||||
F&0xFF0000>>16, F&0x00FF00>>8, F&0x0000FF)
|
||||
rgb(F))
|
||||
end
|
||||
str = str .. tc
|
||||
return str
|
||||
@ -276,7 +282,6 @@ function textgpu.start()
|
||||
for i=start, stop, step do
|
||||
local str, fstr, bstr = get(x, i, W, true)
|
||||
if str and fstr and bstr then
|
||||
lprint("GPU_COPY: " .. str .. " FROM " .. i .. " TO " .. (i + yd))
|
||||
set(x + xd, i + yd, str, fstr, bstr, true)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user