Browse CVS Repository
Contents of /undmail/guiproto/LineTextFormatter.m
Parent Directory
| Revision Log
| Revision Graph
Revision 1.1 -
( show annotations)
( download)
Fri Feb 14 16:50:14 2003 UTC
(21 years, 1 month ago)
by footashida
Branch: MAIN
CVS Tags: HEAD
*** empty log message ***
| 1 |
#import "LineTextFormatter.h" |
| 2 |
|
| 3 |
|
| 4 |
@implementation LineTextFormatter |
| 5 |
-(NSAttributedString *)formatWithAttributedString: |
| 6 |
(NSAttributedString *)attributedString{ |
| 7 |
NSString *string; |
| 8 |
NSMutableAttributedString *ret; |
| 9 |
NSRange lineRange; |
| 10 |
NSRange stringRange; |
| 11 |
|
| 12 |
ret = [[[NSMutableAttributedString alloc] init] autorelease]; |
| 13 |
[ret appendAttributedString:attributedString]; |
| 14 |
string = [attributedString string]; |
| 15 |
|
| 16 |
// patternが空文字列の場合はすべてに適用する。 |
| 17 |
string = [attributedString string]; |
| 18 |
if([_pattern isEqual:@""]){ |
| 19 |
[ret setAttributes:[self attributedDictionary] |
| 20 |
range:NSMakeRange(0, [string length])]; |
| 21 |
return ret; |
| 22 |
} |
| 23 |
stringRange = NSMakeRange(0, [string length]); |
| 24 |
while(stringRange.length > 0){ |
| 25 |
lineRange = [string lineRangeForRange:NSMakeRange(stringRange.location, 0)]; |
| 26 |
if([[string substringWithRange:lineRange] hasPrefix:_pattern]){ |
| 27 |
[ret setAttributes:[self attributedDictionary] range:lineRange]; |
| 28 |
} |
| 29 |
stringRange.location = NSMaxRange(lineRange); |
| 30 |
stringRange.length -= lineRange.length; |
| 31 |
} |
| 32 |
return ret; |
| 33 |
} |
| 34 |
|
| 35 |
@end |
|