How to tell a line from a paragraph?
J. Landman Gay
jacque at hyperactivesw.com
Wed Nov 2 19:29:23 EST 2005
Michael wrote:
> Hi:
>
> Is it possible to determine on which "line" a word resides in a text field,
> where a line is defined not as a cr-delimited paragraph but as a "row" in
> the field's display?
I wrote a function a while back that tells how many visible lines are in
a field, regardless of text wrap:
function getFldLines tFld -- get the actual number of visible lines in a
scrolling field
-- regardless of whether they are wrapped or not.
-- by J. Landman Gay
put the textheight of fld tFld into txHeight
if the style of fld tFld = "scrolling" then put the scroll of fld
tFld into theScroll
select after text of fld tFld -- scroll to bottom
get item 2 of the selectedLoc
put it - the top of fld tFld + the scroll of fld tFld into pix
select empty
if the style of fld tFld = "scrolling" then set the scroll of fld
tFld to theScroll
return pix div txHeight
end getFldLines
Watch out for wrapped lines in the above. You could probably modify this
to do what you want. You'd have to select before or after the word
you're looking for and use that selectedloc for the calculation rather
than scrolling to the end of the field and clicking there. If I had more
time I'd work it out for you, but let us know if you get stuck and maybe
I can fiddle with it when I get back later.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list