Changeset 3035


Ignore:
Timestamp:
Sep 10, 2007, 7:28:15 PM (15 years ago)
Author:
livings124
Message:

get writing message log to a file working again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/MessageWindowController.m

    r3034 r3035  
    106106        return;
    107107   
    108     //keep scrolled to bottom if already at bottom or there is no scroll bar yet
    109     NSScroller * scroller = [fScrollView verticalScroller];
    110     BOOL shouldScroll = [scroller floatValue] == 1.0 || [scroller isHidden] || [scroller knobProportion] == 1.0;
    111    
    112     NSString * levelString, * dateString, * messageString;
     108    NSString * levelString;
    113109    for (currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
    114110    {
     
    145141   
    146142    tr_freeMessageList(messages);
    147    
    148     /*if (shouldScroll)
    149         [fTextView scrollRangeToVisible: NSMakeRange([[fTextView string] length], 0)];*/
    150143}
    151144
     
    200193- (void) writeToFile: (id) sender
    201194{
    202     /*NSString * string = [[fTextView string] retain];
     195    //create the text to output
     196    NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [fMessages count]];
     197   
     198    NSEnumerator * enumerator = [fMessages objectEnumerator];
     199    NSDictionary * message;
     200    while ((message = [enumerator nextObject]))
     201        [messageStrings addObject: [self stringForMessage: message]];
     202   
     203    NSString * fileString = [[messageStrings componentsJoinedByString: @"\n"] retain];
    203204   
    204205    NSSavePanel * panel = [NSSavePanel savePanel];
     
    208209    [panel beginSheetForDirectory: nil file: NSLocalizedString(@"untitled", "Save log panel -> default file name")
    209210            modalForWindow: [self window] modalDelegate: self
    210             didEndSelector: @selector(writeToFileSheetClosed:returnCode:contextInfo:) contextInfo: string];*/
     211            didEndSelector: @selector(writeToFileSheetClosed:returnCode:contextInfo:) contextInfo: fileString];
    211212}
    212213
    213214- (void) writeToFileSheetClosed: (NSSavePanel *) panel returnCode: (int) code contextInfo: (NSString *) string
    214215{
    215     /*if (code == NSOKButton)
     216    if (code == NSOKButton)
    216217    {
    217218        if (![string writeToFile: [panel filename] atomically: YES encoding: NSUTF8StringEncoding error: nil])
     
    231232    }
    232233   
    233     [string release];*/
     234    [string release];
    234235}
    235236
     
    240241- (NSString *) stringForMessage: (NSDictionary *) message
    241242{
    242     return [NSString stringWithFormat: @"%@\n%@\n\n%@", [message objectForKey: @"Date"],
     243    return [NSString stringWithFormat: @"%@ %@ %@", [message objectForKey: @"Date"],
    243244                [message objectForKey: @"Level"], [message objectForKey: @"Message"]];
    244245}
Note: See TracChangeset for help on using the changeset viewer.