Is it possible? I tought the com.intellij.openapi.editor.markup would be the starting point, but there is no example. Even not a single javadoc comment! Can anybody please provide an example?
Hi! It is pretty straightforward. Obtain a reference to MarkupModel interface from the instance of Editor interface and then invoke methods of MarkupModel to implement you highlighting. I can provide you with example of how it works in case you still need it. By the way, there seem to be a bug (though I am not that sure): when I invoke addRangeHighlighter method it highlights a region exactly one line below of what I expect. Cheers.
Something like that: editor.getMarkupModel().addRangeHighlighter(startOffset, endOffset, layer, attrs, HighlighterTargetArea.EXACT_RANGE);
>
Isn't that highlighting as meant to be used for find results and errors? It looked like the original poster was asking about syntax highlighting.
Umm, well, you can do any sort of highlighting/coloring with that. As there's to my knowledge no explicit syntax highlighting API available, this is probably the best thing that's possible. I even believe that the internal syntax coloring uses the same mechanism (see com.intellij.openapi.editor.markup.HighlighterLayer).
>In case you're still reading this forum, could you please give me some code snippeds on how to do my own highlighting?
>
Not sure this is what you have in mind, but if you wish a new file type - ex. Velocity - to be highlighted, you can specify keywords to highlight in : IDE settings.File type. Edit.syntax highlighting.
Hi!
It is pretty straightforward. Obtain a reference to MarkupModel interface from the instance of Editor interface and then invoke methods of MarkupModel to implement you highlighting. I can provide you with example of how it works in case you still need it.
By the way, there seem to be a bug (though I am not that sure): when I invoke addRangeHighlighter method it highlights a region exactly one line below of what I expect.
Cheers.
Sergey
Sorry, no bug with highlighting. My fault
to Sergey:
In case you're still reading this forum, could you please give me some code snippeds on how to do my own highlighting?
Thanks
Jörg
J?rg B?sner wrote:
>to Sergey:
>
>In case you're still reading this forum, could you please give me some code snippeds on how to do my own highlighting?
>
>
I'm not S?rg?y, but I think you should find some in the
SmartIntroduceVariable plugin
Al?a?n.
Alain Ravet wrote:
Thanks for promoting the plugin, but if my memory doesn't let me
down, it only uses custom selections, not arbitrary highlighting. ;)
Custom highlighting isn't too far away though, just get the MarkupModel
from an Editor instance and explore its capabilities ;)
Something like that:
editor.getMarkupModel().addRangeHighlighter(startOffset, endOffset, layer, attrs,
HighlighterTargetArea.EXACT_RANGE);
Sascha
Sascha Weinreuter wrote:
Isn't that highlighting as meant to be used for find results and errors?
It looked like the original poster was asking about syntax highlighting.
Ciao,
Gordon
--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919
Gordon Tyler wrote:
>
Umm, well, you can do any sort of highlighting/coloring with that. As there's to my
knowledge no explicit syntax highlighting API available, this is probably the best thing
that's possible. I even believe that the internal syntax coloring uses the same mechanism
(see com.intellij.openapi.editor.markup.HighlighterLayer).
Sascha
J?rg B?sner wrote:
>In case you're still reading this forum, could you please give me some code snippeds on how to do my own highlighting?
>
Not sure this is what you have in mind, but if you wish a new file type
- ex. Velocity - to be highlighted, you can specify keywords to
highlight in :
IDE settings.File type. Edit.syntax highlighting.
Alain