The R Project SVN R-packages

Rev

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

Rev 6232 Rev 6233
Line 32... Line 32...
32
 *
32
 *
33
 */
33
 */
34
 
34
 
35
#import "RScriptEditorTextView.h"
35
#import "RScriptEditorTextView.h"
36
#import "RScriptEditorTextStorage.h"
36
#import "RScriptEditorTextStorage.h"
37
#import "RScriptEditorTypesetter.h"
37
#import "RScriptEditorTypeSetter.h"
38
#import "RScriptEditorLayoutManager.h"
38
#import "RScriptEditorLayoutManager.h"
39
#import "FoldingSignTextAttachmentCell.h"
39
#import "FoldingSignTextAttachmentCell.h"
40
#import "RGUI.h"
40
#import "RGUI.h"
41
 
41
 
42
 
42
 
Line 61... Line 61...
61
extern NSUInteger rdlex();
61
extern NSUInteger rdlex();
62
typedef struct rd_buffer_state *RD_BUFFER_STATE;
62
typedef struct rd_buffer_state *RD_BUFFER_STATE;
63
void rd_switch_to_buffer(RD_BUFFER_STATE);
63
void rd_switch_to_buffer(RD_BUFFER_STATE);
64
RD_BUFFER_STATE rd_scan_string (const char *);
64
RD_BUFFER_STATE rd_scan_string (const char *);
65
 
65
 
-
 
66
static SEL _foldedSel;
66
 
67
 
67
#pragma mark -
68
#pragma mark -
68
#pragma mark attribute definition 
69
#pragma mark attribute definition 
69
 
70
 
70
#define kAPlinked      @"Linked" // attribute for a via auto-pair inserted char
71
#define kAPlinked      @"Linked" // attribute for a via auto-pair inserted char
Line 78... Line 79...
78
#define kBTQuote       @"BTQuote"
79
#define kBTQuote       @"BTQuote"
79
#define kBTQuoteValue  @"isBTQuoted"
80
#define kBTQuoteValue  @"isBTQuoted"
80
 
81
 
81
#pragma mark -
82
#pragma mark -
82
 
83
 
83
#define R_SYNTAX_HILITE_BIAS 3000
84
#define R_SYNTAX_HILITE_BIAS 2000
84
#define R_MAX_TEXT_SIZE_FOR_SYNTAX_HIGHLIGHTING 20000000
85
#define R_MAX_TEXT_SIZE_FOR_SYNTAX_HIGHLIGHTING 20000000
85
 
86
 
86
 
87
 
