Using visual annotations with JDT text editor [message #635715] |
Wed, 27 October 2010 15:39  |
Eclipse User |
|
|
|
Hello,
I'd like to highlight certain regions of a JDT text editior (e.g. variables). I think this can be done with annotations and markers and I've started by adding code:
IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
Annotation annotation = new Annotation("type", true, "text");
annotationModel.addAnnotation(annotation, new Position(textSelected.getOffset(), textSelected.getLength()));
I'm not sure what "type" and "text" should be. Also, how Markers fit. I guess I could use a standard marker and associate that with those areas of text I would like to highlight but it would be better if I could highlight with squiggly colored lines or similar.
Any pointers to a tutorial or cookbook code to do this would be helpful
Chris
|
|
|
Re: Using visual annotations with JDT text editor [message #636107 is a reply to message #635715] |
Fri, 29 October 2010 06:23  |
Eclipse User |
|
|
|
Chris wrote:
> Hello,
>
> I'd like to highlight certain regions of a JDT text editior (e.g.
> variables). I think this can be done with annotations and markers and
> I've started by adding code:
>
>
> IAnnotationModel annotationModel =
> editor.getDocumentProvider().getAnnotationModel(editor.getEd itorInput());
>
> Annotation annotation = new Annotation("type", true, "text");
> annotationModel.addAnnotation(annotation, new
> Position(textSelected.getOffset(), textSelected.getLength()));
>
>
> I'm not sure what "type" and "text" should be. Also, how Markers fit.
> I guess I could use a standard marker and associate that with those
> areas of text I would like to highlight but it would be better if I
> could highlight with squiggly colored lines or similar.
>
> Any pointers to a tutorial or cookbook code to do this would be helpful
http://www.eclipse.org/eclipse/platform-text/eclipseCon/2006 /texteditorrecipes.zip
Dani
>
> Chris
>
|
|
|
Powered by
FUDForum. Page generated in 0.03699 seconds