diff --git a/MMTextStorage.h b/MMTextStorage.h index 0768793ca5..b2b619fd5b 100644 --- a/MMTextStorage.h +++ b/MMTextStorage.h @@ -36,6 +36,8 @@ - (int)maxRows; - (int)maxColumns; +- (int)actualRows; +- (int)actualColumns; - (void)getMaxRows:(int*)rows columns:(int*)cols; - (void)setMaxRows:(int)rows columns:(int)cols; - (void)replaceString:(NSString *)string atRow:(int)row column:(int)col diff --git a/MMTextStorage.m b/MMTextStorage.m index 8694d54195..ede428935a 100644 --- a/MMTextStorage.m +++ b/MMTextStorage.m @@ -143,6 +143,16 @@ return maxColumns; } +- (int)actualRows +{ + return actualRows; +} + +- (int)actualColumns +{ + return actualColumns; +} + - (void)getMaxRows:(int*)rows columns:(int*)cols { if (rows) *rows = maxRows; diff --git a/MMTypesetter.m b/MMTypesetter.m index 388107dd9c..e847892d3d 100644 --- a/MMTypesetter.m +++ b/MMTypesetter.m @@ -13,6 +13,8 @@ #import "MacVim.h" +#define MM_USE_LINERANGE 0 + #if 0 @interface MMTypesetter (Private) @@ -61,6 +63,7 @@ unsigned i, numberOfLines = 0, firstLine = 0; NSRange firstLineRange = { 0, 0 }; +#if MM_USE_LINERANGE // Find the first line and its range, and count the number of lines. (This // info could also be gleaned from MMTextStorage, but we do it here anyway // to make absolutely sure everything is right.) @@ -73,6 +76,14 @@ i = NSMaxRange(lineRange); } +#else + unsigned stride = 1 + [ts actualColumns]; + numberOfLines = [ts actualRows]; + firstLine = (unsigned)(startCharIdx/stride); + firstLineRange.location = firstLine * stride; + unsigned len = [text length] - firstLineRange.location; + firstLineRange.length = len < stride ? len : stride; +#endif // Perform line fragment generation one line at a time. NSRange lineRange = firstLineRange; @@ -105,7 +116,14 @@ } } +#if MM_USE_LINERANGE lineRange = [text lineRangeForRange:NSMakeRange(endLineIdx, 0)]; +#else + lineRange.location = endLineIdx; + len = [text length] - lineRange.location; + if (len < lineRange.length) + lineRange.length = len; +#endif } if (nextGlyph)