Changed buffer to use lines, replaced maxbuffer -> maxlines

This commit is contained in:
rxi 2014-04-10 18:23:04 +01:00
parent a370307e8d
commit aa7c37791b

View File

@ -16,9 +16,10 @@ lovebird.wrapprint = true
lovebird.host = "*" lovebird.host = "*"
lovebird.port = 8000 lovebird.port = 8000
lovebird.whitelist = { "127.0.0.1", "localhost" } lovebird.whitelist = { "127.0.0.1", "localhost" }
lovebird.maxbuffer = 20000 lovebird.maxlines = 200
lovebird.refreshrate = .5 lovebird.refreshrate = .5
lovebird.buffer = "" lovebird.buffer = ""
lovebird.lines = {}
local loadstring = loadstring or load local loadstring = loadstring or load
@ -188,11 +189,12 @@ end
function lovebird.print(...) function lovebird.print(...)
local str = table.concat(map({...}, tostring), " ") .. "<br>" local str = table.concat(map({...}, tostring), " ")
lovebird.buffer = lovebird.buffer .. str table.insert(lovebird.lines, str)
if #lovebird.buffer > lovebird.maxbuffer then if #lovebird.lines > lovebird.maxlines then
lovebird.buffer = lovebird.buffer:sub(-lovebird.maxbuffer) table.remove(lovebird.lines, 1)
end end
lovebird.buffer = table.concat(lovebird.lines, "<br>")
end end