87
static inline const char* NSStringUTF8String(NSString* self) 
88
static inline const char* NSStringUTF8String(NSString* self) 
88
{
89
{
Line 121... Line 122...
121
	[super awakeFromNib];
122
	[super awakeFromNib];
122
 
123
 
123
	SLog(@"RScriptEditorTextView: awakeFromNib <%@>", self);
124
	SLog(@"RScriptEditorTextView: awakeFromNib <%@>", self);
124
 
125
 
125
	breakSyntaxHighlighting = 0;
126
	breakSyntaxHighlighting = 0;
-
 
127
	_foldedSel = @selector(foldedAtIndex:);
126
 
128
	
127
	// Bind scrollView programmatically - if done in RDocument.xib this'd lead to
129
	// Bind scrollView programmatically - if done in RDocument.xib this'd lead to
128
	// calling awakeFromNib twice
130
	// calling awakeFromNib twice
129
	id scrView = (NSScrollView *)self.superview.superview;
131
	id scrView = (NSScrollView *)self.superview.superview;
130
	if ([scrView isKindOfClass:[NSScrollView class]]) {
132
	if ([scrView isKindOfClass:[NSScrollView class]]) {
131
		if(scrollView) [scrollView release];
133
		if(scrollView) [scrollView release];
Line 140... Line 142...
140
 
142
 
141
	theTextStorage = [[RScriptEditorTextStorage alloc] init];
143
	theTextStorage = [[RScriptEditorTextStorage alloc] init];
142
 
144
 
143
	// Set self as delegate for the textView's textStorage to enable syntax highlighting,
145
	// Set self as delegate for the textView's textStorage to enable syntax highlighting,
144
	[theTextStorage setDelegate:self];
146
	[theTextStorage setDelegate:self];
-
 
147
	_foldedImp = [theTextStorage methodForSelector:_foldedSel];
145
 
148
 
146
	// <TODO> enable for folding
149
	// <TODO> enable for folding
147
	// Make sure using foldingLayoutManager
150
	// Make sure using foldingLayoutManager
148
	// if (![[self layoutManager] isKindOfClass:[RScriptEditorLayoutManager class]]) {
151
	// if (![[self layoutManager] isKindOfClass:[RScriptEditorLayoutManager class]]) {
149
	// 	RScriptEditorLayoutManager *layoutManager = [[RScriptEditorLayoutManager alloc] init];
152
	// 	RScriptEditorLayoutManager *layoutManager = [[RScriptEditorLayoutManager alloc] init];
Line 153... Line 156...
153
 
156
 
154
	// disabled to get the current text range in textView safer
157
	// disabled to get the current text range in textView safer
155
	[[self layoutManager] setBackgroundLayoutEnabled:NO];
158
	[[self layoutManager] setBackgroundLayoutEnabled:NO];
156
	[[self layoutManager] replaceTextStorage:theTextStorage];
159
	[[self layoutManager] replaceTextStorage:theTextStorage];
157
 
160
 
-
 
161
	// <TODO> enable for folding
-
 
162
	// [(RScriptEditorTypeSetter*)[[self layoutManager] typesetter] setTextStorage:theTextStorage];
-
 
163
 
158
	isSyntaxHighlighting = NO;
164
	isSyntaxHighlighting = NO;
159
 
165
 
160
	if([prefs objectForKey:highlightCurrentLine] == nil) [prefs setBool:YES forKey:highlightCurrentLine];
166
	if([prefs objectForKey:highlightCurrentLine] == nil) [prefs setBool:YES forKey:highlightCurrentLine];
161
	if([prefs objectForKey:indentNewLines] == nil) [prefs setBool:YES forKey:indentNewLines];
167
	if([prefs objectForKey:indentNewLines] == nil) [prefs setBool:YES forKey:indentNewLines];
162
 
168
 
Line 733... Line 739...
733
	size_t token;
739
	size_t token;
734
	NSRange tokenRange;
740
	NSRange tokenRange;
735
 
741
 
736
	// initialise flex
742
	// initialise flex
737
	yyuoffset = textRange.location; yyuleng = 0;
743
	yyuoffset = textRange.location; yyuleng = 0;
-
 
744
	
-
 
745
	BOOL hasFoldedItems = [theTextStorage hasFoldedItems];
738
 
746
 
739
	if([[self delegate] isRdDocument]) {
747
	if([[self delegate] isRdDocument]) {
740
 
748
 
741
			rd_switch_to_buffer(rd_scan_string(NSStringUTF8String([selfstr substringWithRange:textRange])));
749
			rd_switch_to_buffer(rd_scan_string(NSStringUTF8String([selfstr substringWithRange:textRange])));
742
 
750
 
743
			// now loop through all the tokens
751
			// now loop through all the tokens
744
			while ((token = rdlex())) {
752
			while ((token = rdlex())) {
-
 
753
				if(hasFoldedItems && (NSInteger)(_foldedImp)(theTextStorage, _foldedSel, yyuoffset) > -1) continue;
745
				switch (token) {
754
				switch (token) {
746
					case RDPT_COMMENT:
755
					case RDPT_COMMENT:
747
					    tokenColor = shColorComment;
756
					    tokenColor = shColorComment;
748
					    break;
757
					    break;
749
					case RDPT_SECTION:
758
					case RDPT_SECTION:
Line 793... Line 802...
793
 
802
 
794
	} else {
803
	} else {
795
 
804
 
796
		yy_switch_to_buffer(yy_scan_string(NSStringUTF8String([selfstr substringWithRange:textRange])));
805
		yy_switch_to_buffer(yy_scan_string(NSStringUTF8String([selfstr substringWithRange:textRange])));
797
 
806
 
-
 
807
 
-
 
808
// NSDate *d1 = [NSDate date];
-
 
809
 
798
		// now loop through all the tokens
810
		// now loop through all the tokens
799
		while ((token = yylex())) {
811
		while ((token = yylex())) {
-
 
812
			if(hasFoldedItems && (NSInteger)(_foldedImp)(theTextStorage, _foldedSel, yyuoffset) > -1) continue;
800
			switch (token) {
813
			switch (token) {
801
				case RPT_SINGLE_QUOTED_TEXT:
814
				case RPT_SINGLE_QUOTED_TEXT:
802
				case RPT_DOUBLE_QUOTED_TEXT:
815
				case RPT_DOUBLE_QUOTED_TEXT:
803
				    tokenColor = shColorString;
816
				    tokenColor = shColorString;
804
				    break;
817
				    break;
Line 844... Line 857...
844
				break;
857
				break;
845
 
858
 
846
			}
859
			}
847
 
860
 
848
		}
861
		}
-
 
862
 
-
 
863
// NSLog(@"bibiko1 t %f", [[NSDate date] timeIntervalSinceDate:d1]);
-
 
864
 
849
	}
865
	}
850
 
866
 
851
	// set current textColor to the color of the caret's position - 1
867
	// set current textColor to the color of the caret's position - 1
852
	// to try to suppress writing in normalColor before syntax highlighting 
868
	// to try to suppress writing in normalColor before syntax highlighting 
853
	NSUInteger ix = [self selectedRange].location;
869
	NSUInteger ix = [self selectedRange].location;
Line 939... Line 955...
939
 
955
 
940
	}
956
	}
941
 
957
 
942
}
958
}
943
 
959
 
-
 
960
- (IBAction)undo:(id)sender
-
 
961
{
-
 
962
	if([[self undoManager] canUndo]) {
-
 
963
		[[self undoManager] undo];
-
 
964
		if(lineNumberingEnabled)
-
 
965
			[[[self enclosingScrollView] verticalRulerView] performSelector:@selector(refresh) withObject:nil afterDelay:0.0f];
-
 
966
	}
-
 
967
}
-
 
968
 
-
 
969
- (IBAction)redo:(id)sender
-
 
970
{
-
 
971
	if([[self undoManager] canRedo]) {
-
 
972
		[[self undoManager] redo];
-
 
973
		if(lineNumberingEnabled)
-
 
974
			[[[self enclosingScrollView] verticalRulerView] performSelector:@selector(refresh) withObject:nil afterDelay:0.0f];
-
 
975
	}
-
 
976
}
-
 
977
 
944
#pragma mark -
978
#pragma mark -
945
#pragma mark Folding
979
#pragma mark Folding
946
 
980
 
947
- (void)foldSelectedLines:(id)sender
981
- (void)foldLinesInRange:(NSRange)range
948
{
982
{
-
 
983
	if(range.length < 2) return;
949
 
984
 
-
 
985
	NSInteger foldId = [theTextStorage registerFoldedRange:range];
950
	NSRange r = [self selectedRange];
986
	NSInteger caretPosition = [self selectedRange].location;
-
 
987
	BOOL caretWasInsideFoldedRange = NO;
951
 
988
 
952
	if(r.length < 4) return;
989
	if(foldId < 0) {
-
 
990
		NSBeep();
-
 
991
		return;
-
 
992
	}
-
 
993
 
-
 
994
	if(caretPosition >= range.location && caretPosition < NSMaxRange(range)) {
-
 
995
		[self setSelectedRange:NSMakeRange(NSMaxRange(range), 0)];
-
 
996
		caretWasInsideFoldedRange = YES;
-
 
997
	}
953
 
998
 
954
	unichar s = [[self string] characterAtIndex:r.location];
999
	unichar s = [[self string] characterAtIndex:range.location];
955
	unichar e = [[self string] characterAtIndex:NSMaxRange(r)-1];
1000
	unichar e = [[self string] characterAtIndex:NSMaxRange(range)-1];
956
 
1001
 
957
	BOOL wrapCheck = NO;
1002
	BOOL wrapCheck = NO;
958
 
1003
 
959
	if(s == '{' && e == '}') {
1004
	if(s == '{' && e == '}') {
960
		r.location++;
1005
		range.location++;
961
		r.length -= 2;
1006
		range.length -= 2;
962
		wrapCheck = YES;
1007
		wrapCheck = YES;
963
	} else if(s == '(' && e == ')') {
1008
	} else if(s == '(' && e == ')') {
964
		r.location++;
1009
		range.location++;
965
		r.length -= 2;
1010
		range.length -= 2;
966
		wrapCheck = YES;
1011
		wrapCheck = YES;
967
	} else if(s == '[' && e == ']') {
1012
	} else if(s == '[' && e == ']') {
968
		r.location++;
1013
		range.location++;
969
		r.length -= 2;
1014
		range.length -= 2;
970
		wrapCheck = YES;
1015
		wrapCheck = YES;
971
	}
1016
	}
972
 
1017
 
973
	if(!r.length) return;
1018
	if(!range.length) return;
-
 
1019
 
-
 
1020
	if(!wrapCheck && [[self string] characterAtIndex:NSMaxRange(range)-1] == '\n')
-
 
1021
		range.length--;
974
 
1022
 
975
	if(!wrapCheck && [[self string] characterAtIndex:NSMaxRange(r)-1] == '\n')
-
 
976
		r.length--;
1023
	if(!range.length) return;
977
 
1024
 
978
	if(!r.length) return;
-
 
979
 
1025
 
980
	NSString *tooltip = nil;
1026
	NSString *tooltip = nil;
981
	if(r.length < 300)
1027
	if(range.length < 300)
982
		tooltip = [[self string] substringWithRange:r];
1028
		tooltip = [[self string] substringWithRange:range];
983
	else
1029
	else
984
		tooltip = [[[self string] substringWithRange:NSMakeRange(r.location, 300)] stringByAppendingString:@"\n…"];
1030
		tooltip = [[[self string] substringWithRange:NSMakeRange(range.location, 300)] stringByAppendingString:@"\n…"];
985
 
1031
 
986
	[theTextStorage beginEditing];
1032
	[theTextStorage beginEditing];
987
	[theTextStorage addAttribute:foldingAttributeName value:[NSNumber numberWithBool:YES] range:r];
1033
	[theTextStorage addAttribute:foldingAttributeId value:[NSNumber numberWithInteger:foldId] range:range];
988
	[theTextStorage addAttribute:NSCursorAttributeName value:[NSCursor arrowCursor] range:r];
1034
	[theTextStorage addAttribute:NSCursorAttributeName value:[NSCursor arrowCursor] range:range];
989
	[theTextStorage addAttribute:NSToolTipAttributeName value:tooltip range:r];
1035
	[theTextStorage addAttribute:NSToolTipAttributeName value:tooltip range:range];
990
	[theTextStorage endEditing];
1036
	[theTextStorage endEditing];
991
 
1037
 
992
	[self didChangeText];
1038
	[self didChangeText];
993
	if(lineNumberingEnabled)
-
 
994
		[[[self enclosingScrollView] verticalRulerView] performSelector:@selector(refresh) withObject:nil afterDelay:0.0f];
-
 
995
 
1039
 
996
	[self setSelectedRange:NSMakeRange(NSMaxRange(r), 0)];
1040
	if(caretWasInsideFoldedRange)
997
	[self scrollRangeToVisible:[self selectedRange]];
1041
		[self scrollRangeToVisible:[self selectedRange]];
-
 
1042
 
-
 
1043
	if(lineNumberingEnabled)
-
 
1044
		[[[self enclosingScrollView] verticalRulerView] performSelector:@selector(refresh) withObject:nil afterDelay:0.01f];
-
 
1045
	
-
 
1046
	[NSObject cancelPreviousPerformRequestsWithTarget:self 
-
 
1047
							selector:@selector(doSyntaxHighlighting) 
-
 
1048
							object:nil];
-
 
1049
	[self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.0f];
998
 
1050
 
999
}
1051
}
1000
 
1052
 
1001
- (BOOL)unfoldLinesContainingCharacterAtIndex:(NSUInteger)charIndex
1053
- (BOOL)unfoldLinesContainingCharacterAtIndex:(NSUInteger)charIndex
1002
{
1054
{
1003
 
1055
 
1004
	NSTextStorage *textStorage = [self textStorage];
1056
	NSInteger foldIndex = [theTextStorage foldedAtIndex:charIndex];
-
 
1057
 
1005
	NSRange range;
1058
	if(foldIndex > -1) {
1006
	NSNumber *value = [textStorage attribute:foldingAttributeName atIndex:charIndex longestEffectiveRange:&range inRange:NSMakeRange(0, [textStorage length])];
1059
		[theTextStorage removeFoldedRangeWithId:[theTextStorage attribute:foldingAttributeId atIndex:charIndex effectiveRange:NULL]];
1007
 
1060
 
1008
	if (value && [value boolValue] && [self shouldChangeTextInRange:range replacementString:nil]) {
-
 
1009
		[textStorage removeAttribute:foldingAttributeName range:range];
-
 
1010
		[textStorage removeAttribute:NSCursorAttributeName range:range];
-
 
1011
		[textStorage removeAttribute:NSToolTipAttributeName range:range];
-
 
1012
		[self didChangeText];
1061
		[self didChangeText];
1013
		[self setSelectedRange:NSMakeRange(NSMaxRange(range), 0)];
-
 
-
 
1062
 
1014
		if(lineNumberingEnabled)
1063
		if(lineNumberingEnabled)
1015
			[[[self enclosingScrollView] verticalRulerView] performSelector:@selector(refresh) withObject:nil afterDelay:0.0f];
1064
			[[[self enclosingScrollView] verticalRulerView] performSelector:@selector(refresh) withObject:nil afterDelay:0.01f];
-
 
1065
		
1016
		[self scrollRangeToVisible:[self selectedRange]];
1066
		[NSObject cancelPreviousPerformRequestsWithTarget:self 
-
 
1067
								selector:@selector(doSyntaxHighlighting) 
-
 
1068
								object:nil];
-
 
1069
 
-
 
1070
		[self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.0f];
-
 
1071
 
-
 
1072
 
1017
		return YES;
1073
		return YES;
1018
	}
1074
	}
-
 
1075
	
1019
	return NO;
1076
	return NO;
-
 
1077
 
1020
}
1078
}
1021
 
1079
 
1022
- (void)mouseDown:(NSEvent *)event
1080
- (void)mouseDown:(NSEvent *)event
1023
{
1081
{
1024
 
1082
 
1025
	// <TODO> enable for folding
1083
	// <TODO> enable for folding
1026
	[super mouseDown:event];
1084
	[super mouseDown:event];
1027
 
1085
 
1028
// 	if(![theTextStorage isKindOfClass:[RScriptEditorTextStorage class]]) [super mouseDown:event];
1086
	// if(![theTextStorage isKindOfClass:[RScriptEditorTextStorage class]]) {
-
 
1087
	// 	[super mouseDown:event];
-
 
1088
	// 	return;
-
 
1089
	// }
1029
// 
1090
	// 
1030
// 	RScriptEditorLayoutManager *layoutManager = (RScriptEditorLayoutManager*)[self layoutManager];
1091
	// RScriptEditorLayoutManager *layoutManager = (RScriptEditorLayoutManager*)[self layoutManager];
1031
// 	NSUInteger glyphIndex = [layoutManager glyphIndexForPoint:[self convertPointFromBase:[event locationInWindow]] inTextContainer:[self textContainer]];
1092
	// NSUInteger glyphIndex = [layoutManager glyphIndexForPoint:[self convertPointFromBase:[event locationInWindow]] inTextContainer:[self textContainer]];
1032
// 
-
 
1033
// 	[theTextStorage setLineFoldingEnabled:YES];
-
 
1034
// 
1093
	// 
1035
// 	// trigger unfolding if inside foldingAttachmentCell
1094
	// // trigger unfolding if inside foldingAttachmentCell
1036
// 	if (glyphIndex < [layoutManager numberOfGlyphs]) {
1095
	// if (glyphIndex < [layoutManager numberOfGlyphs]) {
-
 
1096
	// 
1037
// 		NSUInteger charIndex = [layoutManager characterIndexForGlyphAtIndex:glyphIndex];
1097
	// 	NSUInteger charIndex = [layoutManager characterIndexForGlyphAtIndex:glyphIndex];
1038
// 		NSRange range;
-
 
1039
// 		NSNumber *value = [theTextStorage attribute:foldingAttributeName atIndex:charIndex longestEffectiveRange:&range inRange:NSMakeRange(0, [theTextStorage length])];
1098
	// 	NSInteger foldIndex  = [theTextStorage foldedForIndicatorAtIndex:charIndex];
1040
// 	
1099
	// 
1041
// 		if (value && [value boolValue]) {
1100
	// 	if (foldIndex > -1) {
-
 
1101
	// 
-
 
1102
	// 		NSInteger foldStart = [theTextStorage foldedRangeAtIndex:foldIndex].location+1;
1042
// 			NSTextAttachment *attachment = [theTextStorage attribute:NSAttachmentAttributeName atIndex:range.location effectiveRange:NULL];
1103
	// 		NSTextAttachment *attachment = [theTextStorage attribute:NSAttachmentAttributeName atIndex:foldStart effectiveRange:NULL];
1043
// 	
1104
	// 
1044
// 			if (attachment) {
1105
	// 		if (attachment) {
1045
// 				NSTextAttachmentCell *cell = (NSTextAttachmentCell *)[attachment attachmentCell];
1106
	// 			NSTextAttachmentCell *cell = (NSTextAttachmentCell *)[attachment attachmentCell];
1046
// 				NSRect cellFrame;
1107
	// 			NSRect cellFrame;
1047
// 				NSPoint delta;
1108
	// 			NSPoint delta;
1048
// 	
1109
	// 
1049
// 				glyphIndex = [layoutManager glyphIndexForCharacterAtIndex:range.location];
1110
	// 			glyphIndex = [layoutManager glyphIndexForCharacterAtIndex:foldStart];
1050
// 	
1111
	// 
1051
// 				cellFrame.origin = [self textContainerOrigin];
1112
	// 			cellFrame.origin = [self textContainerOrigin];
1052
// 				cellFrame.size = [layoutManager attachmentSizeForGlyphAtIndex:glyphIndex];
1113
	// 			cellFrame.size = [layoutManager attachmentSizeForGlyphAtIndex:glyphIndex];
1053
// 	
1114
	// 
1054
// 				delta = [layoutManager lineFragmentRectForGlyphAtIndex:glyphIndex effectiveRange:NULL].origin;
1115
	// 			delta = [layoutManager lineFragmentRectForGlyphAtIndex:glyphIndex effectiveRange:NULL].origin;
1055
// 				cellFrame.origin.x += delta.x;
1116
	// 			cellFrame.origin.x += delta.x;
1056
// 				cellFrame.origin.y += delta.y;
1117
	// 			cellFrame.origin.y += delta.y;
1057
// 	
1118
	// 
1058
// 				cellFrame.origin.x += [layoutManager locationForGlyphAtIndex:glyphIndex].x;
1119
	// 			cellFrame.origin.x += [layoutManager locationForGlyphAtIndex:glyphIndex].x;
1059
// 	
1120
	// 
-
 
1121
	// 			if ([cell wantsToTrackMouseForEvent:event inRect:cellFrame ofView:self atCharacterIndex:foldStart] 
1060
// 				if ([cell wantsToTrackMouseForEvent:event inRect:cellFrame ofView:self atCharacterIndex:range.location] && [cell trackMouse:event inRect:cellFrame ofView:self atCharacterIndex:range.location untilMouseUp:YES]) return;
1122
	// 					&& [cell trackMouse:event inRect:cellFrame ofView:self atCharacterIndex:foldStart untilMouseUp:YES]) return;
1061
// 			}
-
 
1062
// 		}
1123
	// 		}
1063
// 	}
1124
	// 	}
1064
// 
1125
	// }
1065
// 	[theTextStorage setLineFoldingEnabled:NO];
-
 
1066
// 
1126
	// 
1067
// 	[super mouseDown:event];
1127
	// [super mouseDown:event];
1068
// }
1128
}
1069
// 
1129
 
1070
// - (void)setSelectedRanges:(NSArray *)ranges affinity:(NSSelectionAffinity)affinity stillSelecting:(BOOL)stillSelectingFlag
1130
// - (void)setSelectedRanges:(NSArray *)ranges affinity:(NSSelectionAffinity)affinity stillSelecting:(BOOL)stillSelectingFlag
1071
// {
1131
// {
1072
// 
1132
// 
1073
// 	if(!stillSelectingFlag) {
1133
// 	if(!stillSelectingFlag) {
1074
// 
1134
// 
Line 1099... Line 1159...
1099
// 			}
1159
// 			}
1100
// 		}
1160
// 		}
1101
// 	}
1161
// 	}
1102
// 
1162
// 
1103
// 	[super setSelectedRanges:ranges affinity:affinity stillSelecting:stillSelectingFlag];
1163
// 	[super setSelectedRanges:ranges affinity:affinity stillSelecting:stillSelectingFlag];
1104
 
1164
// 
1105
}
1165
// }
1106
 
1166
// 
1107
 
1167
 
1108
- (void)setTypingAttributes:(NSDictionary *)attrs
1168
- (void)setTypingAttributes:(NSDictionary *)attrs
1109
{
1169
{
1110
	// we don't want to store foldingAttributeName as a typing attribute
1170
	// we don't want to store foldingAttributeId as a typing attribute
1111
	if ([attrs objectForKey:foldingAttributeName]) {
1171
	if ([attrs objectForKey:foldingAttributeId]) {
1112
		NSMutableDictionary *copy = [[attrs mutableCopyWithZone:NULL] autorelease];
1172
		NSMutableDictionary *copy = [[attrs mutableCopyWithZone:NULL] autorelease];
1113
		[copy removeObjectForKey:foldingAttributeName];
1173
		[copy removeObjectForKey:foldingAttributeId];
1114
		attrs = copy;
1174
		attrs = copy;
1115
	}
1175
	}
1116
 
1176
 
1117
	[super setTypingAttributes:attrs];
1177
	[super setTypingAttributes:attrs];
1118
}
1178
}