Added multiline support for LogView's messages
This commit is contained in:
parent
15cfbfbc46
commit
7610e1064f
|
@ -226,7 +226,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
local function log(icon, icon_color, fmt, ...)
|
local function log(icon, icon_color, fmt, ...)
|
||||||
local text = string.format(fmt, ...):gsub("%s", " ")
|
local text = string.format(fmt, ...)
|
||||||
if icon then
|
if icon then
|
||||||
core.status_view:show_message(icon, icon_color, text)
|
core.status_view:show_message(icon, icon_color, text)
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,6 +33,18 @@ function LogView:update()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function draw_text_multiline(font, text, x, y, color)
|
||||||
|
local th = font:get_height()
|
||||||
|
local resx, resy = x, y
|
||||||
|
for line in text:gmatch("[^\n]+") do
|
||||||
|
resy = y
|
||||||
|
resx = renderer.draw_text(style.font, line, x, y, color)
|
||||||
|
y = y + th
|
||||||
|
end
|
||||||
|
return resx, resy
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function LogView:draw()
|
function LogView:draw()
|
||||||
self:draw_background(style.background)
|
self:draw_background(style.background)
|
||||||
|
|
||||||
|
@ -47,15 +59,13 @@ function LogView:draw()
|
||||||
x = renderer.draw_text(style.font, time, x, y, style.dim)
|
x = renderer.draw_text(style.font, time, x, y, style.dim)
|
||||||
x = x + style.padding.x
|
x = x + style.padding.x
|
||||||
local subx = x
|
local subx = x
|
||||||
x = renderer.draw_text(style.font, item.text, x, y, style.text)
|
x, y = draw_text_multiline(style.font, item.text, x, y, style.text)
|
||||||
x = renderer.draw_text(style.font, " at " .. item.at, x, y, style.dim)
|
renderer.draw_text(style.font, " at " .. item.at, x, y, style.dim)
|
||||||
y = y + th
|
y = y + th
|
||||||
if item.info then
|
if item.info then
|
||||||
for line in item.info:gmatch("[^\n]+") do
|
subx, y = draw_text_multiline(style.font, item.info, subx, y, style.dim)
|
||||||
renderer.draw_text(style.font, line, subx, y, style.dim)
|
|
||||||
y = y + th
|
y = y + th
|
||||||
end
|
end
|
||||||
end
|
|
||||||
y = y + style.padding.y
|
y = y + style.padding.y
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue