Not many people know this.
Mark Waddingham
mark at livecode.com
Thu Aug 16 14:21:02 EDT 2018
On 2018-08-16 19:48, Richard Gaskin via use-livecode wrote:
> I'm not sure if this info has been incorporated into the docs system
> yet, but the Release Notes for v5.5 offer a solid overview of the new
> field features (starting on p12), most of which are paragraph-level
> properties like indent, border, padding, etc. (p19), along with the
> wonderfully efficient styledText array representation of field
> contents ([p16) and super-useful indented lists a la HTML and word
> processors (p18):
> https://downloads.livecode.com/livecode/5_5_4/LiveCodeNotes-5_5_4.pdf
I think all the relevant props and such are in the dictionary - even the
styledText property. However, it is perhaps not the clearest description
of the latter - so any suggestions on how to improve that would be most
welcome. (As it uses a hierarchical array value - and quite a 'complex'
one, relatively speaking - it is quite 'new' in terms of how it works
compared to older properties; as such we perhaps haven't found the best
way to explain it!).
In response to Clarence's question - paragraph when applied to a field
is a synonym to line.
There are two types of style properties - paragraph (line) level and
char level. These are all distinct apart from one - metadata.
If you set a char style of a paragraph/line then it is equivalent to
char 1 to -1 of line. e.g.
set the textFont of line 1 of field 1 to "Geneva"
<=>
set the textFont of char 1 to -1 of line 1 of field 1
If you set the paragraph style of a char then it is equivalent to
line (the lineIndex of char) of field:
set the spaceAbove of char 3 of field 1 to 10
<=>
set the spaceAbove of line (the lineIndex of char 3 of field 1) to 10
[ Note: 'the lineIndex of <field chunk>' gives the index of the line
chunk the start of <field chunk> is in, and the 'charIndex of <field
chunk>' gives the index of the char the start of <field chunk> is in. ]
The exception to the above to rules (as mentioned above) is 'the
metadata' property - with that property you can *either* set at the line
level, or the char level or both:
set the metadata of line 3 of field 1 to "Hello World!"
set the metadata of char 3 of line 3 of field 1 to "Goodbye World!"
Will result in "Hello World!" being applied to the line, and "Goodbye
World!" being applied to char 3 of the line - i.e. neither clobbers the
other, and you need to use the same kind of chunk reference to fetch the
value back.
Warmest Regards,
Mark.
P.S. You can largely thank Trevor for the above additions, in particular
the styledText and metadata - in terms of providing use-cases which led
to their design and implementation.
P.P.S. I won't necessarily thank him for the loss of hair that resulted
in actually implementing them in the field object itself. There's a good
reason we treat that particular 10,000 odd lines of code with a great
deal of care and respect - it really doesn't like being touched very
much!
--
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps
More information about the use-livecode
mailing list