How to use InlayModel.addBlockElement to have multiline text
Hello, i have a very hard time figuring out how to properly use InlayModel.addBlockElement. I want automatic multiline text splitting if the text is to long. I have implemented EditorCustomElementRenderer and tried to use a JBTextArea with it but my problem is the painting.
I have no clue how to draw the whole JBTextArea and not only the string with graphics.drawString, because that is single line.
See my class:
public class MyClass implements EditorCustomElementRenderer {
private JBTextArea textArea;
private Color color;
public MyClass(final String problemMessage, Color color) {
textArea = new JBTextArea(problemMessage);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
this.color = color;
}
@Override
public void paint(@NotNull Inlay inlay, @NotNull Graphics graphics, @NotNull Rectangle targetRegion, @NotNull TextAttributes textAttributes) {
Editor editor = inlay.getEditor();
EditorColorsScheme colorsScheme = editor.getColorsScheme();
graphics.setFont(colorsScheme.getFont(EditorFontType.PLAIN));
graphics.setColor(color);
// todo how to draw the textArea instead of the string?
graphics.drawString(textArea.getText(), targetRegion.x, targetRegion.y + editor.getAscent());
}
Thanks a lot.
Post is closed for comments.
answered in slack