Re: Combining NSLineBreakByWordWrapping + NSLineBreakByTruncatingTail in NSTextView
Re: Combining NSLineBreakByWordWrapping + NSLineBreakByTruncatingTail in NSTextView
- Subject: Re: Combining NSLineBreakByWordWrapping + NSLineBreakByTruncatingTail in NSTextView
- From: Mattias Arrelid <email@hidden>
- Date: Mon, 3 Mar 2008 17:10:53 +0100
On 28 feb 2008, at 18.45, Aki Inoue wrote:
Starting from Leopard, you can do -[NSCell
setTruncatesLastVisibleLine:] or pass
NSStringDrawingTruncatesLastVisibleLine to -[NSString
drawWithRect:options:attributes:].
We don't have out-of-box support for NSTextView.
If you feel there should be support in NSTextView, please file a bug.
Thanks,
Aki
Well, it certainly feels like something one would like to do (at least
me and Stiles... :)). Filed as radar #5776748.
Thanks
Mattias
On 2008/02/28, at 9:03, John Stiles wrote:
I don't know the answer, but if you figure it out, please post a
followup on Cocoa-Dev. I could use this also :)
Mattias Arrelid wrote:
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 (email@hidden)
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:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden