On Jun 25, 2010, at 7:37 PM, Alex Tweedly wrote:
The straightforward answer is using formattedText ..... but the
deeper question is what line numbering you want for the lines when
there is line-wrapping happening. For instance, if it is something
like a source code editor, then the line numbers (IMHO) should be
independent of the size of window currenty in use.
For example, if I have the following text
1 My first line
2 this is a very long line of text that is going to be wrapped in a
moment when I make the window narrow.
3 third line.
Then when the window becomes narrow, do I *want*
1 My first line
2 this is a very long line of text that is going to be wrapped
3 in a moment when I make the window narrow.
4 third line.
or do I want something like
1 My first line
2 this is a very long line of text that is going to be wrapped
2a in a moment when I make the window narrow.
3 third line.
It really depends on whether you are numbering the lines of the
window or the lines of the underlying text (or source code, or
whatever); quite often, I suspect, it should be the latter. And in
that case I don't know of any quick or easy way to figure out how
the numbering should be done :-(
-- Alex.
In the latter case, the easiest way to approach the problem is to
place the line numbers into the field itself with a tab delimiter.
It's easy to get something like:
1 My first line
2 this is a very long line of text that is going to be wrapped
in a moment when I make the window narrow. <--------
3 third line.
(If you need the "2a" option, not so easy.)
Then script around the problem of fetching text from the field by
something like:
function getlinetext lineNbrStart, lineNbrEnd
set the itemdelimiter to tab
repeat with n = lineNbrStart to lineNbrEnd
put (item 2 of line n of fld "text") & cr after textList
end repeat
return char 1 to -2 of textList
end getlinetext
This doesn't avoid messiness in what happens when the user selects
text in the field, but could be useful in some contexts, eg, a list
field. The Rev IDE script editor uses two fields and doesn't try to
sort out line wrapping -- the script field is dontwrap = true.
If the rumors about a major revamping of the field object are true,
maybe we can have built-in functions that give both the clickLine and
the "formattedClickLine" -- ie, the line marked by the arrow in the
example above would be clickline = 2, formattedclickline = 3
-- Peter
Peter M. Brigham
[email protected]
http://home.comcast.net/~pmbrig
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution