|
|
|
@ -48,13 +48,12 @@ end
|
|
|
|
|
local function truncatePath(text)
|
|
|
|
|
local screen_width = Screen:getWidth()
|
|
|
|
|
local face = Font:getFace("xx_smallinfofont")
|
|
|
|
|
local reversed_text = string.reverse(text)
|
|
|
|
|
local txt_width = RenderText:sizeUtf8Text(0, screen_width, face, reversed_text, nil, false).x
|
|
|
|
|
-- we want to truncate text on the left, so work with the reverse of text (which is fine as we don't use kerning)
|
|
|
|
|
local reversed_text = require("util").utf8Reverse(text)
|
|
|
|
|
local txt_width = RenderText:sizeUtf8Text(0, screen_width, face, reversed_text, false, false).x
|
|
|
|
|
if screen_width - 2 * Size.padding.small < txt_width then
|
|
|
|
|
reversed_text = RenderText:truncateTextByWidth(reversed_text, face, screen_width - 2 * Size.padding.small, nil, false)
|
|
|
|
|
-- string.reverse() breaks "…" so we delete it
|
|
|
|
|
reversed_text = reversed_text:sub(1, -5)
|
|
|
|
|
text = "…" .. string.reverse(reversed_text)
|
|
|
|
|
reversed_text = RenderText:truncateTextByWidth(reversed_text, face, screen_width - 2 * Size.padding.small, false, false)
|
|
|
|
|
text = require("util").utf8Reverse(reversed_text)
|
|
|
|
|
end
|
|
|
|
|
return text
|
|
|
|
|
end
|
|
|
|
|