-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathXMLLog.m
50 lines (45 loc) · 1.62 KB
/
XMLLog.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// XMLLog.m
// Jabber
//
// Created by David Chisnall on 12/08/2005.
// Copyright 2005 __MyCompanyName__. All rights reserved.
//
#import "XMLLog.h"
#import "JabberApp.h"
#import <EtoileFoundation/EtoileFoundation.h>
static NSDictionary * inColour;
static NSDictionary * outColour;
@implementation XMLLog
+ (void) initialize
{
inColour = [NSDictionary dictionaryWithObject:[NSColor colorWithCalibratedRed:0.0f
green:0.0f
blue:1.0f
alpha:1.0f]
forKey:NSForegroundColorAttributeName];
outColour = [NSDictionary dictionaryWithObject:[NSColor colorWithCalibratedRed:1.0f
green:0.0f
blue:0.0f
alpha:1.0f]
forKey:NSForegroundColorAttributeName];
}
+ (void) logIncomingXML:(NSString*)xml
{
NSTextView * textView = [(JabberApp*)[NSApp delegate] xmlLogBox];
NSString * inXML = [NSString stringWithFormat:@"IN:\n%@\n\n", xml];
[[textView textStorage] appendAttributedString:[[NSAttributedString alloc] initWithString:inXML
attributes:inColour]];
[textView display];
[textView scrollRangeToVisible:NSMakeRange([[textView textStorage] length],0)];
}
+ (void) logOutgoingXML:(NSString*)xml
{
NSTextView * textView = [(JabberApp*)[NSApp delegate] xmlLogBox];
NSString * outXML = [NSString stringWithFormat:@"OUT:\n%@\n\n", xml];
[[textView textStorage] appendAttributedString:[[NSAttributedString alloc] initWithString:outXML
attributes:outColour]];
[textView display];
[textView scrollRangeToVisible:NSMakeRange([[textView textStorage] length],0)];
}
@end