Re: getting visible character range
Re: getting visible character range
- Subject: Re: getting visible character range
- From: Douglas Davidson <email@hidden>
- Date: Mon, 6 Feb 2006 09:25:07 -0800
On Feb 5, 2006, at 11:07 AM, Aleaxander Cohen wrote:
I'm trying to get the visible character range from a NSTextView and
then, from the first visible character, move back to the first
white space, and from the last character, move to the next
whitespace. How can i get that range?
1) Get the visibleRect of the view.
2) Convert it to container coordinates by subtracting the
textContainerOrigin from the rect's origin.
3) Ask the layout manager for the
glyphRangeForBoundingRect:inTextContainer:.
4) Convert the glyph range to a character range with
characterRangeForGlyphRange:actualGlyphRange:.
5) I'm not sure exactly what you want when you speak of whitespace,
but you might consider nextWordFromIndex:forward:.
Douglas Davidson
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden