forked from izaya/OC-PsychOS2
there is now a non-standard control code for the terminal to toggle line mode and local echo for the terminal
This commit is contained in:
parent
459fd95992
commit
a9b3c6adf3
@ -28,6 +28,7 @@ function vt100emu(gpu) -- takes GPU component proxy *gpu* and returns a function
|
||||
|
||||
local function termwrite(s)
|
||||
local wb = ""
|
||||
local lb, ec = nil, nil
|
||||
local function flushwb()
|
||||
while wb:len() > 0 do
|
||||
checkCursor()
|
||||
@ -103,7 +104,7 @@ function vt100emu(gpu) -- takes GPU component proxy *gpu* and returns a function
|
||||
elseif cc == "m" then
|
||||
for _,num in ipairs(tA) do
|
||||
if num == 0 then
|
||||
fg,bg = 0xFFFFFF,0
|
||||
fg,bg,ec,lb = 0xFFFFFF,0,true,true
|
||||
elseif num == 7 then
|
||||
local nfg,nbg = bg, fg
|
||||
fg, bg = nfg, nbg
|
||||
@ -111,6 +112,10 @@ function vt100emu(gpu) -- takes GPU component proxy *gpu* and returns a function
|
||||
fg = colours[num-29]
|
||||
elseif num > 39 and num < 48 then
|
||||
bg = colours[num-39]
|
||||
elseif num == 100 then -- disable local echo
|
||||
ec = false
|
||||
elseif num == 101 then -- disable line mode
|
||||
lb = false
|
||||
end
|
||||
end
|
||||
gpu.setForeground(fg)
|
||||
@ -129,7 +134,7 @@ function vt100emu(gpu) -- takes GPU component proxy *gpu* and returns a function
|
||||
gpu.set(cx,cy,pc)
|
||||
gpu.setForeground(fg)
|
||||
gpu.setBackground(bg)
|
||||
return rs
|
||||
return rs, lb, ec
|
||||
end
|
||||
|
||||
return termwrite
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user