Parse new lines in text objects correctly

This commit is contained in:
Ethan Shaughnessy 2014-02-22 14:48:49 -07:00
parent 1c7ab5feb4
commit 135fc0b436

View File

@ -282,10 +282,10 @@ function newobject:SetText(t)
table.insert(self.formattedtext, {font = prevfont, color = prevcolor, linkcolor = prevlinkcolor, linkhovercolor = prevlinkhovercolor, link = link, text = tostring(v)}) table.insert(self.formattedtext, {font = prevfont, color = prevcolor, linkcolor = prevlinkcolor, linkhovercolor = prevlinkhovercolor, link = link, text = tostring(v)})
elseif dtype == "string" then elseif dtype == "string" then
if self.ignorenewlines then if self.ignorenewlines then
v = v:gsub(" \n ", " ") v = v:gsub("\n", " ")
v = v:gsub("\n", "")
end end
v = v:gsub(string.char(9), " ") v = v:gsub(string.char(9), " ")
v = v:gsub("\n", " \n ")
local parts = loveframes.util.SplitString(v, " ") local parts = loveframes.util.SplitString(v, " ")
for i, j in ipairs(parts) do for i, j in ipairs(parts) do
table.insert(self.formattedtext, {font = prevfont, color = prevcolor, linkcolor = prevlinkcolor, linkhovercolor = prevlinkhovercolor, link = link, text = j}) table.insert(self.formattedtext, {font = prevfont, color = prevcolor, linkcolor = prevlinkcolor, linkhovercolor = prevlinkhovercolor, link = link, text = j})
@ -778,4 +778,4 @@ function newobject:GetDetectLinks()
return self.detectlinks return self.detectlinks
end end