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
|
||||
currentBgColor = entry.bgColor
|
||||
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
|
||||
local wordLength = #word
|
||||
for i, word in ipairs(words) do
|
||||
local wordLength = #word
|
||||
|
||||
if i > 1 then
|
||||
if x + 1 + wordLength <= width then
|
||||
addFormattedEntry({ text = " " })
|
||||
x = x + 1
|
||||
else
|
||||
x = 1
|
||||
y = y + 1
|
||||
if i > 1 then
|
||||
if x + 1 + wordLength <= width then
|
||||
addFormattedEntry({ text = " " })
|
||||
x = x + 1
|
||||
else
|
||||
x = 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
|
||||
|
||||
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
|
||||
if p ~= #paragraphs then
|
||||
x = 1
|
||||
y = y + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -209,6 +217,7 @@ local function wrapRichText(text, width)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
@@ -340,4 +349,4 @@ uuid = function()
|
||||
return string.gsub(string.format('%x-%x-%x-%x-%x', math.random(0, 0xffff), math.random(0, 0xffff), math.random(0, 0xffff), math.random(0, 0x0fff) + 0x4000, math.random(0, 0x3fff) + 0x8000), ' ', '0')
|
||||
end
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user