made cursor movement and newlines work properly when they hit screen borders
This commit is contained in:
parent
8bb123f198
commit
22bd6982d0
@ -2,10 +2,10 @@ local vtansi = {}
|
|||||||
vtansi.sequences = {
|
vtansi.sequences = {
|
||||||
[28] = "\n", -- newline
|
[28] = "\n", -- newline
|
||||||
[200] = "\27[A", -- up
|
[200] = "\27[A", -- up
|
||||||
[201] = "\27[5~", -- page up
|
|
||||||
[203] = "\27[D", -- left
|
[203] = "\27[D", -- left
|
||||||
[205] = "\27[C", -- right
|
[205] = "\27[C", -- right
|
||||||
[208] = "\27[B", -- down
|
[208] = "\27[B", -- down
|
||||||
|
[201] = "\27[5~", -- page up
|
||||||
[209] = "\27[6~" -- page down
|
[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
|
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
|
if cc == "\n" then
|
||||||
flushwb()
|
flushwb()
|
||||||
cx,cy = 1, cy+1
|
cx,cy = 1, cy+1
|
||||||
|
checkCursor()
|
||||||
elseif cc == "\t" then
|
elseif cc == "\t" then
|
||||||
wb=wb..(" "):rep(8*((cx+9)//8))
|
wb=wb..(" "):rep(8*((cx+9)//8))
|
||||||
elseif cc == "\27" then
|
elseif cc == "\27" then
|
||||||
@ -85,13 +86,25 @@ function vtansi.vtemu(gpu) -- table -- function -- takes GPU component proxy *gp
|
|||||||
if cc == "H" then
|
if cc == "H" then
|
||||||
cx, cy = math.min(mx,tA[1] or 1), math.min(my,tA[2] or 1)
|
cx, cy = math.min(mx,tA[1] or 1), math.min(my,tA[2] or 1)
|
||||||
elseif cc == "A" then
|
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
|
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
|
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
|
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
|
elseif cc == "s" then
|
||||||
sx, sy = cx, cy
|
sx, sy = cx, cy
|
||||||
elseif cc == "u" then
|
elseif cc == "u" then
|
||||||
|
Loading…
Reference in New Issue
Block a user