hopeful multisession support

This commit is contained in:
Izaya 2017-05-16 02:26:28 +10:00
parent 080af72ca6
commit 95a5a16e0f
9 changed files with 83 additions and 22 deletions

View File

@ -1,5 +1,5 @@
optimise no
listmods no
optimise yes
listmods yes
test no
log no
opath kernel.lua

View File

@ -1,18 +1,8 @@
base/header.lua
drivers/dterm.lua
library/print.lua
drivers/keyboard.lua
library/net.lua
library/fs-min.lua
library/fs-std.lua
library/fs-ext.lua
library/fs-util.lua
library/base64.lua
util/fs-automount.lua
net/ping.lua
applications/shutil.lua
applications/evproxy-srv.lua
applications/evproxy-client.lua
applications/ircbridge.lua
applications/luash.lua
util/sinit.lua
base/footer.lua

View File

@ -1,6 +1,6 @@
tT,p,C,T={},1,coroutine,table
function s(n,f,e)
T.insert(tT,{n,C.create(f),(e or {})})
function E()
if tT[cT] ~= nil then return tT[cT][3] end
end
function l()
return eV
@ -8,3 +8,6 @@ end
function h(...)
computer.pushSignal(...)
end
function s(n,f,e)
T.insert(tT,{n,C.create(f),(e or E() or {})})
end

10
modules/drivers/kbd.lua Normal file
View File

@ -0,0 +1,10 @@
function kbd(kA,sI)
s("kbd: "..kA..","..tostring(si),function()
while true do
if ev[1] == "key_down" and ev[2] == kA then
h("key",sI,ev[3],ev[4])
end
C.yield()
end
end)
end

34
modules/drivers/tty.lua Normal file
View File

@ -0,0 +1,34 @@
function tty(gA,sA,sI,fg,bg)
local gP,cx,cy = component.proxy(gA),1,1
gP.bind(sA)
local sx, sy = gP.getResolution()
gP.setResolution(sx,sy)
gP.setForeground(bg or 0xFFFFFF)
gP.setBackground(bg or 0x000000)
gP.fill(1,1,sx,sy," ")
local function cv()
if cx > sx then cx,cy=1,cy+1 end
if cx < 1 then cx,cy=1,cy-1 end
if cy < 1 then cx,cy=1,1 end
if cy > sy then gP.copy(1,2,sx,sy-1,1,1) gP.fill(1,sx,sy,1," ") cx,cy=1,sy end
end
local function wl(str)
for c in str:gmatch(".") do
if c == "\n" then cx,cy=1,cy+1
elseif c == "\r" then cx=1
elseif c == "\f" then cx=1 cy=1 gP.fill(1, 1, sx, sy, " ")
elseif c == "\127" then cx=cx-1 gP.set(cx,cy," ")
else gP.set(cx,cy,c) cx=cx+1
end cv()
end
end
s("display: "..gA..","..sA,function()
while true do
eT = ev
if eT[1] == "display" and eT[3] == sI then
wl(tostring(eT[2]))
end
C.yield()
end
end)
end

View File

@ -1,10 +1,10 @@
function print(...)
for k,v in pairs({...}) do
h("display",tostring(v).."\n")
end
end
function write(...)
for k,v in pairs({...}) do
h("display",tostring(v))
h("display",tostring(v),E().sI)
end
end
function print(...)
for k,v in pairs({...}) do
write(tostring(v).."\n")
end
end

View File

@ -0,0 +1,19 @@
function readln()
local s=""
write("|")
while true do
if ev[1] == "key" and ev[2] == E().sI then
if ev[3] == 13 then
write("\127\n")
C.yield()
return s
elseif ev[3] == 8 then
if s:len()>0 then s=s:sub(1,-2) write("\127\127|") end
elseif ev[3] > 31 and ev[3] < 127 then
s=s..string.char(ev[3]) write("\127"..string.char(ev[3]).."|")
end
end
C.yield()
end
end

5
modules/util/autogpu.lua Normal file
View File

@ -0,0 +1,5 @@
print("","GPU: "..component.list("gpu")(),"Screen: "..component.list("screen")(),"Keyboard:"..component.list("keyboard")())
print("Starting tty")
tty(component.list("gpu")(),component.list("screen")(),1)
print("Starting kbd")
kbd(component.list("keyboard")(),1)

View File

@ -17,4 +17,4 @@ s("init",function()
if _OSVERSION and _BD then
print("Started ".._OSVERSION.." (built at ".._BD..")")
end
end)
end,{["sI"]=1})