Re: index of line wrap
Re: index of line wrap
- Subject: Re: index of line wrap
- From: Satoshi Matsumoto <email@hidden>
- Date: Wed, 14 Jan 2004 22:42:53 +0900
Hi,
on 04.1.14 8:45 PM, Benjamin Salanki at email@hidden wrote:
>
is there a way to determine the index of where an NSTextView wraps a
>
given a line that is longer than the NSTextView is wide?
If you know a character index of the line in question, convert it to the
glyph index using following layout manager method.
- (NSRange)glyphRangeForCharacterRange:(NSRange)charRange
actualCharacterRange:(NSRangePointer)actualCharRange;
Then calculate the lineFragmentRect which contains that glyph index.
lineFragmentRect =[layoutManager
lineFragmentRectForGlyphAtIndex:glyphIndex
effectiveRange:&lineGlyphRange];
The character index of the top of line is:
charIndex = [layoutManager
characterIndexForGlyphAtIndex:lineGlyphRange.location];
The character index of the end of line is:
charIndex = [layoutManager
characterIndexForGlyphAtIndex:NSMaxRange(lineGlyphRange)];
Satoshi
-----------------------------------------------------
Satoshi Matsumoto <email@hidden>
816-5 Odake, Odawara, Kanagawa, Japan 256-0802
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.