fix textgpu somehow getting *really* long buffer lines, which broke things sometimes

This commit is contained in:
ocawesome101 2021-06-04 20:11:23 -04:00
parent f847f6a2ca
commit c6a0ecd8a4

View File

@ -92,6 +92,10 @@ local function set(x, y, text, f, b, safe, noref)
bbuffer[y] = bbuffer[y]:sub(1, x - 1) ..
string.rep(string.char(b - 1), len) .. bbuffer[y]:sub(x + len)
end
-- clamp buffers
tbuffer[y] = unsub(tbuffer[y], 1, w)
fbuffer[y] = fbuffer[y]:sub(1, w)
bbuffer[y] = bbuffer[y]:sub(1, w)
if not noref then
write("\27[", y, ";", x, "H", text)
flush()
@ -103,6 +107,7 @@ fullRefresh = function()
local text = tbuffer[i]
local fgt = fbuffer[i]
local bgt = bbuffer[i]
--native.log("UPDATE " .. i .. ": \"" .. text .. "\"")
local pb, pf
fgt = fgt:gsub("()(.)", function(n, fc)
local bc, tc = bgt:sub(n,n), text:sub(n,n)
@ -289,7 +294,8 @@ function textgpu.start()
end
for i=start, stop, step do
local str, fstr, bstr = get(x, i, W, true)
if str and fstr and bstr then
--native.log("COPY " .. i .. " (" .. (str or "") .. ") to " .. (i + yd))
if str then-- and fstr and bstr then
set(x + xd, i + yd, str, fstr, bstr, true, true)
end
end