The R Project SVN R-packages

Rev

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

Rev 6233 Rev 6238
Line 38... Line 38...
38
#import "RScriptEditorTextStorage.h"
38
#import "RScriptEditorTextStorage.h"
39
#import "PreferenceKeys.h"
39
#import "PreferenceKeys.h"
40
 
40
 
41
@implementation RScriptEditorLayoutManager
41
@implementation RScriptEditorLayoutManager
42
 
42
 
43
static SEL _setfSel;
-
 
44
 
-
 
45
- (id)init
43
- (id)init
46
{
44
{
47
 
45
 
48
	self = [super init];
46
	self = [super init];
49
    
47
    
Line 59... Line 57...
59
	[self setGlyphGenerator:glyphGenerator];
57
	[self setGlyphGenerator:glyphGenerator];
60
	[glyphGenerator release];
58
	[glyphGenerator release];
61
 
59
 
62
	[self setBackgroundLayoutEnabled:YES];
60
	[self setBackgroundLayoutEnabled:YES];
63
 
61
 
64
	_setfSel = @selector(setLineFoldingEnabled:);
-
 
65
 
-
 
66
	return self;
62
	return self;
67
 
63
 
68
}
64
}
69
 
65
 
70
- (void)dealloc
66
- (void)dealloc
Line 75... Line 71...
75
 
71
 
76
- (void)replaceTextStorage:(id)textStorage
72
- (void)replaceTextStorage:(id)textStorage
77
{
73
{
78
	if(_attributedString) [_attributedString release];
74
	if(_attributedString) [_attributedString release];
79
	_attributedString = [(RScriptEditorTextStorage*)textStorage retain];
75
	_attributedString = [(RScriptEditorTextStorage*)textStorage retain];
80
	_setfImp  = [_attributedString methodForSelector:_setfSel];
-
 
81
	[(RScriptEditorGlyphGenerator*)[self glyphGenerator] setTextStorage:textStorage];
76
	[(RScriptEditorGlyphGenerator*)[self glyphGenerator] setTextStorage:textStorage];
82
	[super replaceTextStorage:textStorage];
77
	[super replaceTextStorage:textStorage];
83
}
78
}
84
 
79
 
85
// - (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin
-
 
86
// {
-
 
87
// 	// (*_setfImp)(_attributedString, _setfSel, YES);
-
 
88
// 	[super drawGlyphsForGlyphRange:glyphsToShow atPoint:origin];
-
 
89
// 	// (*_setfImp)(_attributedString, _setfSel, NO);
-
 
90
// }
-
 
91
 
-
 
92
// - (void)textStorage:(RScriptEditorTextStorage *)str edited:(NSUInteger)editedMask range:(NSRange)newCharRange changeInLength:(NSInteger)delta invalidatedRange:(NSRange)invalidatedCharRange
-
 
93
// {
-
 
94
// 
-
 
95
// 	NSUInteger length = [str length];
-
 
96
// //	NSNumber *value;
-
 
97
// 	NSRange effectiveRange, range;
-
 
98
// 	NSInteger foldIndex;
-
 
99
// 
-
 
100
// 	// it's at the end. check if the last char is in foldingAttributeName
-
 
101
// 	if ((invalidatedCharRange.location == length) && (invalidatedCharRange.location != 0)) { 
-
 
102
// 		// value = [str attribute:foldingAttributeName atIndex:invalidatedCharRange.location - 1 effectiveRange:&effectiveRange];
-
 
103
// 		// if (value && [value boolValue]) invalidatedCharRange = NSUnionRange(invalidatedCharRange, effectiveRange);
-
 
104
// 		foldIndex = [str foldedForIndicatorAtIndex:invalidatedCharRange.location - 1];
-
 
105
// 		effectiveRange = [str foldedRangeAtIndex:foldIndex];
-
 
106
// 		effectiveRange.location++;
-
 
107
// 		effectiveRange.length-=2;
-
 
108
// 		if(foldIndex > -1) invalidatedCharRange = NSUnionRange(invalidatedCharRange, effectiveRange);
-
 
109
// 	}
-
 
110
// 
-
 
111
// 	if (invalidatedCharRange.location < length) {
-
 
112
// 		NSString *string = [str string];
-
 
