Parcourir la source

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

master
XeonSquared il y a 3 ans
Parent
révision
22bd6982d0
1 fichiers modifiés avec 18 ajouts et 5 suppressions
  1. +18
    -5
      lib/vtansi.lua

+ 18
- 5
lib/vtansi.lua Voir le fichier

@@ -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


Chargement…
Annuler
Enregistrer