1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-11-21 19:44:21 -05:00

made cursor movement and newlines work properly when they hit screen borders

This commit is contained in:
XeonSquared 2020-06-21 21:31:19 +10:00
parent 8bb123f198
commit 22bd6982d0

View File

@ -2,10 +2,10 @@ local vtansi = {}
vtansi.sequences = {
[28] = "\n", -- newline
[200] = "\27[A", -- up
[201] = "\27[5~", -- page up
[203] = "\27[D", -- left
[205] = "\27[C", -- right
[208] = "\27[B", -- down
[201] = "\27[5~", -- page up
[209] = "\27[6~" -- page down
}
function vtansi.vtemu(gpu) -- table -- function -- takes GPU component proxy *gpu* and returns a function to write to it in a manner like an ANSI terminal
@ -59,6 +59,7 @@ function vtansi.vtemu(gpu) -- table -- function -- takes GPU component proxy *gp
if cc == "\n" then
flushwb()
cx,cy = 1, cy+1
checkCursor()
elseif cc == "\t" then
wb=wb..(" "):rep(8*((cx+9)//8))
elseif cc == "\27" then
@ -85,13 +86,25 @@ function vtansi.vtemu(gpu) -- table -- function -- takes GPU component proxy *gp
if cc == "H" then
cx, cy = math.min(mx,tA[1] or 1), math.min(my,tA[2] or 1)
elseif cc == "A" then
cy = cy - (tA[1] or 1)
for i = 1, (tA[1] or 1) do
cy = cy - 1
checkCursor()
end
elseif cc == "B" then
cy = cy + (tA[1] or 1)
for i = 1, (tA[1] or 1) do
cy = cy + 1
checkCursor()
end
elseif cc == "C" then
cx = cx + (tA[1] or 1)
for i = 1, (tA[1] or 1) do
cx = cx + 1
checkCursor()
end
elseif cc == "D" then
cx = cx - (tA[1] or 1)
for i = 1, (tA[1] or 1) do
cx = cx - 1
checkCursor()
end
elseif cc == "s" then
sx, sy = cx, cy
elseif cc == "u" then