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