mirror of
https://github.com/rxi/lovebird.git
synced 2024-11-27 12:04: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
|
if #lovebird.lines > lovebird.maxlines then
|
||||||
table.remove(lovebird.lines, 1)
|
table.remove(lovebird.lines, 1)
|
||||||
end
|
end
|
||||||
|
lovebird.recalcbuffer()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function lovebird.print(...)
|
function lovebird.recalcbuffer()
|
||||||
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
|
|
||||||
local function doline(line)
|
local function doline(line)
|
||||||
local str = line.str
|
local str = line.str
|
||||||
if not lovebird.allowhtml then
|
if not lovebird.allowhtml then
|
||||||
@ -519,6 +505,25 @@ function lovebird.print(...)
|
|||||||
end
|
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)
|
function lovebird.onerror(err)
|
||||||
lovebird.trace("ERROR:", err)
|
lovebird.trace("ERROR:", err)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user