Summary
Add APIs to configure the tab size of Text and TextFlow nodes.
Problem
The current tab size is hard coded to 8 spaces. Text editors often allow for a configurable tab size. Something like that is very difficult to implement well in JavaFX with the current implementation of Text and TextFlow. Work-arounds such as inserting spaces instead of tabs results in a poor user experience when navigating the text.
Solution
Introduce a tabSize property and a corresponding -fx-tab-size CSS property to Text and TextFlow nodes, along with APIs to configure and query this property. This integer property will set the tab size as a number of spaces in the current font.
Specification
Text.java
/**
* The size of a tab stop in spaces.
* Values less than 1 are treated as 1.
*
* @defaultValue 8
*
* @since 14
*/
public final IntegerProperty tabSizeProperty() { }
public final void setTabSize(int spaces) { }
public final int getTabSize() { }
TextFlow.java
/**
* The size of a tab stop in spaces.
* Values less than 1 are treated as 1. This value overrides the
* {@code tabSize} of contained {@link Text} nodes.
*
* @defaultValue 8
*
* @since 14
*/
public final IntegerProperty tabSizeProperty() { }
public final void setTabSize(int spaces) { }
public final int getTabSize() { }
csssref.html
Text
Style class: empty by default
CSS Property Values Default
-fx-tab-size <integer> 8
- csr of
-
JDK-8130738 Add tabSize property to Text and TextFlow
- Resolved