Archive Project
This commit is contained in:
49
Brainfuck/AppDelegate.m
Executable file
49
Brainfuck/AppDelegate.m
Executable file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// AppDelegate.m
|
||||
// Brainfuck
|
||||
//
|
||||
// Created by Kim Wittenburg on 20.05.13.
|
||||
// Copyright (c) 2013 brainfuck. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#define Color(r,g,b) [NSArchiver archivedDataWithRootObject:[NSColor colorWithCalibratedRed:r green:g blue:b alpha:1.0]]
|
||||
#define WhiteColor(white) [NSArchiver archivedDataWithRootObject:[NSColor colorWithCalibratedWhite:white alpha:1.0]]
|
||||
#define DefaultColor(color) [NSArchiver archivedDataWithRootObject:[NSColor color]]
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
#pragma mark - Application delegate
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
NSMutableDictionary *defaults = [NSMutableDictionary dictionaryWithCapacity:9];
|
||||
[defaults setObject:WhiteColor(0.333333) forKey:@"default"];
|
||||
[defaults setObject:Color(11/255.0, 86/255.0, 2/255.0) forKey:@"\\+"];
|
||||
[defaults setObject:Color(11/255.0, 86/255.0, 2/255.0) forKey:@"\\-"];
|
||||
[defaults setObject:Color(0.0, 0.0, 83/255.0) forKey:@"\\<"];
|
||||
[defaults setObject:Color(0.0, 0.0, 83/255.0) forKey:@"\\>"];
|
||||
[defaults setObject:Color(82/255.0, 0.0, 2/255.0) forKey:@"\\["];
|
||||
[defaults setObject:Color(82/255.0, 0.0, 2/255.0) forKey:@"\\]"];
|
||||
[defaults setObject:DefaultColor(blackColor) forKey:@"\\."];
|
||||
[defaults setObject:DefaultColor(blackColor) forKey:@"\\,"];
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
|
||||
}
|
||||
|
||||
- (IBAction)colorChanged:(id)sender {
|
||||
for (id obj in [[NSDocumentController sharedDocumentController] documents]) {
|
||||
if ([obj respondsToSelector:@selector(updateColors)]) {
|
||||
[obj performSelector:@selector(updateColors)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Window delegate
|
||||
|
||||
- (void)windowDidResignMain:(NSNotification *)notification
|
||||
{
|
||||
[self colorChanged:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user