mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-22 12:04:20 -05:00
Compare commits
3 Commits
583b300720
...
23173506b9
Author | SHA1 | Date | |
---|---|---|---|
|
23173506b9 | ||
|
a9b3c6adf3 | ||
|
459fd95992 |
@ -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()
|
||||
@ -45,9 +46,7 @@ function vt100emu(gpu) -- takes GPU component proxy *gpu* and returns a function
|
||||
gpu.set(cx,cy,pc)
|
||||
for cc in s:gmatch(".") do
|
||||
if mode == 0 then
|
||||
if string.byte(cc) > 31 and string.byte(cc) < 128 then -- probably printable
|
||||
wb = wb .. cc
|
||||
elseif cc == "\n" then
|
||||
if cc == "\n" then
|
||||
flushwb()
|
||||
cx,cy = 1, cy+1
|
||||
elseif cc == "\t" then
|
||||
@ -55,6 +54,8 @@ function vt100emu(gpu) -- takes GPU component proxy *gpu* and returns a function
|
||||
elseif cc == "\27" then
|
||||
flushwb()
|
||||
mode = 1
|
||||
else
|
||||
wb = wb .. cc
|
||||
end
|
||||
elseif mode == 1 then
|
||||
if cc == "[" then
|
||||
@ -96,14 +97,14 @@ function vt100emu(gpu) -- takes GPU component proxy *gpu* and returns a function
|
||||
elseif cc == "J" and tA[1] == 1 then
|
||||
gpu.fill(1,1,mx,cy," ")
|
||||
elseif cc == "J" and tA[1] == 2 then
|
||||
gpu.full(1,1,mx,my," ")
|
||||
gpu.fill(1,1,mx,my," ")
|
||||
cx, cy = 1, 1
|
||||
elseif cc == "J" then
|
||||
gpu.fill(1,cy,mx,my," ")
|
||||
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)
|
||||
@ -122,13 +127,14 @@ function vt100emu(gpu) -- takes GPU component proxy *gpu* and returns a function
|
||||
end
|
||||
end
|
||||
flushwb()
|
||||
checkCursor()
|
||||
pc = gpu.get(cx,cy)
|
||||
gpu.setForeground(bg)
|
||||
gpu.setBackground(fg)
|
||||
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