Files
HyperionOS/prod/Hyperion-firmware-ccpc/lib/modules/ccpc/25_gfx.kmod

2 lines
5.6 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
local a=...local b=a.apis;local c=b.peripheral;local d={"top","bottom","left","right","front","back"}local e={}function e.getNames()local f={}for g=1,#d do local h=d[g]if c.isPresent(h)then table.insert(f,h)if c.hasType(h,"peripheral_hub")then local i=c.call(h,"getNamesRemote")for j,k in ipairs(i)do table.insert(f,k)end end end end;return f end;function e.isPresent(k)if c.isPresent(k)then return true end;for g=1,#d do local h=d[g]if c.hasType(h,"peripheral_hub")and c.call(h,"isPresentRemote",k)then return true end end;return false end;function e.getType(e)if type(e)=="string"then if c.isPresent(e)then return c.getType(e)end;for g=1,#d do local h=d[g]if c.hasType(h,"peripheral_hub")and c.call(h,"isPresentRemote",e)then return c.call(h,"getTypeRemote",e)end end;return nil else local l=getmetatable(e)if not l or l.__name~="peripheral"or type(l.types)~="table"then error("bad argument #1 (table is not a peripheral)",2)end;return table.unpack(l.types)end end;function e.hasType(e,m)if type(e)=="string"then if c.isPresent(e)then return c.hasType(e,m)end;for g=1,#d do local h=d[g]if c.hasType(h,"peripheral_hub")and c.call(h,"isPresentRemote",e)then return c.call(h,"hasTypeRemote",e,m)end end;return nil else local l=getmetatable(e)if not l or l.__name~="peripheral"or type(l.types)~="table"then error("bad argument #1 (table is not a peripheral)",2)end;return l.types[m]~=nil end end;function e.getMethods(k)if c.isPresent(k)then return c.getMethods(k)end;for g=1,#d do local h=d[g]if c.hasType(h,"peripheral_hub")and c.call(h,"isPresentRemote",k)then return c.call(h,"getMethodsRemote",k)end end;return nil end;function e.getName(e)local l=getmetatable(e)if not l or l.__name~="peripheral"or type(l.name)~="string"then error("bad argument #1 (table is not a peripheral)",2)end;return l.name end;function e.call(k,n,...)if c.isPresent(k)then return c.call(k,n,...)end;for g=1,#d do local h=d[g]if c.hasType(h,"peripheral_hub")and c.call(h,"isPresentRemote",k)then return c.call(h,"callRemote",k,n,...)end end;return nil end;function e.wrap(k)local o=e.getMethods(k)if not o then return nil end;local p={e.getType(k)}for q=1,#p do p[p[q]]=true end;local r=setmetatable({},{__name="peripheral",name=k,type=p[1],types=p})for j,n in ipairs(o)do r[n]=function(...)return e.call(k,n,...)end end;return r end;function e.find(s,t)local f={}for j,k in ipairs(e.getNames())do if e.hasType(k,s)then local u=e.wrap(k)if t==nil or t(k,u)then table.insert(f,u)end end end;return table.unpack(f)end;local v={[0x1]=1,[0x2]=2,[0x4]=3,[0x8]=4,[0x10]=5,[0x20]=6,[0x40]=7,[0x80]=8,[0x100]=9,[0x200]=10,[0x400]=11,[0x800]=12,[0x1000]=13,[0x2000]=14,[0x4000]=15,[0x8000]=16}local w={0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080,0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000}local function x(y,z)local A,B=z.getCursorPos()local C,D=z.getSize()for q=1,#y do local E=y:sub(q,q)if E=="\n"then B=B+1;A=1 elseif E=="\t"then local F=4;local G=F-(A-1)%F;z.write(string.rep(" ",G))A=A+G elseif E=="\b"then if A>1 then A=A-1;z.setCursorPos(A,B)z.write(" ")z.setCursorPos(A,B)end else if A<=C and B<=D then z.setCursorPos(A,B)z.write(E)A=A+1 end end;if A>C then A=1;B=B+1 end;if B-1>=D then z.scroll(1)B=D;z.setCursorPos(A,B)end end;z.setCursorPos(A,B)end;a.devfs.data.tty={}local H,I=false,false;local function J(K)if K then return"T"else return"F"end end;local function L(M,N,O)a.devfs.data["tty"][N]=function(P,Q)if P=="type"then return"character device"elseif P=="open"then local D={read=function(R)local S=""for q=1,R or 1 do local T={O()}if T[1]then S=S..T[1]end end;if S==""then S=nil end;return S end,write=function(U)x(U,M)end,size=function()local V={M.getSize()}return table.concat(V,";")end,clear=function()M.clear()M.setCursorPos(1,1)end,gpos=function()local V={M.getCursorPos()}return table.concat(V,";")end,spos=function(A,B)return M.setCursorPos(A,B)end,sfgc=function(E)return M.setTextColor(w[E])end,sbgc=function(E)return M.setBackgroundColor(w[E])end,gfgc=function()return v[M.getTextColor()]end,gbgc=function()return v[M.getBackgroundColor()]end,gctrl=function()return J(H)..";"..J(I)end}if Q=="rw"then return D elseif Q=="r"then D["write"]=nil;return D elseif Q=="w"then D["read"]=nil;return D end end end end;local W=a.newFifo()a.processes.cctmond=function()local X=false;while true do local T={a.EFI:getMachineEvent()}if T[1]then local Y=T[1]local Z=T[3]local _={[b.keys.a]=1,[b.keys.b]=2,[b.keys.c]=3,[b.keys.d]=4,[b.keys.e]=5,[b.keys.f]=6,[b.keys.g]=7,[b.keys.h]=8,[b.keys.i]=9,[b.keys.j]=10,[b.keys.k]=11,[b.keys.l]=12,[b.keys.m]=13,[b.keys.n]=14,[b.keys.o]=15,[b.keys.p]=16,[b.keys.q]=17,[b.keys.r]=18,[b.keys.s]=19,[b.keys.t]=20,[b.keys.u]=21,[b.keys.v]=22,[b.keys.w]=23,[b.keys.x]=24,[b.keys.y]=25,[b.keys.z]=26}if Y=="keyPressed"then if Z==b.keys.leftCtrl or Z==b.keys.rightCtrl then H=true elseif Z==b.keys.leftAlt or Z==b.keys.rightAlt then I=true end;if H then local a0=_[Z]if a0 then if a0==3 then for j,a1 in ipairs(syscall.getTasks())do syscall.sigsend(a1,1)end else W.push(string.char(a0))end end else local a2={[b.keys.up]="",[b.keys.down]="",[b.keys.right]="",[b.keys.left]="",[b.keys.home]="",[b.keys["end"]]="",[b.keys.pageUp]="[5~",[b.keys.pageDown]="[6~",[b.keys.delete]="[3~"}local a3=a2[Z]if a3 then W.push(a3)end end elseif Y=="keyReleased"then if Z==b.keys.leftCtrl or Z==b.keys.rightCtrl then H=false elseif Z==b.keys.leftAlt or Z==b.keys.rightAlt then I=false end elseif Y=="keyTyped"then if Z then W.push(Z)end end;X=false else X=true end;if X then sleep(0.05)end end end;L(b.term,"1",W.pop)for q,a4 in ipairs({e.find("monitor")})do a4.setTextScale(.5)a4.write("Initializing...")L(a4,tostring(q+1),function()end)end