mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Fix line number drawing with large number (fix #370)
This commit is contained in:
parent
e0adfe01e9
commit
d590507253
@ -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
|
||||
--------------------------
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user