-
Notifications
You must be signed in to change notification settings - Fork 268
More Impactful Current Line Number Font. #447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,11 @@ public class LineNumberList extends AbstractGutterComponent | |
| */ | ||
| private Color currentLineNumberColor; | ||
|
|
||
| /** | ||
| * The Increase Required from the base font size of the current line number. | ||
| */ | ||
| private float currentLineNumberFontIncreaseSize = 2f; | ||
|
|
||
| public static final Color DEFAULT_LINE_NUMBER_COLOR = Color.GRAY; | ||
|
|
||
|
|
||
|
|
@@ -387,6 +392,8 @@ protected void paintComponent(Graphics g) { | |
|
|
||
| // Paint line numbers | ||
| boolean ltr = getComponentOrientation().isLeftToRight(); | ||
| Font baseFont = g.getFont(); | ||
| Font currentLineNumberFont = baseFont.deriveFont(Font.BOLD).deriveFont(baseFont.getSize() + currentLineNumberFontIncreaseSize); // Forcing Bold Style on the current line number | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the new field is its own font then we don't have to derive the new font on each call to |
||
| if (ltr) { | ||
| FontMetrics metrics = g.getFontMetrics(); | ||
| int rhs = getWidth() - rhsBorderWidth; | ||
|
|
@@ -397,12 +404,16 @@ protected void paintComponent(Graphics g) { | |
| if (currentLine + 1 == line + getLineNumberingStartIndex() - 1) { | ||
| Color color = currentLineNumberColor != null ? currentLineNumberColor : | ||
| getForeground(); | ||
| g.setFont(currentLineNumberFont); | ||
| g.setColor(color); | ||
| // Calculating the shift width required in Left to Right View Mode since the current line number font will have a greater size than the base font. | ||
| g.drawString(number, rhs - width - (g.getFontMetrics().stringWidth(number) - g.getFontMetrics(baseFont).stringWidth(number)), y); | ||
| } | ||
| else { | ||
| g.setFont(baseFont); | ||
| g.setColor(getForeground()); | ||
| g.drawString(number, rhs-width, y); | ||
| } | ||
| g.drawString(number, rhs-width,y); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| y += cellHeight; | ||
| if (fm!=null) { | ||
| Fold fold = fm.getFoldForLine(line-1); | ||
|
|
@@ -430,11 +441,13 @@ protected void paintComponent(Graphics g) { | |
| Color color = currentLineNumberColor != null ? currentLineNumberColor : | ||
| getForeground(); | ||
| g.setColor(color); | ||
| // Calculating the shift width required in Right to Left View Mode since the current line number font will have a greater size than the base font. | ||
| g.drawString(number, rhsBorderWidth + (g.getFontMetrics().stringWidth(number) - g.getFontMetrics(baseFont).stringWidth(number)), y); | ||
| } | ||
| else { | ||
| g.setColor(getForeground()); | ||
| g.drawString(number, rhsBorderWidth, y); | ||
| } | ||
| g.drawString(number, rhsBorderWidth, y); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same changes here as in the LTR case |
||
| y += cellHeight; | ||
| if (fm!=null) { | ||
| Fold fold = fm.getFoldForLine(line-1); | ||
|
|
@@ -726,7 +739,10 @@ void updateCellWidths() { | |
| lineCount = lineCount/10; | ||
| count++; | ||
| } while (lineCount >= 10); | ||
| cellWidth += fontMetrics.charWidth('9')*(count+1) + 3; | ||
| // This was required since the current line number has a higher font size so the previous method can cause the first digit of the | ||
| // number to go out of bounds of the line number list. | ||
| // Maybe there is some better solution to this situation. | ||
| cellWidth += fontMetrics.charWidth('9')*(count+1) + (fontMetrics.charWidth('9') * (int)currentLineNumberFontIncreaseSize); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming we just move to a Font font = getFont();
FontMetrics fontMetrics = font.getFontMetrics();
int charWidth = fontMetrics.charWidth('9');
if (currentLineNumberFont != null) {
int charWidth2 = currentLineNumberFont.getFontMetrics().charWidth('9');
charWidth = Math.max(charWidth, charWidth2);
}
...
cellWidth += charWidth * (count + 1) + 3;Might even move that |
||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.