mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-28 01:09:39 +03:00
7b2694e9f6
svn path=/trunk/netsurf/; revision=11490
33 lines
815 B
Objective-C
33 lines
815 B
Objective-C
//
|
|
// NSString_AITruncation.m
|
|
// PSMTabBarControl
|
|
//
|
|
// Created by Evan Schoenberg on 7/14/07.
|
|
// From Adium, which is licensed under the GPL. Used in PSMTabBarControl with permission.
|
|
// The contents of this remain licensed under the GPL.
|
|
//
|
|
|
|
#import "NSString_AITruncation.h"
|
|
|
|
@implementation NSString (AITruncation)
|
|
|
|
+ (id)ellipsis {
|
|
return [NSString stringWithUTF8String:"\xE2\x80\xA6"];
|
|
}
|
|
|
|
- (NSString *)stringWithEllipsisByTruncatingToLength:(NSUInteger)length {
|
|
NSString *returnString;
|
|
|
|
if(length < [self length]) {
|
|
//Truncate and append the ellipsis
|
|
returnString = [[self substringToIndex:length - 1] stringByAppendingString:[NSString ellipsis]];
|
|
} else {
|
|
//We don't need to truncate, so don't append an ellipsis
|
|
returnString = [[self copy] autorelease];
|
|
}
|
|
|
|
return returnString;
|
|
}
|
|
|
|
@end
|