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