feat(gui): lange tekstrækker ombrydes over flere linjer i stedet for at blive afkortet; markdetaljen viser hele statusteksten (v1.29.4.0)
This commit is contained in:
@@ -147,3 +147,22 @@ function ADFlowView.joinCounted(names, separator, empty)
|
||||
end
|
||||
return table.concat(parts, separator)
|
||||
end
|
||||
|
||||
-- Lang tekst -> linjer på højst maxChars (ombrydes ved mellemrum; indrykning gentages på hver linje,
|
||||
-- så en indrykket forklaring forbliver indrykket). Ét ord længere end linjen deles ikke.
|
||||
function ADFlowView.wrapText(text, maxChars)
|
||||
text = tostring(text or "")
|
||||
if #text <= maxChars then return {text} end
|
||||
local indent = string.match(text, "^%s*") or ""
|
||||
local lines, line = {}, indent
|
||||
for word in string.gmatch(string.sub(text, #indent + 1), "%S+") do
|
||||
if line ~= indent and #line + 1 + #word > maxChars then
|
||||
table.insert(lines, line)
|
||||
line = indent .. word
|
||||
else
|
||||
line = line == indent and (indent .. word) or (line .. " " .. word)
|
||||
end
|
||||
end
|
||||
if line ~= indent then table.insert(lines, line) end
|
||||
return lines
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user