made tty.lua handle the cursor rather than readline because that's just stupid
This commit is contained in:
parent
d5f77ef8c9
commit
2c6f92261e
@ -1,10 +1,10 @@
|
|||||||
function tty(gA,sA,sI,fg,bg)
|
function tty(gA,sA,sI,fg,bg)
|
||||||
local gP,cx,cy = component.proxy(gA),1,1
|
local gP,cx,cy,bg,fg = component.proxy(gA),1,1,bg or 0x000000, fg or 0xffffff
|
||||||
gP.bind(sA)
|
gP.bind(sA)
|
||||||
local sx, sy = gP.getResolution()
|
local sx, sy = gP.getResolution()
|
||||||
gP.setResolution(sx,sy)
|
gP.setResolution(sx,sy)
|
||||||
gP.setForeground(bg or 0xFFFFFF)
|
gP.setForeground(fg)
|
||||||
gP.setBackground(bg or 0x000000)
|
gP.setBackground(bg)
|
||||||
gP.fill(1,1,sx,sy," ")
|
gP.fill(1,1,sx,sy," ")
|
||||||
local function cv()
|
local function cv()
|
||||||
if cx > sx then cx,cy=1,cy+1 end
|
if cx > sx then cx,cy=1,cy+1 end
|
||||||
@ -28,6 +28,12 @@ function tty(gA,sA,sI,fg,bg)
|
|||||||
eT = ev
|
eT = ev
|
||||||
if eT[1] == "display" and eT[3] == sI then
|
if eT[1] == "display" and eT[3] == sI then
|
||||||
wl(tostring(eT[2]))
|
wl(tostring(eT[2]))
|
||||||
|
local cc,fg,bg=gP.get(cx,cy)
|
||||||
|
gP.setForeground(bg)
|
||||||
|
gP.setBackground(fg)
|
||||||
|
gP.set(cx,cy,cc)
|
||||||
|
gP.setForeground(fg)
|
||||||
|
gP.setBackground(bg)
|
||||||
end
|
end
|
||||||
C.yield()
|
C.yield()
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
function readln(rC)
|
function readln(rC)
|
||||||
local s,si="",E().sI or 1
|
local s,si="",E().sI or 1
|
||||||
write("|")
|
|
||||||
while true do
|
while true do
|
||||||
if ev[1] == "key" and ev[2] == si then
|
if ev[1] == "key" and ev[2] == si then
|
||||||
if ev[3] == 13 then
|
if ev[3] == 13 then
|
||||||
@ -8,9 +7,9 @@ function readln(rC)
|
|||||||
C.yield()
|
C.yield()
|
||||||
return s
|
return s
|
||||||
elseif ev[3] == 8 then
|
elseif ev[3] == 8 then
|
||||||
if s:len()>0 then s=s:sub(1,-2) write("\127\127|") end
|
if s:len()>0 then s=s:sub(1,-2) write("\127") end
|
||||||
elseif ev[3] > 31 and ev[3] < 127 then
|
elseif ev[3] > 31 and ev[3] < 127 then
|
||||||
s=s..string.char(ev[3]) write("\127"..(rC or string.char(ev[3])).."|")
|
s=s..string.char(ev[3]) write((rC or string.char(ev[3])))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
C.yield()
|
C.yield()
|
||||||
|
Loading…
Reference in New Issue
Block a user