diff --git a/lib/vtansi.lua b/lib/vtansi.lua index 024b60b..c6b1208 100644 --- a/lib/vtansi.lua +++ b/lib/vtansi.lua @@ -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