I am using @ar2rsawseen
textwrap class. It is really a good solution. Also there is one more Textwrap2 by @atilim
which is optimized for vey vey long texts. But i am using ar2rsawseen's cause it also supports formats like justify etc.
I had something in mind like this when i started:
@" in the beginning of the lines. And the code will recognize them and format my line according to correspending parameters.
Example inside txt file:
This is a test line.@This
is a test line.
@ line will be green color. But the first line will be black as default.
What i done:
1-To function TextWrap:setText(text) i added some lines of code like this:
local line = TextField.new(self.font, part)
print(atchar) --check only
@ signs inside our text
line:setTextColor(0xfff450) --set the wanted color for the <a href="/profile/2">@2</a> line
line:setTextColor(self.textColor) --else default
2-For the ones doesn't want to format the txt file i wrote another function which you can give spesific lines that you want to change colors. So for example if you will give begin=1 and ending=3, 1,2,3 lines will be differnet color in your program.
self.textColor = color
for i = begin, endind do
local sprite = self:getChildAt(i)
So here is an example project.
When i will finish all the class i will post it here again. I posted before finishing because maybe someone else have some other ideas about it and we can work all together.