Skip to content

Commit

Permalink
Truncate details using NSLineBreakByTruncatingMiddle
Browse files Browse the repository at this point in the history
  • Loading branch information
pjrobertson committed Oct 16, 2012
1 parent 0ed19f0 commit ce9e6e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 424 deletions.
1 change: 0 additions & 1 deletion Quicksilver/Code-QuickStepInterface/QSObjectCell.h
Expand Up @@ -17,7 +17,6 @@
NSDictionary *nameAttributes; NSDictionary *nameAttributes;
NSDictionary *detailsAttributes; NSDictionary *detailsAttributes;
NSDictionary *rankedNameAttributes; NSDictionary *rankedNameAttributes;
NSRect lastFrame;
NSTextView *fieldEditor; NSTextView *fieldEditor;
} }


Expand Down
9 changes: 3 additions & 6 deletions Quicksilver/Code-QuickStepInterface/QSObjectCell.m
Expand Up @@ -389,7 +389,7 @@ - (void)drawIconForObject:(QSObject *)object withFrame:(NSRect)cellFrame inView:
- (void)buildStylesForFrame:(NSRect)cellFrame inView:(NSView *)controlView { - (void)buildStylesForFrame:(NSRect)cellFrame inView:(NSView *)controlView {


NSMutableParagraphStyle *style = [[[NSMutableParagraphStyle alloc] init] autorelease]; NSMutableParagraphStyle *style = [[[NSMutableParagraphStyle alloc] init] autorelease];
[style setLineBreakMode:NSLineBreakByTruncatingTail]; [style setLineBreakMode:NSLineBreakByTruncatingMiddle];
[style setFirstLineHeadIndent:1.0]; [style setFirstLineHeadIndent:1.0];
[style setHeadIndent:1.0]; [style setHeadIndent:1.0];
[style setAlignment:[self alignment]]; [style setAlignment:[self alignment]];
Expand Down Expand Up @@ -498,12 +498,9 @@ - (void)drawTextForObject:(QSObject *)drawObject withFrame:(NSRect)cellFrame inV


CGFloat detailHeight = NSHeight(textDrawRect) -nameSize.height; CGFloat detailHeight = NSHeight(textDrawRect) -nameSize.height;
NSRange returnRange; NSRange returnRange;
if (detailHeight<detailsSize.height && (returnRange = [detailsString rangeOfString:@"\n"]) .location != NSNotFound) if (detailHeight<detailsSize.height && (returnRange = [detailsString rangeOfString:@"\n"]) .location != NSNotFound) {
detailsString = [detailsString substringToIndex:returnRange.location]; detailsString = [detailsString substringToIndex:returnRange.location];
if ([detailsString length] >100) detailsString = [detailsString substringWithRange:NSMakeRange(0, 100)]; }
// ***warning ** this should take first line only?
//if ([titleString length]) [titleString appendAttributedString:;

} }
} }


Expand Down

0 comments on commit ce9e6e6

Please sign in to comment.