Line numbers for soft-wrapped styled text?
ahsoftware at sonic.net
Sat Mar 25 12:07:05 EDT 2017
On 03/25/2017 08:36 AM, Richard Gaskin via use-livecode wrote:
> I have an app that allows the user to write styled text, in which any
> portion of that text may have a variety of styles and sizes, and may be
> long enough to soft-wrap.
> I'd like to add a line-number field next to it, but I haven't come up
> with an efficient way of setting up those line numbers so that they
> align vertically with the lines next to them.
> Ideally the line numbers would reflect true lines, separated by CRs, as
> opposed to any soft-wrapped lines.
> What I'm after is common in many apps that support line numbers for
> style text, but alas I don't have a ready solution.
> Anyone here done this? Any tips you can share for doing this efficiently?
I looked into that for the glx2 script editor and gave up. Soft line
wrapping by itself isn't a problem, and line numbering by itself isn't a
problem, but there's no message generated that lets you know when
wrapping is happening, and no indication in the text fields that a line
has been wrapped.
The only ugly solution I could think of was to iterate through each of
the lines of text, comparing the line length and character width with
the length of the field, and flagging an overflow as a wrapped line. And
do this every time the field got resized and text added or deleted. If
you're dealing with a field with mixed styles then your problems are
ahsoftware at gmail.com
More information about the use-livecode