113
// 		NSUInteger start, end;
-
 
114
// 		if (delta > 0) {
-
 
115
// 			NSUInteger contentsEnd;
-
 
116
// 			[string getParagraphStart:NULL end:&end contentsEnd:&contentsEnd forRange:newCharRange];
-
 
117
// 			if ((contentsEnd != end) && (invalidatedCharRange.location > 0) 
-
 
118
// 				&& (NSMaxRange(newCharRange) == end)) { 
-
 
119
// 				// there was para sep insertion. extend to both sides
-
 
120
// 				if (newCharRange.location <= invalidatedCharRange.location) {
-
 
121
// 					invalidatedCharRange.length = (NSMaxRange(invalidatedCharRange) - (newCharRange.location - 1));
-
 
122
// 					invalidatedCharRange.location = (newCharRange.location - 1);
-
 
123
// 				}
-
 
124
// 
-
 
125
// 				if ((end < length) && (NSMaxRange(invalidatedCharRange) <= end)) {
-
 
126
// 					invalidatedCharRange.length = ((end + 1) - invalidatedCharRange.location);
-
 
127
// 				}
-
 
128
// 			}
-
 
129
// 		}
-
 
130
// 
-
 
131
// 		range = invalidatedCharRange;
-
 
132
// 
-
 
133
// 		while ((range.location > 0) || (NSMaxRange(range) < length)) {
-
 
134
// 			[string getParagraphStart:&start end:&end contentsEnd:NULL forRange:range];
-
 
135
// 			range.location = start;
-
 
136
// 			range.length = (end - start);
-
 
137
// 
-
 
138
// 			// Extend backward
-
 
139
// 			foldIndex = [str foldedForIndicatorAtIndex:range.location];
-
 
140
// 			if(foldIndex > -1) {
-
 
141
// 				effectiveRange = [str foldedRangeAtIndex:foldIndex];
-
 
142
// 				if(effectiveRange.length) {
-
 
143
// 					// value = [str attribute:foldingAttributeName atIndex:range.location longestEffectiveRange:&effectiveRange inRange:NSMakeRange(0, range.location + 1)];
-
 
144
// 					// if (value && [value boolValue] && (effectiveRange.location < range.location)) {
-
 
145
// 					effectiveRange.location++;
-
 
146
// 					if (effectiveRange.location < range.location) {
-
 
147
// 						range.length += (range.location - effectiveRange.location);
-
 
148
// 						range.location = effectiveRange.location;
-
 
149
// 					}
-
 
150
// 				}
-
 
151
// 			}
-
 
152
// 			// Extend forward
-
 
153
// 			if (NSMaxRange(range) < length) {
-
 
154
// 				// value = [str attribute:foldingAttributeName atIndex:NSMaxRange(range) longestEffectiveRange:&effectiveRange inRange:NSMakeRange(NSMaxRange(range), length - NSMaxRange(range))];
-
 
155
// 				// if (value && [value boolValue] && (NSMaxRange(effectiveRange) > NSMaxRange(range))) {
-
 
156
// 				foldIndex = [str foldedForIndicatorAtIndex:NSMaxRange(range)];
-
 
157
// 				if(foldIndex > -1) {
-
 
158
// 					effectiveRange = [str foldedRangeAtIndex:foldIndex];
-
 
159
// 					if(effectiveRange.length) {
-
 
160
// 						effectiveRange.location++;
-
 
161
// 						effectiveRange.length-=2;
-
 
162
// 						if(NSMaxRange(effectiveRange) > NSMaxRange(range)) {
-
 
163
// 							range.length = NSMaxRange(effectiveRange) - range.location;
-
 
164
// 						}
-
 
165
// 					}
-
 
166
// 				}
-
 
167
// 			}
-
 
168
// 
-
 
169
// 			if (NSEqualRanges(range, invalidatedCharRange)) break;
-
 
170
// 			invalidatedCharRange = range;
-
 
171
// 		}
-
 
172
// 	}
-
 
173
// 
-
 
174
// 	[super textStorage:str edited:editedMask range:newCharRange changeInLength:delta invalidatedRange:invalidatedCharRange];
-
 
175
// 
-
 
176
// }
-
 
177
 
-
 
178
@end
80
@end