I'm trying to make the bullet of active line have a highlighted background. I'm using
int activeLine = styledText.getLineAtOffset(styledText.getCaretOffset());
To get the like that is currently active. This seems to work except when I hit enter and get a new line.
getCaretOffset returns 35 and getCharCount returns 36.
However, if I click on the last line (for now I call redraw() on clicks) the line highlights correctly and getCaretOffset returns 36.
Here is the relevant code
public void lineGetStyle(LineStyleEvent event) {
// Set the line number
int activeLine = styledText.getLineAtOffset(styledText.getCaretOffset());
System.out.println("Offset " + styledText.getCaretOffset() + " max " + styledText.getCharCount());
int currentLine = styledText.getLineAtOffset(event.lineOffset);
event.bulletIndex = currentLine;
// Set the style, 12 pixles wide for each digit
StyleRange style = new StyleRange();
style.metrics = new GlyphMetrics(0, 0, 36);
if (activeLine == currentLine) {
style.background = highlightedLine;
if (curActiveLine != activeLine){
System.out.println("ActiveLine " + activeLine + " old " + curActiveLine);
int redrawLine = curActiveLine;
curActiveLine = activeLine;
styledText.redraw(0, styledText.getLinePixel(redrawLine), 36, styledText.getLineHeight(),true);
}
}
style.foreground = mainBackground;
// Create and set the bullet
event.bullet = new Bullet(ST.BULLET_NUMBER, style);
event.styles = matchKeywords(event);
}