Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions objc-appscript/trunk/src/Appscript/objectrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@

+(NSString *)formatObject:(id)obj;

+(void)setDataDescriptionTruncation:(NSUInteger)maxBytes;

@end

26 changes: 24 additions & 2 deletions objc-appscript/trunk/src/Appscript/objectrenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#import "objectrenderer.h"

static NSUInteger dataDescriptionTruncation = (NSUInteger)-1;

@implementation AEMObjectRenderer

Expand Down Expand Up @@ -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:@"<NSAppleEventDescriptor:"]) {
NSArray *bits = [s componentsSeparatedByString:@"$"];
if ([bits count] == 3) {
NSString *d = [bits objectAtIndex:1];
NSUInteger length = [d length];
if (length / 2 > 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];
}
}


Expand All @@ -117,5 +136,8 @@ +(NSString *)formatObject:(id)obj {
return result;
}

+(void)setDataDescriptionTruncation:(NSUInteger)maxBytes {
dataDescriptionTruncation = maxBytes;
}

@end