From c6a0ecd8a430f61606052d66ceac01b9dead05c7 Mon Sep 17 00:00:00 2001 From: ocawesome101 Date: Fri, 4 Jun 2021 20:11:23 -0400 Subject: [PATCH] fix textgpu somehow getting *really* long buffer lines, which broke things sometimes --- src/lua/core/textgpu.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lua/core/textgpu.lua b/src/lua/core/textgpu.lua index 096bd6f..acb2732 100644 --- a/src/lua/core/textgpu.lua +++ b/src/lua/core/textgpu.lua @@ -78,7 +78,7 @@ local function set(x, y, text, f, b, safe, noref) 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) + string.rep(string.char(f - 1), len) .. fbuffer[y]:sub(x + len) end if type(b) == "string" then bbuffer[y] = bbuffer[y]:sub(1, x - 1) .. @@ -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