remove debugging syslog calls from buffer library, reduce draw calls for readline

This commit is contained in:
Izaya 2020-06-11 13:20:49 +10:00
parent f95124996c
commit b4db6c7226

View File

@ -263,15 +263,17 @@ function buffer:read(...)
local function redraw()
io.write("\27[u")
io.write(buffer.." ")
if pos < 1 then
io.write("\28[D")
else
io.write("\27[u")
io.write(buffer:sub(1,(#buffer-pos)+1))
end
end
while true do
syslog("top of readline loop")
char = readBytesOrChars(1)
if char == "\27" then
if readBytesOrChars(1) == "[" then
syslog("escape code")
local args = {""}
repeat
char = readBytesOrChars(1)
@ -286,12 +288,10 @@ function buffer:read(...)
until not char:match("[%d;]")
if char == "C" then -- right
if pos > 1 then
syslog("moving right")
pos = pos - 1
end
elseif char == "D" then -- left
if pos <= #buffer then
syslog("moving left")
pos = pos + 1
end
end
@ -305,7 +305,6 @@ function buffer:read(...)
if chop then buffer = buffer .. "\n" end
return buffer
else
syslog("char: "..tostring(string.byte(char)))
buffer = buffer:sub(1, (#buffer - pos) + 1) .. char .. buffer:sub((#buffer - pos) + 2)
end
redraw()