diff --git a/objc-appscript/trunk/src/Appscript/objectrenderer.h b/objc-appscript/trunk/src/Appscript/objectrenderer.h index dfe840a..36c7f13 100644 --- a/objc-appscript/trunk/src/Appscript/objectrenderer.h +++ b/objc-appscript/trunk/src/Appscript/objectrenderer.h @@ -12,5 +12,7 @@ +(NSString *)formatObject:(id)obj; ++(void)setDataDescriptionTruncation:(NSUInteger)maxBytes; + @end diff --git a/objc-appscript/trunk/src/Appscript/objectrenderer.m b/objc-appscript/trunk/src/Appscript/objectrenderer.m index 13de80d..4765b50 100644 --- a/objc-appscript/trunk/src/Appscript/objectrenderer.m +++ b/objc-appscript/trunk/src/Appscript/objectrenderer.m @@ -5,6 +5,7 @@ #import "objectrenderer.h" +static NSUInteger dataDescriptionTruncation = (NSUInteger)-1; @implementation AEMObjectRenderer @@ -103,8 +104,26 @@ +(void)formatObject:(id)obj indent:(NSString *)indent result:(NSMutableString *) [self formatObject: [obj description] indent: @"" result: result]; [result appendString: @"]"]; - } else - [result appendFormat: @"%@", obj]; + } else if ([obj isKindOfClass:[NSAppleEventDescriptor class]]) { + NSString *s = [obj description]; + if ([s hasPrefix:@" dataDescriptionTruncation) { + s = [NSString stringWithFormat:@"%@%d:$%@...$%@", + [bits objectAtIndex:0], + (int)length / 2, + [d substringToIndex:dataDescriptionTruncation * 2], + [bits objectAtIndex:2]]; + } + } + } + [result appendString:s]; + } else { + [result appendFormat:@"%@", obj]; + } } @@ -117,5 +136,8 @@ +(NSString *)formatObject:(id)obj { return result; } ++(void)setDataDescriptionTruncation:(NSUInteger)maxBytes { + dataDescriptionTruncation = maxBytes; +} @end