|
|
@@ -8,7 +8,7 @@ function vtemu(gpua,scra) -- creates a process to handle the GPU and screen addr |
|
|
|
for k,v in ipairs(component.invoke(scra,"getKeyboards")) do |
|
|
|
kba[v]=true |
|
|
|
end |
|
|
|
local buf = "" |
|
|
|
local buf, lbuf, echo = "", true, true |
|
|
|
os.spawn(function() dprint(pcall(function() |
|
|
|
while true do |
|
|
|
local ty,ka,ch = coroutine.yield() |
|
|
@@ -16,24 +16,43 @@ function vtemu(gpua,scra) -- creates a process to handle the GPU and screen addr |
|
|
|
if ch == 13 then ch = 10 end |
|
|
|
if ch == 8 then |
|
|
|
if buf:len() > 0 then |
|
|
|
write("\8 \8") |
|
|
|
if echo then write("\8 \8") end |
|
|
|
buf = buf:sub(1,-2) |
|
|
|
end |
|
|
|
elseif ch > 0 then |
|
|
|
write(string.char(ch)) |
|
|
|
if echo then write(string.char(ch)) end |
|
|
|
buf=buf..string.char(ch) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end)) end,string.format("ttyd[%s:%s]",gpua:sub(1,8),scra:sub(1,8))) |
|
|
|
local function bread() |
|
|
|
while not buf:find("\n") do |
|
|
|
local function bread(n) |
|
|
|
local r |
|
|
|
if lbuf then |
|
|
|
while not buf:find("\n") do |
|
|
|
coroutine.yield() |
|
|
|
end |
|
|
|
local n = buf:find("\n") |
|
|
|
r, buf = buf:sub(1,n), buf:sub(n+1) |
|
|
|
else |
|
|
|
r = buf |
|
|
|
buf = "" |
|
|
|
coroutine.yield() |
|
|
|
end |
|
|
|
local n = buf:find("\n") |
|
|
|
r, buf = buf:sub(1,n), buf:sub(n+1) |
|
|
|
return r |
|
|
|
end |
|
|
|
return bread, function(d) buf=buf..write(d) end, function() io.write("\27[2J\27[H") end |
|
|
|
local function bwrite(d) |
|
|
|
local ba, lb, ec = write(d) |
|
|
|
buf = buf .. ba |
|
|
|
if lb ~= nil then |
|
|
|
dprint("local buffer mode: "..tostring(lb)) |
|
|
|
lbuf = lb |
|
|
|
end |
|
|
|
if ec ~= nil then |
|
|
|
dprint("echo mode: "..tostring(ec)) |
|
|
|
echo = ec |
|
|
|
end |
|
|
|
end |
|
|
|
return bread, bwrite, function() io.write("\27[2J\27[H") end |
|
|
|
end |
|
|
|
end |