livfoss at mac.com
Wed Feb 18 14:28:59 EST 2015
Richard, great insight as usual. I see that bothering with HTML was probably a totally unnecessary trip down the rabbit hole.
While I hide behind a rock (to deflect the shrapnel), who decided what the standard for style runs should be? Not Microsoft, I assume. Like there are some underlying conventions that are hidden from the public gaze...
Arrays, forsooth. I suppose I'd better dust off my understanding of those blighters. Used to use them for purely numeric work (but that was when dinosaurs ruled the Earth).
> On 18 Feb 2015, at 19:08, Richard Gaskin <ambassador at fourthworld.com> wrote:
> Graham Samuel wrote:
> > I just tried it and of course it works, but I can’t quite see
> > what’s happening inside LC. I mean, I can select the field
> > within my stack which has the formatted text in it, copy it
> > and paste it into Word, and bingo! it looks the same. There
> > is no obvious sign that Word thinks it was formatted in HTML.
> When text is rendered on screen (in LC, Word, or even a Web browser), it's a binary structure of text and style runs.
> None of the formatting per se is in html/htmlText. Those are just plain-text ways to *describe* formatting, but not the formatting itself.
> Any renderer, such as LiveCode or a browser, will need to interpret those html/htmlText descriptions into text with style runs.
> HtmlText is simply an intermediary format generated from the binary style run data when obtained from a field, and interpreted into binary style run data when applied to a field.
> If this isn't confusing enough, take some time to experiment with the relatively new styledText field property. It returns an array of the text and style runs within a field object in a way that more closely reflects how the engine handles these things under the hood.
> Not only will styledText give you a new appreciation for how programs render styled text, but once you get the hang of working with it you'll find it's often much faster for identifying and manipulating style info in field contents than htmlText.
> For example, last week I needed to find runs of text in a field that had linkText values. In htmlText the performance wasn't bad, but when I rewrote that to use a styledText array it took only half as long.
> Getting close to the engine is rarely a bad thing.
> Know the engine.
> Trust the engine.
> Use the engine.
> Richard Gaskin
> Fourth World Systems
> Software Design and Development for the Desktop, Mobile, and the Web
> Ambassador at FourthWorld.com http://www.FourthWorld.com
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the Use-livecode