Re: end of paragraph in NSTextView
Re: end of paragraph in NSTextView
- Subject: Re: end of paragraph in NSTextView
- From: Jim Correia <email@hidden>
- Date: Mon, 26 Apr 2004 16:24:44 -0400
On Apr 26, 2004, at 3:52 PM, Mark Munz wrote:
On Apr 26, 2004, at 1:53 PM, Douglas Davidson wrote:
If you are trying to count paragraphs, you should be using
- (NSRange)paragraphRangeForRange:(NSRange)paragraphRange;
or the more detailed
- (void)getParagraphStart:(unsigned *)startPtr end:(unsigned *)endPtr
contentsEnd:(unsigned *)contentsEntPtr forRange:(NSRange)range;
which gives you information about the location and length of the
paragraph separator. Either of these will take into account carriage
returns, line feeds, carriage return/line feed combinations, the
Unicode paragraph separator, and the end of the text. This is what
the Cocoa text system uses internally; it will allow existing
paragraph breaks of any of these types, although when it generates a
paragraph break it uses \n. You may be encountering the quirk that
carriage return followed by line feed is counted as a single
paragraph break, due to the Windows convention.
Unfortunately, these two calls only work on Panther which is bad for
me (for the moment). I'm targeting 10.2.8 or later with my App. This
may change, but for now I haven't been able to use any Panther only
features for my project.
But getLineStart:end:contentsEnd:forRange: works on older release.
From what I can tell, the docs don't clearly define the difference
between lines and paragraphs.
The release notes say:
We now clearly make a distinction between paragraph separators and
line separators. The following methods can be used to find paragraph
boundaries in a string:
- (void)getParagraphStart:(unsigned *)startPtr
end:(unsigned *)parEndPtr
contentsEnd:(unsigned *)contentsEndPtr
forRange:(NSRange)range;
- (NSRange)paragraphRangeForRange:(NSRange)range;
These parallel the existing line range equivalents, but which take
into account only paragraph separators and not all line separators.
The methods getLineStart:end:contentsEnd:forRange: and
lineRangeForRange: now treat U0085 (NEXT LINE) as a line separator
character.
What paragraph separators does the new method consider?
Mark - I maybe the older getLineStart:end:contentsEnd:forRange: method
will meet your needs?
Jim
_______________________________________________
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.