@@ -72,7 +72,7 @@ @implementation MMTextStorage
72
72
- (id )init
73
73
{
74
74
if ((self = [super init ])) {
75
- attribString = [[NSMutableAttributedString alloc ] initWithString: @" " ];
75
+ backingStore = [[NSTextStorage alloc ] init ];
76
76
// NOTE! It does not matter which font is set here, Vim will set its
77
77
// own font on startup anyway. Just set some bogus values.
78
78
font = [[NSFont userFixedPitchFontOfSize: 0 ] retain ];
@@ -104,19 +104,19 @@ - (void)dealloc
104
104
[font release ]; font = nil ;
105
105
[defaultBackgroundColor release ]; defaultBackgroundColor = nil ;
106
106
[defaultForegroundColor release ]; defaultForegroundColor = nil ;
107
- [attribString release ]; attribString = nil ;
107
+ [backingStore release ]; backingStore = nil ;
108
108
[super dealloc ];
109
109
}
110
110
111
111
- (NSString *)string
112
112
{
113
- return [attribString string ];
113
+ return [backingStore string ];
114
114
}
115
115
116
116
- (NSDictionary *)attributesAtIndex : (NSUInteger )index
117
117
effectiveRange : (NSRangePointer )range
118
118
{
119
- return [attribString attributesAtIndex: index effectiveRange: range];
119
+ return [backingStore attributesAtIndex: index effectiveRange: range];
120
120
}
121
121
122
122
- (void )replaceCharactersInRange : (NSRange )range
@@ -126,15 +126,15 @@ - (void)replaceCharactersInRange:(NSRange)range
126
126
ASLogWarn (@" Calling %@ on MMTextStorage is unsupported" ,
127
127
NSStringFromSelector (_cmd));
128
128
#endif
129
- // [attribString replaceCharactersInRange:range withString:string];
129
+ // [backingStore replaceCharactersInRange:range withString:string];
130
130
}
131
131
132
132
- (void )setAttributes : (NSDictionary *)attributes range : (NSRange )range
133
133
{
134
134
// NOTE! This method must be implemented since the text system calls it
135
135
// constantly to 'fix attributes', apply font substitution, etc.
136
136
#if 0
137
- [attribString setAttributes:attributes range:range];
137
+ [backingStore setAttributes:attributes range:range];
138
138
#elif 1
139
139
// HACK! If the font attribute is being modified, then ensure that the new
140
140
// font has a fixed advancement which is either the same as the current
@@ -153,7 +153,7 @@ - (void)setAttributes:(NSDictionary *)attributes range:(NSRange)range
153
153
return;
154
154
155
155
float adv = cellSize.width;
156
- if ([attribString attribute:MMWideCharacterAttributeName
156
+ if ([backingStore attribute:MMWideCharacterAttributeName
157
157
atIndex:range.location
158
158
effectiveRange:NULL])
159
159
adv += adv;
@@ -170,9 +170,9 @@ - (void)setAttributes:(NSDictionary *)attributes range:(NSRange)range
170
170
dictionaryWithDictionary:attributes];
171
171
[newAttr setObject:newFont forKey:NSFontAttributeName];
172
172
173
- [attribString setAttributes:newAttr range:range];
173
+ [backingStore setAttributes:newAttr range:range];
174
174
} else {
175
- [attribString setAttributes:attributes range:range];
175
+ [backingStore setAttributes:attributes range:range];
176
176
}
177
177
#endif
178
178
}
@@ -329,34 +329,34 @@ - (void)drawString:(NSString *)string atRow:(int)row column:(int)col
329
329
}
330
330
331
331
// 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 '.
333
333
if (flags & DRAW_WIDE)
334
334
[attributes setObject: [NSNull null ]
335
335
forKey: MMWideCharacterAttributeName];
336
336
337
337
// Replace characters in text storage and apply new attributes.
338
338
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];
341
341
342
342
NSInteger changeInLength = [string length ] - range.length ;
343
343
if (acells != cells || acol != col) {
344
344
if (acells == cells + 1 ) {
345
345
// NOTE: A normal width character replaced a double width
346
346
// character. To maintain the invariant that each row covers the
347
347
// 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 )
349
349
withAttributedString: [emptyRowString
350
350
attributedSubstringFromRange: NSMakeRange (0 ,1 )]];
351
351
++changeInLength;
352
352
#if 0
353
353
} else if (acol == col - 1) {
354
- [attribString replaceCharactersInRange:NSMakeRange(r.location,0)
354
+ [backingStore replaceCharactersInRange:NSMakeRange(r.location,0)
355
355
withAttributedString:[emptyRowString
356
356
attributedSubstringFromRange:NSMakeRange(0,1)]];
357
357
++changeInLength;
358
358
} else if (acol == col + 1) {
359
- [attribString replaceCharactersInRange:NSMakeRange(r.location-1,1)
359
+ [backingStore replaceCharactersInRange:NSMakeRange(r.location-1,1)
360
360
withAttributedString:[emptyRowString
361
361
attributedSubstringFromRange:NSMakeRange(0,2)]];
362
362
++changeInLength;
@@ -435,10 +435,10 @@ - (void)deleteLinesFromRow:(int)row lineCount:(int)count
435
435
return ;
436
436
}
437
437
438
- NSAttributedString *srcString = [attribString
438
+ NSAttributedString *srcString = [backingStore
439
439
attributedSubstringFromRange: srcRange];
440
440
441
- [attribString replaceCharactersInRange: destRange
441
+ [backingStore replaceCharactersInRange: destRange
442
442
withAttributedString: srcString];
443
443
[self edited: (NSTextStorageEditedCharacters
444
444
| NSTextStorageEditedAttributes) range: destRange
@@ -471,9 +471,9 @@ - (void)deleteLinesFromRow:(int)row lineCount:(int)count
471
471
return ;
472
472
}
473
473
474
- [attribString replaceCharactersInRange: destRange
474
+ [backingStore replaceCharactersInRange: destRange
475
475
withAttributedString: emptyString];
476
- [attribString setAttributes: attribs
476
+ [backingStore setAttributes: attribs
477
477
range: NSMakeRange (destRange.location, width)];
478
478
479
479
[self edited: (NSTextStorageEditedAttributes
@@ -531,9 +531,9 @@ - (void)insertLinesAtRow:(int)row lineCount:(int)count
531
531
return ;
532
532
}
533
533
534
- NSAttributedString *srcString = [attribString
534
+ NSAttributedString *srcString = [backingStore
535
535
attributedSubstringFromRange: srcRange];
536
- [attribString replaceCharactersInRange: destRange
536
+ [backingStore replaceCharactersInRange: destRange
537
537
withAttributedString: srcString];
538
538
[self edited: (NSTextStorageEditedCharacters
539
539
| NSTextStorageEditedAttributes) range: destRange
@@ -566,9 +566,9 @@ - (void)insertLinesAtRow:(int)row lineCount:(int)count
566
566
return ;
567
567
}
568
568
569
- [attribString replaceCharactersInRange: destRange
569
+ [backingStore replaceCharactersInRange: destRange
570
570
withAttributedString: emptyString];
571
- [attribString setAttributes: attribs
571
+ [backingStore setAttributes: attribs
572
572
range: NSMakeRange (destRange.location, width)];
573
573
574
574
[self edited: (NSTextStorageEditedAttributes
@@ -613,9 +613,9 @@ - (void)clearBlockFromRow:(int)row1 column:(int)col1 toRow:(int)row2
613
613
return ;
614
614
}
615
615
616
- [attribString replaceCharactersInRange: range
616
+ [backingStore replaceCharactersInRange: range
617
617
withAttributedString: emptyString];
618
- [attribString setAttributes: attribs
618
+ [backingStore setAttributes: attribs
619
619
range: NSMakeRange (range.location, cells)];
620
620
621
621
[self edited: (NSTextStorageEditedAttributes
@@ -917,7 +917,7 @@ - (NSRect)boundingRectForCharacterAtRow:(int)row column:(int)col
917
917
int cells = 1 ;
918
918
NSRange r = [self charRangeForRow: row column: &col cells: &cells];
919
919
if (NSNotFound != r.location
920
- && [attribString attribute: MMWideCharacterAttributeName
920
+ && [backingStore attribute: MMWideCharacterAttributeName
921
921
atIndex: r.location
922
922
effectiveRange: nil ])
923
923
rect.size .width += rect.size .width ;
@@ -958,7 +958,7 @@ - (void)lazyResize:(BOOL)force
958
958
if (!force && actualRows == maxRows && actualColumns == maxColumns)
959
959
return ;
960
960
961
- NSRange oldRange = NSMakeRange (0 , [attribString length ]);
961
+ NSRange oldRange = NSMakeRange (0 , [backingStore length ]);
962
962
963
963
actualRows = maxRows;
964
964
actualColumns = maxColumns;
@@ -990,16 +990,16 @@ - (void)lazyResize:(BOOL)force
990
990
emptyRowString = [[NSAttributedString alloc ] initWithString: rowString
991
991
attributes: dict];
992
992
993
- [attribString release ];
994
- attribString = [[NSMutableAttributedString alloc ] init ];
993
+ [backingStore release ];
994
+ backingStore = [[NSMutableAttributedString alloc ] init ];
995
995
for (i=0 ; i<maxRows; ++i) {
996
996
#if MM_USE_ROW_CACHE
997
997
rowCache[i].length = actualColumns + 1 ;
998
998
#endif
999
- [attribString appendAttributedString: emptyRowString];
999
+ [backingStore appendAttributedString: emptyRowString];
1000
1000
}
1001
1001
1002
- NSRange fullRange = NSMakeRange (0 , [attribString length ]);
1002
+ NSRange fullRange = NSMakeRange (0 , [backingStore length ]);
1003
1003
[self edited: (NSTextStorageEditedCharacters|NSTextStorageEditedAttributes)
1004
1004
range: oldRange changeInLength: fullRange.length-oldRange.length];
1005
1005
}
@@ -1014,7 +1014,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
1014
1014
if (characterEqualsColumn)
1015
1015
return NSMakeRange (row*(actualColumns+1 ) + col, cells);
1016
1016
1017
- NSString *string = [attribString string ];
1017
+ NSString *string = [backingStore string ];
1018
1018
unsigned stringLen = [string length ];
1019
1019
NSRange r, range = { NSNotFound , 0 };
1020
1020
unsigned idx;
@@ -1082,7 +1082,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
1082
1082
r = [string rangeOfComposedCharacterSequenceAtIndex:idx];
1083
1083
1084
1084
// Wide chars take up two display cells.
1085
- if ([attribString attribute:MMWideCharacterAttributeName
1085
+ if ([backingStore attribute:MMWideCharacterAttributeName
1086
1086
atIndex:idx
1087
1087
effectiveRange:nil])
1088
1088
++i;
@@ -1100,7 +1100,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
1100
1100
--i;
1101
1101
1102
1102
// Wide chars take up two display cells.
1103
- if ([attribString attribute:MMWideCharacterAttributeName
1103
+ if ([backingStore attribute:MMWideCharacterAttributeName
1104
1104
atIndex:idx
1105
1105
effectiveRange:nil])
1106
1106
--i;
@@ -1127,7 +1127,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
1127
1127
r = [string rangeOfComposedCharacterSequenceAtIndex: idx];
1128
1128
1129
1129
// Wide chars take up two display cells.
1130
- if ([attribString attribute: MMWideCharacterAttributeName
1130
+ if ([backingStore attribute: MMWideCharacterAttributeName
1131
1131
atIndex: idx
1132
1132
effectiveRange: nil ])
1133
1133
++i;
@@ -1149,7 +1149,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
1149
1149
r = [string rangeOfComposedCharacterSequenceAtIndex: idx];
1150
1150
1151
1151
// Wide chars take up two display cells.
1152
- if ([attribString attribute: MMWideCharacterAttributeName
1152
+ if ([backingStore attribute: MMWideCharacterAttributeName
1153
1153
atIndex: idx
1154
1154
effectiveRange: nil ])
1155
1155
++i;
@@ -1166,7 +1166,7 @@ - (NSRange)charRangeForRow:(int)row column:(int*)pcol cells:(int*)pcells
1166
1166
r = [string rangeOfComposedCharacterSequenceAtIndex: idx];
1167
1167
1168
1168
// Wide chars take up two display cells.
1169
- if ([attribString attribute: MMWideCharacterAttributeName
1169
+ if ([backingStore attribute: MMWideCharacterAttributeName
1170
1170
atIndex: idx
1171
1171
effectiveRange: nil ])
1172
1172
++i;
@@ -1218,14 +1218,14 @@ - (void)fixInvalidCharactersInRange:(NSRange)range
1218
1218
// TODO: Treat these separately inside of Vim so we don't have to bother
1219
1219
// here.
1220
1220
while (range.length > 0 ) {
1221
- invalidRange = [[attribString string ]
1221
+ invalidRange = [[backingStore string ]
1222
1222
rangeOfCharacterFromSet: invalidCharacterSet
1223
1223
options: NSLiteralSearch
1224
1224
range: range];
1225
1225
if (NSNotFound == invalidRange.location )
1226
1226
break ;
1227
1227
1228
- [attribString replaceCharactersInRange: invalidRange withString: @" " ];
1228
+ [backingStore replaceCharactersInRange: invalidRange withString: @" " ];
1229
1229
1230
1230
end = NSMaxRange (invalidRange);
1231
1231
range.length -= end - range.location ;
0 commit comments