• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: index of line wrap
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >index of line wrap (From: Benjámin Salánki <email@hidden>)

  • Prev by Date: [ANN : my new application is out]
  • Next by Date: crash on quit
  • Previous by thread: index of line wrap
  • Next by thread: NSAutoreleasePool
  • Index(es):
    • Date
    • Thread