Hi there.

Occasionally I need to display some very long strings. These string can have sentences that would span several lines depending on the width of my NSTextView. Example of such texts:

"This is the first line which spans over to the second line and then it stops.

This is another line, note the line break above"

Now, if the size of my text view is not large enough to display all lines, the last word gets truncated so that stuff looks like this (standard behavior):

"This is the first line
which spans over to the
second line and then it"

I'd like to show something like:

"This is the first line
which spans over to the
second line and then..."

I've tried e.g. this:

NSRange range= NSMakeRange(0,[[aView string] length]);
NSTextStorage *textStorage = [aView textStorage];
NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];

[paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
[textStorage addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range];

That doesn't work that good, since it will give me something like:

"This is the first...

"This is another..."

I'd like to somehow use word wrapping, as far as possible, and then, at the last line, truncate the last word. Is this easy to implement? Does anyone have any clues or could point me in some interesting directions?

Thanks
Mattias
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to