@@ -72,7 +72,7 @@ @implementation MMTextStorage
7272- (id )init
7373{
7474 if ((self = [super init ])) {
75- attribString = [[NSMutableAttributedString alloc ] initWithString: @" " ];
75+ backingStore = [[NSTextStorage alloc ] init ];
7676 // NOTE! It does not matter which font is set here, Vim will set its
7777 // own font on startup anyway. Just set some bogus values.
7878 font = [[NSFont userFixedPitchFontOfSize: 0 ] retain ];
@@ -104,19 +104,19 @@ - (void)dealloc
104104 [font release ]; font = nil ;
105105 [defaultBackgroundColor release ]; defaultBackgroundColor = nil ;
106106 [defaultForegroundColor release ]; defaultForegroundColor = nil ;
107- [attribString release ]; attribString = nil ;
107+ [backingStore release ]; backingStore = nil ;
108108 [super dealloc ];
109109}
110110
111111- (NSString *)string
112112{
113- return [attribString string ];
113+ return [backingStore string ];
114114}
115115
116116- (NSDictionary *)attributesAtIndex : (NSUInteger )index
117117 effectiveRange : (NSRangePointer )range
118118{
119- return [attribString attributesAtIndex: index effectiveRange: range];
119+ return [backingStore attributesAtIndex: index effectiveRange: range];
120120}
121121
122122- (void )replaceCharactersInRange : (NSRange )range
@@ -126,15 +126,15 @@ - (void)replaceCharactersInRange:(NSRange)range
126126 ASLogWarn (@" Calling %@ on MMTextStorage is unsupported" ,
127127 NSStringFromSelector (_cmd));
128128#endif
129- // [attribString replaceCharactersInRange:range withString:string];
129+ // [backingStore replaceCharactersInRange:range withString:string];
130130}
131131
132132- (void )setAttributes : (NSDictionary *)attributes range : (NSRange )range
133133{
134134 // NOTE! This method must be implemented since the text system calls it
135135 // constantly to 'fix attributes', apply font substitution, etc.
136136#if 0
137- [attribString setAttributes:attributes range:range];
137+ [backingStore setAttributes:attributes range:range];
138138#elif 1
139139 // HACK! If the font attribute is being modified, then ensure that the new
140140 // font has a fixed advancement which is either the same as the current
@@ -153,7 +153,7 @@ - (void)setAttributes:(NSDictionary *)attributes range:(NSRange)range
153153 return;
154154
155155 float adv = cellSize.width;
156- if ([attribString attribute:MMWideCharacterAttributeName
156+ if ([backingStore attribute:MMWideCharacterAttributeName
157157 atIndex:range.location
158158 effectiveRange:NULL])
159159 adv += adv;
@@ -170,9 +170,9 @@ - (void)setAttributes:(NSDictionary *)attributes range:(NSRange)range
170170 dictionaryWithDictionary:attributes];
171171 [newAttr setObject:newFont forKey:NSFontAttributeName];
172172
173- [attribString setAttributes:newAttr range:range];
173+ [backingStore setAttributes:newAttr range:range];
174174 } else {
175- [attribString setAttributes:attributes range:range];
175+ [backingStore setAttributes:attributes range:range];
176176 }
177177#endif
178178}
@@ -329,34 +329,34 @@ - (void)drawString:(NSString *)string atRow:(int)row column:(int)col
329329 }
330330
331331 // Mark these characters as wide. This attribute is subsequently checked
332- // when translating (row,col) pairs to offsets within 'attribString '.
332+ // when translating (row,col) pairs to offsets within 'backingStore '.
333333 if (flags & DRAW_WIDE)
334334 [attributes setObject: [NSNull null ]
335335 forKey: MMWideCharacterAttributeName];
336336
337337 // Replace characters in text storage and apply new attributes.
338338 NSRange r = NSMakeRange (range.location , [string length ]);
339- [attribString replaceCharactersInRange: range withString: string];
340- [attribString setAttributes: attributes range: r];
339+ [backingStore replaceCharactersInRange: range withString: string];
340+ [backingStore setAttributes: attributes range: r];
341341
342342 NSInteger changeInLength = [string length ] - range.length ;
343343 if (acells != cells || acol != col) {
344344 if (acells == cells + 1 ) {
345345 // NOTE: A normal width character replaced a double width
346346 // character. To maintain the invariant that each row covers the
347347 // same amount of cells, we compensate by adding an empty column.
348- [attribString replaceCharactersInRange: NSMakeRange (NSMaxRange (r),0 )
348+ [backingStore replaceCharactersInRange: NSMakeRange (NSMaxRange (r),0 )
349349 withAttributedString: [emptyRowString
350350 attributedSubstringFromRange: NSMakeRange (0 ,1 )]];
351351 ++changeInLength;
352352#if 0
353353 } else if (acol == col - 1) {
354- [attribString replaceCharactersInRange:NSMakeRange(r.location,0)
354+ [backingStore replaceCharactersInRange:NSMakeRange(r.location,0)
355355 withAttributedString:[emptyRowString
356356 attributedSubstringFromRange:NSMakeRange(0,1)]];
357357 ++changeInLength;
358358 } else if (acol == col + 1) {
359- [attribString replaceCharactersInRange:NSMakeRange(r.location-1,1)
359+ [backingStore replaceCharactersInRange:NSMakeRange(r.location-1,1)
360360 withAttributedString:[emptyRowString
361361 attributedSubstringFromRange:NSMakeRange(0,2)]];
362362 ++changeInLength;
@@ -435,10 +435,10 @@ - (void)deleteLinesFromRow:(int)row lineCount:(int)count
435435 return ;
436436 }
437437
438- NSAttributedString *srcString = [attribString
438+ NSAttributedString *srcString = [backingStore
439439 attributedSubstringFromRange: srcRange];
440440
441- [attribString replaceCharactersInRange: destRange
441+ [backingStore replaceCharactersInRange: destRange
442442 withAttributedString: srcString];
443443 [self edited: (NSTextStorageEditedCharacters
444444 | NSTextStorageEditedAttributes) range: destRange
@@ -471,9 +471,9 @@ - (void)deleteLinesFromRow:(int)row lineCount:(int)count
471471 return ;
472472 }
473473
474- [attribString replaceCharactersInRange: destRange
474+ [backingStore replaceCharactersInRange: destRange
475475 withAttributedString: emptyString];
476- [attribString setAttributes: attribs
476+ [backingStore setAttributes: attribs
477477 range: NSMakeRange (destRange.location, width)];
478478
479479 [self edited: (NSTextStorageEditedAttributes
@@ -531,9 +531,9 @@ - (void)insertLinesAtRow:(int)row lineCount:(int)count
531531 return ;
532532 }
533533
534- NSAttributedString *srcString = [attribString
534+ NSAttributedString *srcString = [backingStore
535535 attributedSubstringFromRange: srcRange];
536- [attribString replaceCharactersInRange: destRange
536+ [backingStore replaceCharactersInRange: destRange
537537 withAttributedString: srcString];
538538 [self edited: (NSTextStorageEditedCharacters
539539 | NSTextStorageEditedAttributes) range: destRange
@@ -566,9 +566,9 @@ - (void)insertLinesAtRow:(int)row lineCount:(int)count
566566 return ;
567567 }
568568
569- [attribString replaceCharactersInRange: destRange
569+ [backingStore replaceCharactersInRange: destRange
570570 withAttributedString: emptyString];
571- [attribString setAttributes: attribs
571+ [backingStore setAttributes: attribs
572572 range: NSMakeRange (destRange.location, width)];
573573
574574 [self edited: (NSTextStorageEditedAttributes
@@ -613,9 +613,9 @@ - (void)clearBlockFromRow:(int)row1 column:(int)col1 toRow:(int)row2
613613 return ;
614614 }
615615
616- [attribString replaceCharactersInRange: range
616+ [backingStore replaceCharactersInRange: range
617617 withAttributedString: emptyString];
618- [attribString setAttributes: attribs
618+ [backingStore setAttributes: attribs
619619 range: NSMakeRange (range.location, cells)];
620620
621621 [self edited: (NSTextStorageEditedAttributes
@@ -917,7 +917,7 @@ - (NSRect)boundingRectForCharacterAtRow:(int)row column:(int)col
917917 int cells = 1 ;
918918 NSRange r = [self charRangeForRow: row column: &col cells: &cells];
919919 if (NSNotFound != r.location
920- && [attribString attribute: MMWideCharacterAttributeName
920+ && [backingStore attribute: MMWideCharacterAttributeName
921921 atIndex: r.location
922922 effectiveRange: nil ])
923923 rect.size .width += rect.size .width ;
@@ -958,7 +958,7 @@ - (void)lazyResize:(BOOL)force
958958 if (!force && actualRows == maxRows && actualColumns == maxColumns)
959959 return ;
960960
961- NSRange oldRange = NSMakeRange (0 , [attribString length ]);
961+ NSRange oldRange = NSMakeRange (0 , [backingStore length ]);
962962
963963 actualRows = maxRows;
964964 actualColumns = maxColumns;
@@ -990,16 +990,16 @@ - (void)lazyResize:(BOOL)force
990990 emptyRowString = [[NSAttributedString alloc ] initWithString: rowString
991991 attributes: dict];
992992
993- [attribString release ];
994- attribString = [[NSMutableAttributedString alloc ] init ];
993+ [backingStore release ];
994+ backingStore = [[NSMutableAttributedString alloc ] init ];
995995 for (i=0 ; i<maxRows; ++i) {
996996#if MM_USE_ROW_CACHE
997997 rowCache[i].length = actualColumns + 1 ;
998998#endif
999- [attribString appendAttributedString: emptyRowString];
999+ [backingStore appendAttributedString: emptyRowString];
10001000 }
10011001
1002- NSRange fullRange = NSMakeRange (0 , [attribString length ]);
1002+ NSRange fullRange = NSMakeRange (0 , [backingStore length ]);
10031003 [self edited: (NSTextStorageEditedCharacters|NSTextStorageEditedAttributes)
10041004 range: oldRange changeInLength: fullRange.length-oldRange.length];
10051005}
@@ -1014,7 +1014,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
10141014 if (characterEqualsColumn)
10151015 return NSMakeRange (row*(actualColumns+1 ) + col, cells);
10161016
1017- NSString *string = [attribString string ];
1017+ NSString *string = [backingStore string ];
10181018 unsigned stringLen = [string length ];
10191019 NSRange r, range = { NSNotFound , 0 };
10201020 unsigned idx;
@@ -1082,7 +1082,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
10821082 r = [string rangeOfComposedCharacterSequenceAtIndex:idx];
10831083
10841084 // Wide chars take up two display cells.
1085- if ([attribString attribute:MMWideCharacterAttributeName
1085+ if ([backingStore attribute:MMWideCharacterAttributeName
10861086 atIndex:idx
10871087 effectiveRange:nil])
10881088 ++i;
@@ -1100,7 +1100,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
11001100 --i;
11011101
11021102 // Wide chars take up two display cells.
1103- if ([attribString attribute:MMWideCharacterAttributeName
1103+ if ([backingStore attribute:MMWideCharacterAttributeName
11041104 atIndex:idx
11051105 effectiveRange:nil])
11061106 --i;
@@ -1127,7 +1127,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
11271127 r = [string rangeOfComposedCharacterSequenceAtIndex: idx];
11281128
11291129 // Wide chars take up two display cells.
1130- if ([attribString attribute: MMWideCharacterAttributeName
1130+ if ([backingStore attribute: MMWideCharacterAttributeName
11311131 atIndex: idx
11321132 effectiveRange: nil ])
11331133 ++i;
@@ -1149,7 +1149,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
11491149 r = [string rangeOfComposedCharacterSequenceAtIndex: idx];
11501150
11511151 // Wide chars take up two display cells.
1152- if ([attribString attribute: MMWideCharacterAttributeName
1152+ if ([backingStore attribute: MMWideCharacterAttributeName
11531153 atIndex: idx
11541154 effectiveRange: nil ])
11551155 ++i;
@@ -1166,7 +1166,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
11661166 r = [string rangeOfComposedCharacterSequenceAtIndex: idx];
11671167
11681168 // Wide chars take up two display cells.
1169- if ([attribString attribute: MMWideCharacterAttributeName
1169+ if ([backingStore attribute: MMWideCharacterAttributeName
11701170 atIndex: idx
11711171 effectiveRange: nil ])
11721172 ++i;
@@ -1218,14 +1218,14 @@ - (void)fixInvalidCharactersInRange:(NSRange)range
12181218 // TODO: Treat these separately inside of Vim so we don't have to bother
12191219 // here.
12201220 while (range.length > 0 ) {
1221- invalidRange = [[attribString string ]
1221+ invalidRange = [[backingStore string ]
12221222 rangeOfCharacterFromSet: invalidCharacterSet
12231223 options: NSLiteralSearch
12241224 range: range];
12251225 if (NSNotFound == invalidRange.location )
12261226 break ;
12271227
1228- [attribString replaceCharactersInRange: invalidRange withString: @" " ];
1228+ [backingStore replaceCharactersInRange: invalidRange withString: @" " ];
12291229
12301230 end = NSMaxRange (invalidRange);
12311231 range.length -= end - range.location ;
0 commit comments