I believe the darker yellow colored region is the default "mark all" color. I think the problem here is twofold. First, you still have the default mark occurrences functionality enabled, which you don't want to do since you're providing your own substitute functionality with MarkAllOccurrencesSupport. Not really a problem, but something to note.
Oh, yes, indeed, I had forgotten green was not the default for highlights. Sorry.
I disabled the default highlighting and i now only get the new one.
The second problem is a bug in the code snippet I provided earlier.
Note the bug was that the second parameter to JTextComponent.getText(int start, int len) is the length of the string to get, not the end offset.
I see. No problem.
By the way, the end-start
+1 is correct, but there is a "Caret c = textArea.getCaret();" missing at the beginning of course. Not a big deal.
Hope this helps!
Definitely. I'm getting close (errr, I should say
you are getting close

)
But there's still a glitch

The highlights work, but every time the timer fires (every second), it brings back the "caret" line in the view. In other words, if you have a 200 lines text shown in a 100-line view (so only half of it is visible) and line 1 is currently highlighted, if you try to scroll down to see the second half of the text, the text will jump back to the start, which is really annoying

I think this is due to markAll() fiddling with setCaretPosition() to search for occurrences, causing "state changed" events to be fired on the caret, which in turn cause the line highlighter to be brought in view.
Does it make sense ? Is there a simple way to avoid this ? Having a one-shot delay at each caret position change instead of a repeating timer maybe ?
Edit : now wait, it doesn't repeat. I guess there is something else in my code refreshing the view regularly that interferes with the setCaretPosition() in markAll()... I'm having a look.
Kind regards,
Vicne
[quote]I believe the darker yellow colored region is the default "mark all" color. I think the problem here is twofold. First, you still have the default mark occurrences functionality enabled, which you don't want to do since you're providing your own substitute functionality with MarkAllOccurrencesSupport. Not really a problem, but something to note.
[/quote]
Oh, yes, indeed, I had forgotten green was not the default for highlights. Sorry.
I disabled the default highlighting and i now only get the new one.
[quote]The second problem is a bug in the code snippet I provided earlier.
Note the bug was that the second parameter to JTextComponent.getText(int start, int len) is the [b]length[/b] of the string to get, not the end offset.
[/quote]
I see. No problem.
By the way, the end-start[u]+1[/u] is correct, but there is a "Caret c = textArea.getCaret();" missing at the beginning of course. Not a big deal.
[quote]Hope this helps![/quote]
Definitely. I'm getting close (errr, I should say [i]you[/i] are getting close ;-))
But there's still a glitch :-(
The highlights work, but every time the timer fires (every second), it brings back the "caret" line in the view. In other words, if you have a 200 lines text shown in a 100-line view (so only half of it is visible) and line 1 is currently highlighted, if you try to scroll down to see the second half of the text, the text will jump back to the start, which is really annoying :-(
I think this is due to markAll() fiddling with setCaretPosition() to search for occurrences, causing "state changed" events to be fired on the caret, which in turn cause the line highlighter to be brought in view.
Does it make sense ? Is there a simple way to avoid this ? Having a one-shot delay at each caret position change instead of a repeating timer maybe ?
Edit : now wait, it doesn't repeat. I guess there is something else in my code refreshing the view regularly that interferes with the setCaretPosition() in markAll()... I'm having a look.
Kind regards,
Vicne