Textgpu fixes
This commit is contained in:
parent
ac3b1c62a7
commit
56072b2c51
@ -21,7 +21,7 @@ function internet.start()
|
||||
return {
|
||||
finishConnect = function()
|
||||
if not sfd then
|
||||
return false, reason
|
||||
error(reason)
|
||||
end
|
||||
return true
|
||||
end,
|
||||
@ -40,6 +40,15 @@ function internet.start()
|
||||
}
|
||||
end
|
||||
|
||||
function component.request(url, post)
|
||||
local host = url:match("http://([^/]+)")
|
||||
local con = component.connect(host, 80)
|
||||
if con:finishConnect() then
|
||||
con:write("GET " .. url .. " HTTP/1.1\r\nHost: " .. host .. "\r\n\r\n")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
modules.component.api.register(nil, "internet", component)
|
||||
end
|
||||
|
||||
|
@ -39,12 +39,16 @@ local function prepareBuffers(w, h)
|
||||
end
|
||||
end
|
||||
|
||||
local usub = modules.sandbox.utf8.sub
|
||||
local usub
|
||||
local function insertString(main, sub, at)
|
||||
checkArg(1, main, "string")
|
||||
checkArg(2, sub, "string")
|
||||
checkArg(3, at, "number")
|
||||
return usub(main, 1, at - 1) .. sub .. usub(main, at + utf8.len(sub))
|
||||
end
|
||||
|
||||
function textgpu.start()
|
||||
usub = modules.sandbox.unicode.sub
|
||||
local gpu = {}
|
||||
function gpu.bind() return false, "This is static bound gpu" end
|
||||
function gpu.setBackground(color, isPaletteIndex)
|
||||
@ -125,11 +129,15 @@ function textgpu.start()
|
||||
x = math.floor(x)
|
||||
y = math.floor(y)
|
||||
if not vertical then
|
||||
if not tbuffer[y] then
|
||||
return false
|
||||
end
|
||||
tbuffer[y] = insertString(tbuffer[y], value, x)
|
||||
bbuffer[y] = insertString(bbuffer[y], background:rep(utf8.len(value)), x)
|
||||
fbuffer[y] = insertString(fbuffer[y], foreground:rep(utf8.len(value)), x)
|
||||
write("\x1b[" .. y .. ";" .. x .. "H" .. value)
|
||||
else
|
||||
--TODO: Buffers!
|
||||
write("\x1b[" .. y .. ";" .. x .. "H")
|
||||
value:gsub(".", function(c)
|
||||
write(c .. "\x1b[D\x1b[B")
|
||||
@ -171,12 +179,14 @@ function textgpu.start()
|
||||
if lwrite then
|
||||
local wx = (tx + linex)|0
|
||||
local wy = (ty + y + i - 1)|0
|
||||
write("\x1b[4" .. bg .. "m")
|
||||
write("\x1b[3" .. fg .. "m")
|
||||
write("\x1b[" .. wy .. ";" .. wx .. "H" .. line)
|
||||
tbuffer[wy] = insertString(tbuffer[wy], line, wx)
|
||||
bbuffer[wy] = insertString(bbuffer[wy], bg:rep(utf8.len(line)), wx)
|
||||
fbuffer[wy] = insertString(fbuffer[wy], fg:rep(utf8.len(line)), wx)
|
||||
if tbuffer[wy] then
|
||||
write("\x1b[4" .. bg .. "m")
|
||||
write("\x1b[3" .. fg .. "m")
|
||||
write("\x1b[" .. wy .. ";" .. wx .. "H" .. line)
|
||||
tbuffer[wy] = insertString(tbuffer[wy], line, wx)
|
||||
bbuffer[wy] = insertString(bbuffer[wy], bg:rep(utf8.len(line)), wx)
|
||||
fbuffer[wy] = insertString(fbuffer[wy], fg:rep(utf8.len(line)), wx)
|
||||
end
|
||||
bg = btbuf[i]:sub(j,j)
|
||||
fg = ftbuf[i]:sub(j,j)
|
||||
line = nil
|
||||
@ -189,12 +199,14 @@ function textgpu.start()
|
||||
if line then
|
||||
local wx = (tx + linex)|0
|
||||
local wy = (ty + y + i - 1)|0
|
||||
write("\x1b[4" .. bg .. "m")
|
||||
write("\x1b[3" .. fg .. "m")
|
||||
write("\x1b[" .. wy .. ";" .. wx .. "H" .. line)
|
||||
tbuffer[wy] = insertString(tbuffer[wy], line, wx)
|
||||
bbuffer[wy] = insertString(bbuffer[wy], bg:rep(utf8.len(line)), wx)
|
||||
fbuffer[wy] = insertString(fbuffer[wy], fg:rep(utf8.len(line)), wx)
|
||||
if tbuffer[wy] then
|
||||
write("\x1b[4" .. bg .. "m")
|
||||
write("\x1b[3" .. fg .. "m")
|
||||
write("\x1b[" .. wy .. ";" .. wx .. "H" .. line)
|
||||
tbuffer[wy] = insertString(tbuffer[wy], line, wx)
|
||||
bbuffer[wy] = insertString(bbuffer[wy], bg:rep(utf8.len(line)), wx)
|
||||
fbuffer[wy] = insertString(fbuffer[wy], fg:rep(utf8.len(line)), wx)
|
||||
end
|
||||
line = nil
|
||||
linex = nil
|
||||
lwrite = false
|
||||
|
Loading…
Reference in New Issue
Block a user