Merge branch 'master' of https://github.com/Pyroxenium/Basalt
This commit is contained in:
@@ -167,34 +167,42 @@ local function wrapRichText(text, width)
|
|||||||
elseif entry.bgColor then
|
elseif entry.bgColor then
|
||||||
currentBgColor = entry.bgColor
|
currentBgColor = entry.bgColor
|
||||||
else
|
else
|
||||||
local words = splitString(entry.text, " ")
|
local paragraphs = splitString(entry.text, "\n")
|
||||||
|
for p, paragraph in ipairs(paragraphs) do
|
||||||
|
local words = splitString(paragraph, " ")
|
||||||
|
|
||||||
for i, word in ipairs(words) do
|
for i, word in ipairs(words) do
|
||||||
local wordLength = #word
|
local wordLength = #word
|
||||||
|
|
||||||
if i > 1 then
|
if i > 1 then
|
||||||
if x + 1 + wordLength <= width then
|
if x + 1 + wordLength <= width then
|
||||||
addFormattedEntry({ text = " " })
|
addFormattedEntry({ text = " " })
|
||||||
x = x + 1
|
x = x + 1
|
||||||
else
|
else
|
||||||
x = 1
|
x = 1
|
||||||
y = y + 1
|
y = y + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
while wordLength > 0 do
|
||||||
|
local line = word:sub(1, width - x + 1)
|
||||||
|
word = word:sub(width - x + 2)
|
||||||
|
wordLength = #word
|
||||||
|
|
||||||
|
addFormattedEntry({ text = line })
|
||||||
|
|
||||||
|
if wordLength > 0 then
|
||||||
|
x = 1
|
||||||
|
y = y + 1
|
||||||
|
else
|
||||||
|
x = x + #line
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
while wordLength > 0 do
|
if p ~= #paragraphs then
|
||||||
local line = word:sub(1, width - x + 1)
|
x = 1
|
||||||
word = word:sub(width - x + 2)
|
y = y + 1
|
||||||
wordLength = #word
|
|
||||||
|
|
||||||
addFormattedEntry({ text = line })
|
|
||||||
|
|
||||||
if wordLength > 0 then
|
|
||||||
x = 1
|
|
||||||
y = y + 1
|
|
||||||
else
|
|
||||||
x = x + #line
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -211,6 +219,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getTextHorizontalAlign = function(text, width, textAlign, replaceChar)
|
getTextHorizontalAlign = function(text, width, textAlign, replaceChar)
|
||||||
text = sub(text, 1, width)
|
text = sub(text, 1, width)
|
||||||
|
|||||||
Reference in New Issue
Block a user