1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 16:52:39 +00:00

Log window now indents none-first lines.

This commit is contained in:
Mitchell Livingston 2006-08-22 19:50:45 +00:00
parent 5ee5fb30e5
commit 368e7b4c4e
3 changed files with 11 additions and 7 deletions

View file

@ -39,8 +39,13 @@
{ {
fTimer = [NSTimer scheduledTimerWithTimeInterval: UPDATE_SECONDS target: self fTimer = [NSTimer scheduledTimerWithTimeInterval: UPDATE_SECONDS target: self
selector: @selector(updateLog:) userInfo: nil repeats: YES]; selector: @selector(updateLog:) userInfo: nil repeats: YES];
fAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: [NSFont fontWithName: @"Monaco" size: 10],
NSFontAttributeName, nil]; NSMutableParagraphStyle * paragraph = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraph setHeadIndent: 20.0];
fAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSFont fontWithName: @"Monaco" size: 10], NSFontAttributeName,
paragraph, NSParagraphStyleAttributeName, nil];
[[self window] update]; //make sure nib is loaded right away [[self window] update]; //make sure nib is loaded right away
} }
@ -85,9 +90,8 @@
NSScroller * scroller = [fScrollView verticalScroller]; NSScroller * scroller = [fScrollView verticalScroller];
BOOL shouldScroll = [scroller floatValue] == 1.0 || [scroller isHidden] || [scroller knobProportion] == 1.0; BOOL shouldScroll = [scroller floatValue] == 1.0 || [scroller isHidden] || [scroller knobProportion] == 1.0;
NSAttributedString * messageString; NSMutableAttributedString * messageString;
NSString * levelString; NSString * levelString, * dateString;
NSCalendarDate * dateString;
for (currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next) for (currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
{ {
//new line if text view is not empty //new line if text view is not empty
@ -106,8 +110,8 @@
levelString = @"???"; levelString = @"???";
dateString = [[NSDate dateWithTimeIntervalSince1970: currentMessage->when] dateString = [[NSDate dateWithTimeIntervalSince1970: currentMessage->when]
dateWithCalendarFormat: @"%1m/%d %H:%M:%S" timeZone: nil]; descriptionWithCalendarFormat: @"%1m/%d %H:%M:%S" timeZone: nil locale: nil];
messageString = [[[NSAttributedString alloc] initWithString: [NSString stringWithFormat: @"%@ %@ %s", messageString = [[[NSMutableAttributedString alloc] initWithString: [NSString stringWithFormat: @"%@ %@ %s",
dateString, levelString, currentMessage->message] attributes: fAttributes] autorelease]; dateString, levelString, currentMessage->message] attributes: fAttributes] autorelease];
[[fTextView textStorage] appendAttributedString: messageString]; [[fTextView textStorage] appendAttributedString: messageString];