mirror of
https://github.com/rxi/lovebird.git
synced 2024-11-15 22:54:21 +00:00
Added function lovebird.recalcbuffer()
This commit is contained in:
parent
7401ba3d58
commit
fc96823be8
37
lovebird.lua
37
lovebird.lua
@ -482,25 +482,11 @@ function lovebird.pushline(line)
|
||||
if #lovebird.lines > lovebird.maxlines then
|
||||
table.remove(lovebird.lines, 1)
|
||||
end
|
||||
lovebird.recalcbuffer()
|
||||
end
|
||||
|
||||
|
||||
function lovebird.print(...)
|
||||
local t = {}
|
||||
for i = 1, select("#", ...) do
|
||||
table.insert(t, tostring(select(i, ...)))
|
||||
end
|
||||
local str = table.concat(t, " ")
|
||||
local last = lovebird.lines[#lovebird.lines]
|
||||
if last and str == last.str then
|
||||
-- Update last line if this line is a duplicate of it
|
||||
last.time = os.time()
|
||||
last.count = last.count + 1
|
||||
else
|
||||
-- Create new line
|
||||
lovebird.pushline({ type = "output", str = str })
|
||||
end
|
||||
-- Build string buffer from lines
|
||||
function lovebird.recalcbuffer()
|
||||
local function doline(line)
|
||||
local str = line.str
|
||||
if not lovebird.allowhtml then
|
||||
@ -519,6 +505,25 @@ function lovebird.print(...)
|
||||
end
|
||||
|
||||
|
||||
function lovebird.print(...)
|
||||
local t = {}
|
||||
for i = 1, select("#", ...) do
|
||||
table.insert(t, tostring(select(i, ...)))
|
||||
end
|
||||
local str = table.concat(t, " ")
|
||||
local last = lovebird.lines[#lovebird.lines]
|
||||
if last and str == last.str then
|
||||
-- Update last line if this line is a duplicate of it
|
||||
last.time = os.time()
|
||||
last.count = last.count + 1
|
||||
lovebird.recalcbuffer()
|
||||
else
|
||||
-- Create new line
|
||||
lovebird.pushline({ type = "output", str = str })
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function lovebird.onerror(err)
|
||||
lovebird.trace("ERROR:", err)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user