The R Project SVN R-packages

Rev

Rev 6137 | Rev 6233 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6137 Rev 6232
Line 42... Line 42...
42
@synthesize lineFoldingEnabled = _lineFoldingEnabled;
42
@synthesize lineFoldingEnabled = _lineFoldingEnabled;
43
 
43
 
44
static NSTextAttachment *sharedAttachment = nil;
44
static NSTextAttachment *sharedAttachment = nil;
45
static SEL _getSel;
45
static SEL _getSel;
46
static SEL _setSel;
46
static SEL _setSel;
-
 
47
static SEL _strSel;
-
 
48
static SEL _replSel;
-
 
49
static SEL _editSel;
47
 
50
 
48
+ (void)initialize
51
+ (void)initialize
49
{
52
{
50
 
53
 
51
	if ([self class] == [RScriptEditorTextStorage class]) {
54
	if ([self class] == [RScriptEditorTextStorage class]) {
52
		FoldingSignTextAttachmentCell *cell = [[FoldingSignTextAttachmentCell alloc] initImageCell:nil];
55
		FoldingSignTextAttachmentCell *cell = [[FoldingSignTextAttachmentCell alloc] initImageCell:nil];
53
		sharedAttachment = [[NSTextAttachment alloc] init];
56
		sharedAttachment = [[NSTextAttachment alloc] init];
54
		[sharedAttachment setAttachmentCell:cell];
57
		[sharedAttachment setAttachmentCell:cell];
55
		[cell release];
58
		[cell release];
56
		_getSel = @selector(attributesAtIndex:effectiveRange:);
59
		_getSel  = @selector(attributesAtIndex:effectiveRange:);
57
		_setSel = @selector(setAttributes:range:);
60
		_setSel  = @selector(setAttributes:range:);
-
 
61
		_strSel  = @selector(string);
-
 
62
		_replSel = @selector(replaceCharactersInRange:withString:);
-
 
63
		_editSel = @selector(edited:range:changeInLength:);
-
 
64
		_lineFoldingEnabled = NO;
58
	}
65
	}
59
}
66
}
60
 
67
 
61
+ (NSTextAttachment *)attachment
68
+ (NSTextAttachment *)attachment
62
{
69
{
Line 67... Line 74...
67
{
74
{
68
	self = [super init];
75
	self = [super init];
69
 
76
 
70
	if (self != nil) {
77
	if (self != nil) {
71
		_attributedString = [[NSTextStorage alloc] init];
78
		_attributedString = [[NSTextStorage alloc] init];
72
		_getImp = [_attributedString methodForSelector:_getSel];
79
		_getImp  = [_attributedString methodForSelector:_getSel];
73
		_setImp = [_attributedString methodForSelector:_setSel];
80
		_setImp  = [_attributedString methodForSelector:_setSel];
-
 
81
		_strImp  = [_attributedString methodForSelector:_strSel];
-
 
82
		_replImp = [_attributedString methodForSelector:_replSel];
-
 
83
		_editImp = [_attributedString methodForSelector:_editSel];
74
	}
84
	}
75
 
85
 
76
	return self;
86
	return self;
77
}
87
}
78
 
88
 
79
- (void)dealloc
89
- (void)dealloc
80
{
90
{
81
	[[NSNotificationCenter defaultCenter] removeObserver:self];
91
	[[NSNotificationCenter defaultCenter] removeObserver:self];
82
	[_attributedString release];
92
	[_attributedString release];
-
 
93
	if(sharedAttachment) [sharedAttachment release];
83
	[super dealloc];
94
	[super dealloc];
84
}
95
}
85
 
96
 
86
// NSAttributedString primitives
97
// NSAttributedString primitives
87
- (NSString *)string
98
- (NSString *)string
88
{ 
99
{ 
89
	return [_attributedString string];
100
	return (*_strImp)(_attributedString, _strSel);
90
}
101
}
91
 
102
 
92
 
-
 
93
- (NSDictionary *)attributesAtIndex:(NSUInteger)location effectiveRange:(NSRangePointer)range
103
- (NSDictionary *)attributesAtIndex:(NSUInteger)location effectiveRange:(NSRangePointer)range
94
{
104
{
95
 
105
 
96
	NSDictionary *attributes = (*_getImp)(_attributedString, _getSel, location, range);
106
	NSDictionary *attributes = (*_getImp)(_attributedString, _getSel, location, range);
97
 
107
 
Line 121... Line 131...
121
}
131
}
122
 
132
 
123
// NSMutableAttributedString primitives
133
// NSMutableAttributedString primitives
124
- (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str
134
- (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)str
125
{
135
{
126
	[_attributedString replaceCharactersInRange:range withString:str];
136
	(*_replImp)(_attributedString, _replSel, range, str);
127
	[self edited:NSTextStorageEditedCharacters range:range changeInLength:[str length] - range.length];
137
	(*_editImp)(self, _editSel, NSTextStorageEditedCharacters, range, [str length] - range.length);
128
}
138
}
129
 
139
 
130
- (void)setAttributes:(NSDictionary *)attrs range:(NSRange)range
140
- (void)setAttributes:(NSDictionary *)attrs range:(NSRange)range
131
{
141
{
132
	(*_setImp)(_attributedString, _setSel, attrs, range);
142
	(*_setImp)(_attributedString, _setSel, attrs, range);
133
	[self edited:NSTextStorageEditedAttributes range:range changeInLength:0];
143
	(*_editImp)(self, _editSel, NSTextStorageEditedAttributes, range, 0);
134
}
144
}
135
 
145
 
136
// Attribute Fixing Overrides
146
// Attribute Fixing Overrides
137
/*
147
/*
138
- (void)fixAttributesInRange:(NSRange)range
148
- (void)fixAttributesInRange:(NSRange)range