use of org.fxmisc.richtext.model.TwoLevelNavigator in project RichTextFX by FXMisc.
the class TextFlowExt method getLineStartPosition.
int getLineStartPosition(int charIdx) {
TextLine[] lines = getLines();
TwoLevelNavigator navigator = new TwoLevelNavigator(() -> lines.length, i -> lines[i].getLength());
int currentLineIndex = navigator.offsetToPosition(charIdx, Forward).getMajor();
return navigator.position(currentLineIndex, 0).toOffset();
}
use of org.fxmisc.richtext.model.TwoLevelNavigator in project RichTextFX by FXMisc.
the class TextFlowExt method getLineOfCharacter.
int getLineOfCharacter(int charIdx) {
TextLine[] lines = getLines();
TwoLevelNavigator navigator = new TwoLevelNavigator(() -> lines.length, i -> lines[i].getLength());
return navigator.offsetToPosition(charIdx, Forward).getMajor();
}
use of org.fxmisc.richtext.model.TwoLevelNavigator in project RichTextFX by FXMisc.
the class TextFlowExt method getLineEndPosition.
int getLineEndPosition(int charIdx) {
TextLine[] lines = getLines();
TwoLevelNavigator navigator = new TwoLevelNavigator(() -> lines.length, i -> lines[i].getLength());
int currentLineIndex = navigator.offsetToPosition(charIdx, Forward).getMajor();
int minor = currentLineIndex == lines.length - 1 ? 0 : -1;
return navigator.position(currentLineIndex + 1, minor).toOffset();
}
Aggregations