Re: Combining NSLineBreakByWordWrapping + NSLineBreakByTruncatingTail in NSTextView
Re: Combining NSLineBreakByWordWrapping + NSLineBreakByTruncatingTail in NSTextView
- Subject: Re: Combining NSLineBreakByWordWrapping + NSLineBreakByTruncatingTail in NSTextView
- From: Aki Inoue <email@hidden>
- Date: Thu, 28 Feb 2008 09:45:06 -0800
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
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