Skip to content

Commit fc41a6a

Browse files
Merge pull request #489 from AlexP11223/fix-lnf
Fix line numbers alignment and change default padding to spaces. #488
2 parents eb6d4bf + 191d430 commit fc41a6a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

richtextfx/src/main/java/org/fxmisc/richtext/LineNumberFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.function.IntFunction;
44

55
import javafx.geometry.Insets;
6+
import javafx.geometry.Pos;
67
import javafx.scene.Node;
78
import javafx.scene.control.Label;
89
import javafx.scene.layout.Background;
@@ -29,7 +30,7 @@ public class LineNumberFactory implements IntFunction<Node> {
2930
new Background(new BackgroundFill(Color.web("#ddd"), null, null));
3031

3132
public static IntFunction<Node> get(GenericStyledArea<?, ?, ?> area) {
32-
return get(area, digits -> "%0" + digits + "d");
33+
return get(area, digits -> "%1$" + digits + "s");
3334
}
3435

3536
public static IntFunction<Node> get(
@@ -57,6 +58,7 @@ public Node apply(int idx) {
5758
lineNo.setBackground(DEFAULT_BACKGROUND);
5859
lineNo.setTextFill(DEFAULT_TEXT_FILL);
5960
lineNo.setPadding(DEFAULT_INSETS);
61+
lineNo.setAlignment(Pos.TOP_RIGHT);
6062
lineNo.getStyleClass().add("lineno");
6163

6264
// bind label's text to a Val that stops observing area's paragraphs

0 commit comments

Comments
 (0)