4 // Created by Doug Dickinson on Sun Jun 01 2003.
5 // Copyright (c) 2003 Doug Dickinson (dasher@DressTheMonkey.plus.com). All rights reserved.
8 #import "TextDocument.h"
9 #import "PreferencesController.h"
11 @implementation TextDocument
21 - (NSString *)windowNibName
23 return @"TextDocument";
26 - (void)windowControllerDidLoadNib:(NSWindowController *) aController
28 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
29 [super windowControllerDidLoadNib:aController];
30 [textUI setFont:[NSFont fontWithName:[defaults stringForKey:EDIT_FONT] size:(float)[defaults integerForKey:EDIT_FONT_SIZE]]];
31 [textUI setString:[[[NSString alloc] initWithData:[self fileContents] encoding:NSMacOSRomanStringEncoding] autorelease]];
32 [self setFileContents:nil];
35 - (NSData *)dataRepresentationOfType:(NSString *)aType
37 return [[textUI string] dataUsingEncoding:NSMacOSRomanStringEncoding];
40 - (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
42 [self setFileContents:data];
46 - (NSData *)fileContents {
50 - (void)setFileContents:(NSData *)newFileContents {
51 if (_fileContents != newFileContents) {
52 NSData *oldValue = _fileContents;
53 _fileContents = [newFileContents retain];
58 - (NSTextView *)textUI
65 [_fileContents release];