Fix the detection of ANSI code
This commit is contained in:
parent
c9acccaddc
commit
eab3342065
1 changed files with 4 additions and 4 deletions
|
@ -106,7 +106,7 @@
|
||||||
@implementation NSString (ANSI)
|
@implementation NSString (ANSI)
|
||||||
|
|
||||||
- (BOOL)containsANSICodes {
|
- (BOOL)containsANSICodes {
|
||||||
return [self rangeOfString:@"\\033["].location != NSNotFound;
|
return [self rangeOfString:@"\033["].location != NSNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMutableAttributedString*)attributedStringParsingANSICodes {
|
- (NSMutableAttributedString*)attributedStringParsingANSICodes {
|
||||||
|
@ -114,10 +114,10 @@
|
||||||
|
|
||||||
base::scoped_nsobject<NSMutableDictionary> attributes(
|
base::scoped_nsobject<NSMutableDictionary> attributes(
|
||||||
[[NSMutableDictionary alloc] init]);
|
[[NSMutableDictionary alloc] init]);
|
||||||
NSArray* parts = [self componentsSeparatedByString:@"\\033["];
|
NSArray* parts = [self componentsSeparatedByString:@"\033["];
|
||||||
[result appendAttributedString:[[[NSAttributedString alloc]
|
[result appendAttributedString:[[[NSAttributedString alloc]
|
||||||
initWithString:parts.firstObject
|
initWithString:parts.firstObject
|
||||||
attributes:nil] autorelease]];
|
attributes:nil] autorelease]];
|
||||||
|
|
||||||
for (NSString* part in [parts subarrayWithRange:NSMakeRange(1, parts.count - 1)]) {
|
for (NSString* part in [parts subarrayWithRange:NSMakeRange(1, parts.count - 1)]) {
|
||||||
if (part.length == 0)
|
if (part.length == 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue