forked from jessegrosjean/bpreferences
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBPreferencesTextAttributesController.m
More file actions
73 lines (57 loc) · 2.08 KB
/
BPreferencesTextAttributesController.m
File metadata and controls
73 lines (57 loc) · 2.08 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// BPreferencesTextAttributesController.m
// BPreferences
//
// Created by Jesse Grosjean on 5/8/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "BPreferencesTextAttributesController.h"
#import "BPreferencesTextAttributesTextView.h"
@implementation BPreferencesTextAttributesController
#pragma mark Init
- (id)init {
if (self = [super initWithWindowNibName:@"BPreferencesTextAttributesWindow"]) {
}
return self;
}
- (void)awakeFromNib {
[[textView textStorage] setDelegate:self];
[[self undoManager] disableUndoRegistration];
[[textView textStorage] replaceCharactersInRange:NSMakeRange(0, [[textView textStorage] length]) withString:BLocalizedString(@"Use this text area to select your prefered text attributes. This text is not editable, but the attributes are. To change font's etc, Control-Click on this text and then choose the Font menu item from the popup menu.", @"")];
[[self undoManager] enableUndoRegistration];
[textView setRulerVisible:YES];
[selectAttributesControl setMenu:textAttributesMenu forSegment:0];
}
- (NSDictionary *)textAttributes {
return [[textView textStorage] attributesAtIndex:0 effectiveRange:NULL];
}
- (void)setTextAttributes:(NSDictionary *)newTextAttributes {
[[textView textStorage] setAttributes:newTextAttributes range:NSMakeRange(0, [[textView textStorage] length])];
}
- (NSUndoManager *)undoManager {
if (!undoManager) {
undoManager = [[NSUndoManager alloc] init];
}
return undoManager;
}
- (IBAction)ok:(id)sender {
[NSApp endSheet:[self window] returnCode:NSOKButton];
[[self window] close];
}
- (IBAction)cancel:(id)sender {
[NSApp endSheet:[self window] returnCode:NSCancelButton];
[[self window] close];
}
- (IBAction)reset:(id)sender {
self.textAttributes = [NSDictionary dictionary];
}
- (IBAction)changeFont:(id)sender {
[[self window] makeFirstResponder:textView];
[[NSFontManager sharedFontManager] orderFrontFontPanel:sender];
}
- (void)textStorageDidProcessEditing:(NSNotification *)aNotification {
}
- (NSUndoManager *)undoManagerForTextView:(NSTextView *)aTextView {
return [self undoManager];
}
@end