Clip to cell when drawing insertion point

This fixes an issue where the cursor would spill over into the
neighboring cells on Retina displays (only).
This commit is contained in:
Bjorn Winckler
2012-08-10 21:24:15 +02:00
parent a1f636d72a
commit ce5b7a2d6d
+10 -1
View File
@@ -1241,6 +1241,9 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGSize *advances,
{
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
NSRect rect = [self rectForRow:row column:col numRows:1 numColumns:1];
CGRect clipRect = *(CGRect *)▭
CGContextSaveGState(context);
if (MMInsertionPointHorizontal == shape) {
int frac = (cellSize.height * percent + 99)/100;
@@ -1259,6 +1262,12 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGSize *advances,
// over into adjacent display cells and it may look ugly.
CGContextSetShouldAntialias(context, NO);
// Even though antialiasing is disabled and we adjust the rect to fit
// inside the display cell it still happens on Retina displays (only) that
// the cursor bleeds over into the neighboring cells. To work around this
// issue we enable clipping.
CGContextClipToRect(context, clipRect);
if (MMInsertionPointHollow == shape) {
// When stroking a rect its size is effectively 1 pixel wider/higher
// than we want so make it smaller to avoid having it bleed over into
@@ -1275,7 +1284,7 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGSize *advances,
CGContextFillRect(context, *(CGRect*)&rect);
}
CGContextSetShouldAntialias(context, antialias);
CGContextRestoreGState(context);
}
- (void)drawInvertedRectAtRow:(int)row column:(int)col numRows:(int)nrows