Re: end of paragraph in NSTextView
Re: end of paragraph in NSTextView
- Subject: Re: end of paragraph in NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Mon, 26 Apr 2004 12:53:12 -0700
On Apr 26, 2004, at 12:18 PM, Mark Munz wrote:
Does anyone know if NSTextView allows \r (0x0D) in the text it uses to
make end of paragraph? Or is this tied to the reading of the text file
into an NSString? For some reason they don't seem to be showing up on
plain text that I'm munging.
It seems like all the carriage returns are converted to LFs (\n), but
I wanted to make sure this is truly the case. If I'm trying to count
paragraphs (ie. number of returns), should I be looking for all the
alternatives (\n, \r, unicode)?
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.
Douglas Davidson
_______________________________________________
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.