Line numbers for soft-wrapped styled text?
jiml at netrin.com
Wed Mar 29 20:20:01 CEST 2017
> 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.
Now that I think about it, I’ve overcomplicated things.
You don’t need two fields at all.
Just set the liststyle of the field that contains your editable text to ‘decimal’.
Then the lines will be automatically numbered and outdented.
Yet conveniently, the ’text’ and the ‘styledtext’ runs will not ‘contain' the numbering since it is a styling.
Of course, this still doesn’t allow you to get rid of the trailing period on the numbers.
More information about the use-livecode