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
|
||||||
local F = mapping[f]
|
if not noref then
|
||||||
local r, g, _b = rgb(F)
|
local F = mapping[f]
|
||||||
write("\27[38;2;", r, ";", g, ";", _b, "m")
|
local r, g, _b = rgb(F)
|
||||||
|
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,14 +84,18 @@ 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
|
||||||
local B = mapping[b]
|
if not noref then
|
||||||
local r, g, _b = rgb(B)
|
local B = mapping[b]
|
||||||
write("\27[48;2;", r, ";", g, ";", _b, "m")
|
local r, g, _b = rgb(B)
|
||||||
|
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
|
||||||
write("\27[", y, ";", x, "H", text)
|
if not noref then
|
||||||
flush()
|
write("\27[", y, ";", x, "H", text)
|
||||||
|
flush()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fullRefresh = function()
|
fullRefresh = function()
|
||||||
@ -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