Changeset 1521
- Timestamp:
- 08/21/04 18:08:12 (4 years ago)
- Files:
-
- WiredClient/trunk/NSStringAdditions.h (modified) (2 diffs)
- WiredClient/trunk/NSStringAdditions.m (modified) (2 diffs)
- WiredClient/trunk/WCConsole.h (modified) (3 diffs)
- WiredClient/trunk/WCConsole.m (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredClient/trunk/NSStringAdditions.h
r1360 r1521 1 /* $Id: NSStringAdditions.h,v 1. 9 2004/06/10 10:43:54morris Exp $ */1 /* $Id: NSStringAdditions.h,v 1.10 2004/08/21 16:08:12 morris Exp $ */ 2 2 3 3 /* … … 38 38 - (unsigned int) UTF8StringLength; 39 39 40 - (NSString *) stringByReplacingOccurencesOfString:(NSString *)target withString:(NSString *)replacement; 41 - (NSString *) stringByReplacingOccurencesOfStrings:(NSArray *)targets withString:(NSString *)replacement; 42 40 43 @end 41 44 WiredClient/trunk/NSStringAdditions.m
r1360 r1521 1 /* $Id: NSStringAdditions.m,v 1.1 2 2004/06/10 10:43:54morris Exp $ */1 /* $Id: NSStringAdditions.m,v 1.13 2004/08/21 16:08:12 morris Exp $ */ 2 2 3 3 /* … … 65 65 } 66 66 67 68 69 - (NSString *)stringByReplacingOccurencesOfString:(NSString *)target withString:(NSString *)replacement { 70 NSMutableString *string; 71 NSRange range; 72 73 string = [NSMutableString stringWithString:self]; 74 range = NSMakeRange(0, [string length]); 75 76 [string replaceOccurrencesOfString:target withString:replacement options:0 range:range]; 77 78 return [NSString stringWithString:string]; 79 } 80 81 82 83 - (NSString *)stringByReplacingOccurencesOfStrings:(NSArray *)targets withString:(NSString *)replacement { 84 NSMutableString *string; 85 NSEnumerator *enumerator; 86 NSString *target; 87 NSRange range; 88 89 string = [NSMutableString stringWithString:self]; 90 range = NSMakeRange(0, [string length]); 91 enumerator = [targets objectEnumerator]; 92 93 while((target = [enumerator nextObject])) 94 [string replaceOccurrencesOfString:target withString:replacement options:0 range:range]; 95 96 return [NSString stringWithString:string]; 97 } 98 67 99 @end 68 100 WiredClient/trunk/WCConsole.h
r1514 r1521 1 /* $Id: WCConsole.h,v 1. 2 2004/08/21 11:43:33morris Exp $ */1 /* $Id: WCConsole.h,v 1.3 2004/08/21 16:08:12 morris Exp $ */ 2 2 3 3 /* … … 33 33 @interface WCConsole : WCWindowController { 34 34 IBOutlet NSTextView *_consoleTextView; 35 IBOutlet NSScrollView *_consoleScrollView; 35 36 } 36 37 … … 38 39 - (id) initWithConnection:(WCConnection *)connection; 39 40 40 - (NSString *) stringByReplacingSeparators:(NSString *)string;41 41 - (void) logInput:(NSString *)string; 42 42 - (void) logOutput:(NSString *)string; WiredClient/trunk/WCConsole.m
r1514 r1521 1 /* $Id: WCConsole.m,v 1. 9 2004/08/21 11:43:33morris Exp $ */1 /* $Id: WCConsole.m,v 1.10 2004/08/21 16:08:12 morris Exp $ */ 2 2 3 3 /* … … 27 27 */ 28 28 29 #import "NSStringAdditions.h" 29 30 #import "WCConnection.h" 30 31 #import "WCConsole.h" … … 124 125 #pragma mark - 125 126 126 - (NSString *)stringByReplacingSeparators:(NSString *)string { 127 NSMutableString *mutableString; 128 NSRange range; 127 - (void)logInput:(NSString *)string { 128 NSString *input; 129 129 130 range = NSMakeRange(0, [string length]); 131 mutableString = [string mutableCopy]; 130 input = [string stringByReplacingOccurencesOfStrings:[NSArray arrayWithObjects: 131 WCFieldSeparator, WCGroupSeparator, WCRecordSeparator, NULL] 132 withString:@"\t"]; 132 133 133 [mutableString replaceOccurrencesOfString:WCFieldSeparator withString:@"\t" options:0 range:range]; 134 [mutableString replaceOccurrencesOfString:WCGroupSeparator withString:@"\t" options:0 range:range]; 135 [mutableString replaceOccurrencesOfString:WCRecordSeparator withString:@"\t" options:0 range:range]; 136 [mutableString appendString:@"\n"]; 137 138 return [mutableString autorelease]; 139 } 140 141 142 143 - (void)logInput:(NSString *)string { 144 [self log:[self stringByReplacingSeparators:string] color:[NSColor blueColor]]; 134 [self log:input color:[NSColor blueColor]]; 145 135 } 146 136 … … 148 138 149 139 - (void)logOutput:(NSString *)string { 150 [self log:[self stringByReplacingSeparators:string] color:[NSColor blackColor]]; 140 NSString *output; 141 142 output = [string stringByReplacingOccurencesOfStrings:[NSArray arrayWithObjects: 143 WCFieldSeparator, WCGroupSeparator, WCRecordSeparator, NULL] 144 withString:@"\t"]; 145 146 [self log:output color:[NSColor blackColor]]; 151 147 } 152 148 … … 165 161 166 162 // --- print 163 if([[_consoleTextView textStorage] length] > 0) 164 [[[_consoleTextView textStorage] mutableString] appendString:@"\n"]; 165 167 166 [[_consoleTextView textStorage] appendAttributedString:attributedString]; 168 167 169 168 // --- scroll with it 170 [_consoleTextView scrollRangeToVisible:NSMakeRange([[_consoleTextView textStorage] length], 0)]; 169 if([[_consoleScrollView verticalScroller] floatValue] == 1.0) { 170 [_consoleTextView scrollRangeToVisible: 171 NSMakeRange([[_consoleTextView textStorage] length], 0)]; 172 } 171 173 172 174 // --- release
