forked from jessegrosjean/bpreferences
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BPreferencesTextAttributesTextView.m
56 lines (42 loc) · 1.27 KB
/
BPreferencesTextAttributesTextView.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
51
52
53
54
55
56
//
// BPreferencesTextAttributesTextView.m
// BPreferences
//
// Created by Jesse Grosjean on 5/8/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "BPreferencesTextAttributesTextView.h"
#import "BPreferencesTextAttributesLayoutManager.h"
@implementation BPreferencesTextAttributesTextView
- (void)awakeFromNib {
[[self textContainer] replaceLayoutManager:[[BPreferencesTextAttributesLayoutManager alloc] init]];
}
- (void)keyDown:(NSEvent *)theEvent {
}
- (void)keyUp:(NSEvent *)theEvent {
}
- (void)mouseDown:(NSEvent *)theEvent {
}
- (void)viewDidMoveToWindow {
[[self window] performSelector:@selector(makeFirstResponder:) withObject:self afterDelay:0.0];
}
- (void)setRulerVisible:(BOOL)flag {
if (flag != [self isRulerVisible]) {
if (flag) {
[[self window] makeFirstResponder:self];
}
[super setRulerVisible:flag];
[self setSelectedRange:NSMakeRange(0,0)];
[self selectAll:nil];
}
}
- (void)drawRect:(NSRect)rect {
[[self backgroundColor] set];
NSRectFill(rect);
NSLayoutManager *layoutManger = [self layoutManager];
NSRange glyphRange = [layoutManger glyphRangeForTextContainer:[self textContainer]];
if (glyphRange.length > 0) {
[layoutManger drawGlyphsForGlyphRange:glyphRange atPoint:NSMakePoint(0, 0)];
}
}
@end