diff --git a/modules/drivers/tty.lua b/modules/drivers/tty.lua index 0e6b98e..71539f1 100644 --- a/modules/drivers/tty.lua +++ b/modules/drivers/tty.lua @@ -1,10 +1,10 @@ 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) local sx, sy = gP.getResolution() gP.setResolution(sx,sy) - gP.setForeground(bg or 0xFFFFFF) - gP.setBackground(bg or 0x000000) + gP.setForeground(fg) + gP.setBackground(bg) gP.fill(1,1,sx,sy," ") local function cv() if cx > sx then cx,cy=1,cy+1 end @@ -18,7 +18,7 @@ function tty(gA,sA,sI,fg,bg) elseif c == "\r" then cx=1 elseif c == "\f" then cx=1 cy=1 gP.fill(1, 1, sx, sy, " ") elseif c == "\t" then cx=(cx+4-((cx+4)%4))+1 - elseif c == "\127" then cx=cx-1 gP.set(cx,cy," ") + elseif c == "\127" then cx=cx-1 gP.set(cx,cy," ") else gP.set(cx,cy,c) cx=cx+1 end cv() end @@ -28,6 +28,12 @@ function tty(gA,sA,sI,fg,bg) eT = ev if eT[1] == "display" and eT[3] == sI then 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 C.yield() end diff --git a/modules/library/readline.lua b/modules/library/readline.lua index 262069a..8edbf59 100644 --- a/modules/library/readline.lua +++ b/modules/library/readline.lua @@ -1,6 +1,5 @@ function readln(rC) local s,si="",E().sI or 1 - write("|") while true do if ev[1] == "key" and ev[2] == si then if ev[3] == 13 then @@ -8,9 +7,9 @@ function readln(rC) C.yield() return s 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 - 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 C.yield()