forked from izaya/LuPPC
small scrolling optimization to textgpu
This commit is contained in:
parent
b4fefd4c0f
commit
ecdc855ee0
@ -50,7 +50,7 @@ local function rgb(i)
|
||||
end
|
||||
|
||||
local unsub, fullRefresh
|
||||
local function set(x, y, text, f, b, safe)
|
||||
local function set(x, y, text, f, b, safe, noref)
|
||||
if x > w or x < 1 or y > h or y < 1 or not tbuffer[y] then
|
||||
if safe then
|
||||
return
|
||||
@ -72,9 +72,11 @@ local function set(x, y, text, f, b, safe)
|
||||
fbuffer[y] = fbuffer[y]:sub(1, x - 1) ..
|
||||
f .. fbuffer[y]:sub(x + len)
|
||||
else
|
||||
if not noref then
|
||||
local F = mapping[f]
|
||||
local r, g, _b = rgb(F)
|
||||
write("\27[38;2;", r, ";", g, ";", _b, "m")
|
||||
end
|
||||
fbuffer[y] = fbuffer[y]:sub(1, x - 1) ..
|
||||
string.rep(string.char(f - 1), len) .. fbuffer[y]:sub(x + len)
|
||||
end
|
||||
@ -82,15 +84,19 @@ local function set(x, y, text, f, b, safe)
|
||||
bbuffer[y] = bbuffer[y]:sub(1, x - 1) ..
|
||||
b .. bbuffer[y]:sub(x + len)
|
||||
else
|
||||
if not noref then
|
||||
local B = mapping[b]
|
||||
local r, g, _b = rgb(B)
|
||||
write("\27[48;2;", r, ";", g, ";", _b, "m")
|
||||
end
|
||||
bbuffer[y] = bbuffer[y]:sub(1, x - 1) ..
|
||||
string.rep(string.char(b - 1), len) .. bbuffer[y]:sub(x + len)
|
||||
end
|
||||
if not noref then
|
||||
write("\27[", y, ";", x, "H", text)
|
||||
flush()
|
||||
end
|
||||
end
|
||||
|
||||
fullRefresh = function()
|
||||
for i=1, h, 1 do
|
||||
@ -282,7 +288,7 @@ 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
|
||||
set(x + xd, i + yd, str, fstr, bstr, true)
|
||||
set(x + xd, i + yd, str, fstr, bstr, true, true)
|
||||
end
|
||||
end
|
||||
fullRefresh()
|
||||
|
Loading…
Reference in New Issue
Block a user