Line numbers for soft-wrapped styled text?
Richard Gaskin
ambassador at fourthworld.com
Mon Mar 27 15:32:56 EDT 2017
When I first started down this road I went for getting max values from
the styledText array, similar (though far less efficiently) to how Alex
Tweedly solved this so well in his post the other day:
http://lists.runrev.com/pipermail/use-livecode/2017-March/235688.html
Great work as usual from Alex there, reasonably performant enough for
most needs and very well crafted.
This morning Jim Lambert emailed me a very different solution that I
thought would be worth sharing here.
Here he uses the engine's own metrics for calculating vertical line
spacings, by having the number field placed below the editable text
field, setting its width to that of the editable field + a left margin
in which he uses the engine's support for numeric list styles to draw
the line numbers:
on textchanged
lock screen
set the htmltext of fld "nums" to the htmltext of me
set the liststyle of line 1 to -1 of fld nums to "decimal"
set the scroll of fld "nums" to the scroll of me
end textchanged
The only downside I can see to this approach is for memory, as it
requires copying the full styled text from the source field into the
line number field.
Very minor drawbacks for my needs are aesthetic: I prefer a line number
field without trailing decimal points ("1" rather than "1." as LC's
listStyle renders), and that line number be left-aligned by LC renders
its list line numbers left-aligned.
But overall quite nice, and very snappy. Thanks, Jim!
--
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