Skip to content

Commit

Permalink
Merge pull request #577 from JFormDesigner/adjust-wrapped-lines-selec…
Browse files Browse the repository at this point in the history
…tion

adjust wrapped lines selection to the rest of the line
  • Loading branch information
JordanMartinez authored Sep 8, 2017
2 parents e650194 + f97fff8 commit 21bded5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion richtextfx/src/main/java/org/fxmisc/richtext/ParagraphText.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,19 @@ private PathElement[] getRangeShapeSafely(int start, int end) {
shape[bottomRightIndex] = new LineTo(getWidth(), getHeight());
}
}

if (getLineCount() > 1) {
// adjust right corners of wrapped lines
boolean wrappedAtEndPos = (end > 0 && getLineOfCharacter(end) > getLineOfCharacter(end - 1));
int adjustLength = shape.length - (wrappedAtEndPos ? 0 : 5);
for (int i = 0; i < adjustLength; i++) {
if (shape[i] instanceof MoveTo) {
((LineTo)shape[i + 1]).setX(getWidth());
((LineTo)shape[i + 2]).setX(getWidth());
}
}
}

return shape;
}

Expand All @@ -302,7 +315,8 @@ private PathElement[] createRectangle(double topLeftX, double topLeftY, double b
new MoveTo(topLeftX, topLeftY),
new LineTo(bottomRightX, topLeftY),
new LineTo(bottomRightX, bottomRightY),
new LineTo(topLeftX, bottomRightY)
new LineTo(topLeftX, bottomRightY),
new LineTo(topLeftX, topLeftY)
};
}

Expand Down

0 comments on commit 21bded5

Please sign in to comment.