Changeset 829
- Timestamp:
- Aug 24, 2006, 1:55:09 AM (17 years ago)
- Location:
- trunk/macosx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/MessageWindowController.h
r828 r829 34 34 NSTimer * fTimer; 35 35 NSDictionary * fAttributes; 36 37 int fLines; 36 38 } 37 39 -
trunk/macosx/MessageWindowController.m
r828 r829 30 30 #define LEVEL_DEBUG 2 31 31 32 #define UPDATE_SECONDS 0.35 32 #define UPDATE_SECONDS 0.35 33 #define MAX_LINES 1000 33 34 34 35 @implementation MessageWindowController … … 38 39 if ((self = [super initWithWindowNibName: name])) 39 40 { 40 fTimer = [NSTimer scheduledTimerWithTimeInterval: UPDATE_SECONDS target: self41 selector: @selector(updateLog:) userInfo: nil repeats: YES];42 43 41 NSMutableParagraphStyle * paragraph = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy]; 44 42 [paragraph setHeadIndent: 20.0]; … … 48 46 paragraph, NSParagraphStyleAttributeName, nil]; 49 47 [paragraph release]; 48 49 fLines = 0; 50 51 fTimer = [NSTimer scheduledTimerWithTimeInterval: UPDATE_SECONDS target: self 52 selector: @selector(updateLog:) userInfo: nil repeats: YES]; 50 53 51 54 [[self window] update]; //make sure nib is loaded right away … … 92 95 BOOL shouldScroll = [scroller floatValue] == 1.0 || [scroller isHidden] || [scroller knobProportion] == 1.0; 93 96 94 NSAttributedString * messageString; 95 NSString * levelString, * dateString; 97 NSString * levelString, * dateString, * messageString; 96 98 for (currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next) 97 99 { 98 //new line if text view is not empty99 if (currentMessage != messages || ![[fTextView string] isEqualToString: @""])100 [[fTextView textStorage] appendAttributedString: [[[NSAttributedString alloc]101 initWithString: @"\n" attributes: fAttributes] autorelease]];102 103 100 int level = currentMessage->level; 104 101 if (level == TR_MSG_ERR) … … 113 110 dateString = [[NSDate dateWithTimeIntervalSince1970: currentMessage->when] 114 111 descriptionWithCalendarFormat: @"%1m/%d %H:%M:%S" timeZone: nil locale: nil]; 115 messageString = [ [[NSAttributedString alloc] initWithString: [NSString stringWithFormat: @"%@ %@ %s",116 dateString, levelString, currentMessage->message] attributes: fAttributes] autorelease];112 messageString = [NSString stringWithFormat: @"%s%@ %@ %s", 113 fLines > 0 ? "\n" : "", dateString, levelString, currentMessage->message]; 117 114 118 [[fTextView textStorage] appendAttributedString: messageString]; 115 //remove the first line if at max number of lines 116 if (fLines == MAX_LINES) 117 { 118 NSString * text = [fTextView string]; 119 unsigned int loc = [text rangeOfString: @"\n"].location; 120 if (loc != NSNotFound) 121 [fTextView setString: [[text substringFromIndex: loc + 1] stringByAppendingString: messageString]]; 122 } 123 else 124 { 125 [[fTextView textStorage] appendAttributedString: [[[NSAttributedString alloc] initWithString: 126 messageString attributes: fAttributes] autorelease]]; 127 fLines++; 128 } 119 129 } 120 130 … … 144 154 { 145 155 [fTextView setString: @""]; 156 fLines = 0; 146 157 } 147 158
Note: See TracChangeset
for help on using the changeset viewer.