bobbylight / RSyntaxTextArea

A syntax highlighting, code folding text editor for Java Swing applications.
BSD 3-Clause "New" or "Revised" License
1.12k stars 259 forks source link

Add an image in the middle of the text #478

Closed gvom closed 1 year ago

gvom commented 1 year ago

Hello!

I would like to add a image in the middle of the code text. To allow the user to know with what image he is working. Like this:

image

I already tried to do it this way, but it didn't work:

final SimpleAttributeSet attrs = new SimpleAttributeSet(doc.getParagraphElement(doc.getLength()).getAttributes());
if (StyleConstants.getIcon(attrs) == null) {
StyleConstants.setIcon(attrs, new ImageIcon(imgFile.getAbsolutePath()));
}

if("#{image:".equals(label)) {
identation = UIUtils.getIdentationToNextLine(textSourceCode);
doc.insertString(doc.getLength()-1, identation, attrs);
}else
doc.insertString(doc.getLength(), " ", attrs);

I cannot find a way to do this, if is possible, can you point me the righ way? If is not possible can you add this new feature?

bobbylight commented 1 year ago

RSTA will never support embedding arbitrary images in its text content, but it can render emojis if the fonts being used support them. In such cases, they are rendered if the appropriate code point is in the content.