Line numbers for soft-wrapped styled text?

hh hh at hyperhh.de
Tue Mar 28 00:30:23 EDT 2017


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.





More information about the use-livecode mailing list