Re: end of paragraph in NSTextView
Re: end of paragraph in NSTextView
- Subject: Re: end of paragraph in NSTextView
- From: Mark Munz <email@hidden>
- Date: Mon, 26 Apr 2004 13:52:00 -0600
On Apr 26, 2004, at 1:53 PM, Douglas Davidson wrote:
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
Thanks for the info.
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.
For the record, I said NSTextView, I should have said that it was
NSMutableAttributedStrings I'm working with. My bad on that. Just so
there is no confusion.
Am I correct in assuming that the text could have any variation of
CR+LF or LF or CR or Unicode Paragraph Sep in it? I can make
adjustments for it if that's the case, I'm just trying to understand
it. I can make the right adjustments like pre-flighting the text and
standardizing the end-of-paragraphs to a single format. At least until
I can require Panther. :-)
Thanks.
Mark Munz
_______________________________________________
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.