Fix line number drawing with large number (fix #370)

This commit is contained in:
1024jp 2015-03-16 02:27:57 +09:00
parent e0adfe01e9
commit d590507253
2 changed files with 20 additions and 4 deletions

View File

@ -10,6 +10,11 @@ develop
- Revert find panel behavior to select always whole text in find field when the panel is called.
### Fixes
- Fix line number drawing with large line numbers.
2.1.2
--------------------------

View File

@ -34,7 +34,7 @@
#import "constants.h"
const CGFloat kMinVerticalThickness = 32.0;
static const CGFloat kMinVerticalThickness = 32.0;
@interface CELineNumberView ()
@ -86,6 +86,17 @@ static const NSString *LineNumberFontName;
}
// ------------------------------------------------------
/// setup initial size
- (void)viewDidMoveToSuperview
// ------------------------------------------------------
{
[super viewDidMoveToSuperview];
[self setRuleThickness:kMinVerticalThickness];
}
// ------------------------------------------------------
/// clean up
- (void)dealloc
@ -158,7 +169,7 @@ static const NSString *LineNumberFontName;
CGFloat charWidth = advance.width;
// prepare frame width
CGFloat width = kMinVerticalThickness;
CGFloat width = [self ruleThickness];
// adjust drawing coordinate
NSPoint relativePoint = [self convertPoint:NSZeroPoint fromView:[self textView]];
@ -237,11 +248,11 @@ static const NSString *LineNumberFontName;
CGContextShowGlyphsAtPositions(context, glyphs, positions, digit); // draw line number
}
CGContextRestoreGState(context);
// adjust thickness
CGFloat requiredWidth = MAX(numberOfDigits(lineNum) * charWidth + 3 * kLineNumPadding, kMinVerticalThickness);
[self setRuleThickness:ceil(requiredWidth)];
CGContextRestoreGState(context);
}