Hi all,
In this thread
viewtopic.php?f=10&t=33737
Orthomaker colorizes syllables of words according to the french rules of pronunciation. He mentions that colorizing can be slow.
I attempted to do the colorization conditionally (using pseudo conditions) using styledText from the unformatted "raw" text.
Additionally I did the colorization using htmlText as comparison and also setting the colors of a word using "set the backgroundColor of char x to y of word to color"
I thought this might be of interest to people applying styles to longer texts.
Kind regards
Bernd
Building styledText or htmlText from scratch to colorize text
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Building styledText or htmlText from scratch to colorize text
- Attachments
-
- colorize Words StyledText_02.livecode.zip
- (5.83 KiB) Downloaded 236 times
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Building styledText or htmlText from scratch to colorize text
This is a beautiful demo of a "usual" scenario that shows that using htmlText is pretty fast (and here faster than styledText).
Anyway I can't understand the general hyping up of (the here slower) styledText as this is for most people hard to handle without the help of the "real stars" (team members and you).
Anyway I can't understand the general hyping up of (the here slower) styledText as this is for most people hard to handle without the help of the "real stars" (team members and you).
shiftLock happens
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Building styledText or htmlText from scratch to colorize text
I added a button in my upload that:
clears the text. Just a toy so I can see the text change with each method.
Craig
Code: Select all
on mouseUp
put fld "fDest" into fld "fDest"
end mouseUp
Craig
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: Building styledText or htmlText from scratch to colorize text
Thanks for this Bernd.
A few comments, hoping not to derail the thread!
I can see that the times for htmltext and styledText are both roughly proportional to the length of the original text, and that htmlText is a bit faster.
I remember a sample stack that was uploaded some 18 months ago (perhaps in reply to my question) and it might have been Hermann who produced it. (Sorry cannot find it by searching the forum.) It showed that htmlText was fast up to a point but for longer texts styledText was faster. Does that make sense? I remember Trevor Devore was the first who suggested styledText.
I am using htmlText, but the practical problem I find is that I need to color across several lines, so text contains returns. For html I need to close tags before return and open for next line. It just complicates the process. Additionally, i often have nested colors. Again I have to do all kinds of acrobatics to ensure open and close tags match.
For these reasons I have been thinking of moving to styledText, but arrays are not natural for me! Any thoughts on whether styledText would reduce my woes would be appreciated.
Kaveh
A few comments, hoping not to derail the thread!
I can see that the times for htmltext and styledText are both roughly proportional to the length of the original text, and that htmlText is a bit faster.
I remember a sample stack that was uploaded some 18 months ago (perhaps in reply to my question) and it might have been Hermann who produced it. (Sorry cannot find it by searching the forum.) It showed that htmlText was fast up to a point but for longer texts styledText was faster. Does that make sense? I remember Trevor Devore was the first who suggested styledText.
I am using htmlText, but the practical problem I find is that I need to color across several lines, so text contains returns. For html I need to close tags before return and open for next line. It just complicates the process. Additionally, i often have nested colors. Again I have to do all kinds of acrobatics to ensure open and close tags match.
For these reasons I have been thinking of moving to styledText, but arrays are not natural for me! Any thoughts on whether styledText would reduce my woes would be appreciated.
Kaveh
Kaveh
-
- VIP Livecode Opensource Backer
- Posts: 4003
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Building styledText or htmlText from scratch to colorize text
I think both htmlText and styledText get complex pretty soon depending on the amount of formatting you apply to the text. I think it boils down to what you are comfortable with. If you do not like arrays styledText is definitely not what you want. StyledText operates like htmlText on the paragraph level. Instead of opening and closing a tag you tag runs of characters in a paragraph by setting their "Style". A run of characters consists of sequential characters that share the same formatting in a numerically indexed run of a paragraph.kaveh1000 wrote: ↑Mon Mar 09, 2020 9:48 amI am using htmlText, but the practical problem I find is that I need to color across several lines, so text contains returns. For html I need to close tags before return and open for next line. It just complicates the process. Additionally, i often have nested colors. Again I have to do all kinds of acrobatics to ensure open and close tags match.
For these reasons I have been thinking of moving to styledText, but arrays are not natural for me! Any thoughts on whether styledText would reduce my woes would be appreciated.
If you want to find out you probably have to experiment with some simple formatting an see what happens
Kind regards
Bernd