ha! fixed it, mostly... now to make colors work

This commit is contained in:
ocawesome101 2021-05-28 13:19:44 -04:00
parent 7dade89a0e
commit 3246aa2d65
1 changed files with 7 additions and 5 deletions

View File

@ -59,10 +59,11 @@ local function set(x, y, text, f, b, safe)
b = b or bg
local len = utf8.len(text)
if x + len > w then
text = unsub(text, 1, -1 - ((x + len) - w))
--len = (x + len) - w
--text = unsub(text, 1, len)
end
tbuffer[y] = tbuffer[y]:sub(1, x - 1) ..
text .. tbuffer[y]:sub(x + len)
tbuffer[y] = unsub(tbuffer[y], 1, x - 1) ..
text .. unsub(tbuffer[y], x + len)
if type(f) == "string" then
fbuffer[y] = fbuffer[y]:sub(1, x - 1) ..
f .. fbuffer[y]:sub(x + len)
@ -81,7 +82,7 @@ local function set(x, y, text, f, b, safe)
bbuffer[y] = bbuffer[y]:sub(1, x - 1) ..
string.rep(string.char(b - 1), len) .. bbuffer[y]:sub(x + len)
end
write("\27[", x, ";", y, "H", text)
write("\27[", y, ";", x, "H", text)
flush()
end
@ -222,6 +223,7 @@ function textgpu.start()
checkArg(2, y, "number")
checkArg(3, text, "string")
checkArg(4, vert, "boolean", "nil")
vert = false
if vert then
local i = 1
local len = utf8.len(text)
@ -251,7 +253,7 @@ function textgpu.start()
c = unsub(c, 1, 1)
if #c == 0 then return true end
local str = c:rep(W)
for i=1, h, 1 do
for i=1, H, 1 do
set(x, y + i - 1, str, nil, nil, true)
end
return true