Two features I don't understand

Richard Gaskin ambassador at fourthworld.com
Fri Oct 31 14:24:22 EDT 2014


Always valuable to read your words here, Fraser.  Meeting you was one of 
the key highlights for me at the conference.

You wrote:

 > Internally, the field is structured somewhat like this(*):
 >
 > - Field
 >    - Paragraph 1
 >        - Run 1
 >        - Run 2
 >    - Paragraph 2
 >
 > and the styledText property is that structure in array form. (A “run” 
 > in this case is a block of text sharing the same styling attributes).
 > It is also possible to set properties at the paragraph and field
 > levels so these are also exported in the styledText.
 >
 > The offsets aren’t stored because they are redundant with the
 > contents of the array - Run 2 comes after Run 1 (and Paragraph 2
 > comes after Paragraph 1). Storing them would cause problems when
 > the contents of any of the runs are updated.
 > ...
 > (*) the field is vastly more complicated than this diagram. For
 > example, there are “lines” and “segments” used internally between
 > paragraphs and runs in order to keep the code remotely manageable.

This is one of the things that had eluded me about this feature originally:

I had been looking at StyledText as a means of setting attributes, very 
useful for setting at the field or paragraph level, but without offsets 
not so much for making a single word within a paragraph bold, for example.

But I see now that most folks are using it as read-only, for exporters. 
  I can definitely see very high value in that - in fact, I'm tempted 
now to rewrite some exporters I have to make use of this over htmlText 
as I had been using.


 > It is by far the most complicated control in the engine and that
 > was before adding support for things like bi-directional text input…
 > the humble LiveCode field is actually not all that different from
 > the insides of a word processor.

Agreed.  I think Kevin was being modest:
<http://lists.runrev.com/pipermail/use-livecode/2012-February/168802.html>

In terms of the full scope of features a true word processor needs to 
compete against Microsoft I think he has a good point there, but in the 
broader view of being able to craft very specialized word processing 
tools I think LiveCode is perhaps the most capable development option on 
the planet.


This is good to know:

 > In terms of comparisons with htmlText, styledText is more “raw” -
 > far closer to the field’s internal representation than HTML.
 > Because of this, it is easier for the field to process than HTML
 > (especially as HTML has to be parsed while the array is already
 > structured). Looking at it from the other side, an array is generally
 > easier to manipulate compared to parsing HTML in your scripts.

Thanks for your input, Fraser.  And thanks to Trevor, Tom, and the 
others who've provided good examples of styledText in use.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list