Line numbers for soft-wrapped styled text?

Alex Tweedly alex at tweedly.net
Tue Mar 28 19:23:26 EDT 2017


Thanks Ralph, but no, that doesn't make any difference.

Usually the "char 1 to -1" addition helps where there is an implied 
trailing delimiter. In this case, the problem occurs even for the 
simplest chunk expression of just a single line (e.g. "line N") where 
the delimiter is never included.

-- Alex.


On 28/03/2017 22:48, Ralph DiMola wrote:
> I remember once had a problem like something like this. I solved it by
> including char 1 to -1 or was it adding the effective keyword? Don't
> remember and I don't have time to try at this moment. If you do this do you
> get the expected results?
>
> the formattedheight of char 1 to -1 of line N of fld
> or
> the effective formattedheight of char 1 to -1 of line N of fld
> or
> the effective formattedheight of line N of fld
>
> Ralph DiMola
> IT Director
> Evergreen Information Services
> rdimola at evergreeninfo.net
>
>
> -----Original Message-----
> From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On Behalf
> Of Alex Tweedly via use-livecode
> Sent: Tuesday, March 28, 2017 4:13 PM
> To: use-livecode at lists.runrev.com
> Cc: Alex Tweedly
> Subject: Re: Line numbers for soft-wrapped styled text?
>
> There is a bit of a problem I encountered trying to code this up.
>
> I'm not 100% sure yet if it's a bug, though I think it must be. Comments
> anyone ?
>
>
> If I set the 'spacebelow' of the last (Nth) line of a field, and get the
> formattedheight of the field, that includes the spacebelow value just set.
>
> However, none of
>
>     the formattedheight of line N of fld ...
>
>     the formattedheight of line 1 to N of fld ...
>
>     the formattedheight of line 1 to -1 of fld ...
>
> include it.  The same is true of 'internal' lines - it's not just the
> last one in the field - the formattedheight of a chunk doesn't include
> any spacebelow set on the last line of the chunk.
>
> This makes it near impossible to use a binary search accurately (or
> indeed to reliably use "the formattedheight of chunk xx of fld yy").
>
> So now that I've describe it like that, I'm pretty sure it is a bug ....
> but comments welcome before I report it.
>
> -- Alex.
>
>
> On 28/03/2017 05:30, hh via use-livecode wrote:
>> The solution of Alex T. was the first example I saw of a useful
>> usage of the styledText array. TMHO this is the way to go for the
>> future of more and more complicated styled text.
>>
>> As was said elsewhere, there could be a considerable speed up if
>> first the visible range of lines, say numbers L1 to L2, is determined.
>>
>> We had once a thread in the forum about that. The fastest method:
>>
>> Compare the formattedHeight of line 1 to L of fld T to the vscroll v0
>> of fld T. Not by walking with L up from one, but by using a binary
>> search for L1 and then starting from there to find L2 by comparing to
>> v0+the height of fld T. This needs only a few millisecs even for large
>> chunks.
>>
>> Then use Alex's method with the styledText array of these lines. Or,
>> quick and dirty, save the selectedChunk, select before each line L
>> in the range L1 to L1 and collect the selectedLocs and then restore
>> the selectedChunk.
>>
>> Now draw the line numbers each into an own freshly created field or
>> use Alex's space below method.
>>
>> p.s. Hopefully you will share your final code.
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>





More information about the use-livecode mailing list