best way to refresh/update syntax highlighting? [message #466608] |
Sun, 22 April 2007 20:31 |
Eclipse User |
|
|
|
Originally posted by: jweeks.neuraldk.org
Hello,
I have developed an editor, which extends TextEditor, that has a context
menu that allows certain (user defined) keywords in the text to be
highlighted a special colour.
This part works, but I'm not quite sure of the best way to force the
TextEditor to update its content (to redo the process of colour syntax
highlighting)... to "refontify" in emacs terms.
My current solution is provided below. It works... but it loses context
information. For example, if I were on line 400, and I execute this
refresh method, then I end up back on line 1. I assume there must be a
better way to do this, but I'm not sure what the trigger is.
protected void refresh()
{
try
{
this.doSetInput( this.getEditorInput() );
}
catch( Exception e )
{
e.printStackTrace();
}
}
Unfortunately, debugging through the 'doSetInput' method doesn't give me
immediate visual feedback, so I'm not sure when the editor content is
actually updated.
Any help on this matter would be greatly appreciated.
Thanks,
Jeff
|
|
|
Re: best way to refresh/update syntax highlighting? [message #466752 is a reply to message #466608] |
Tue, 24 April 2007 14:32 |
Dani Megert Messages: 3802 Registered: July 2009 |
Senior Member |
|
|
Jeff Weeks [ neuraldk ] wrote:
>Hello,
>
>I have developed an editor, which extends TextEditor, that has a context
>menu that allows certain (user defined) keywords in the text to be
>highlighted a special colour.
>
>This part works, but I'm not quite sure of the best way to force the
>TextEditor to update its content (to redo the process of colour syntax
>highlighting)... to "refontify" in emacs terms.
>
>
Do you update the coloring while typing? If so, do you use a
presentation reconciler (IPresentationReconciler)? If this is the case
then you might want to look at
ITextViewerExtension2.invalidateTextPresentation(int,int).
HTH
Dani
>My current solution is provided below. It works... but it loses context
>information. For example, if I were on line 400, and I execute this
>refresh method, then I end up back on line 1. I assume there must be a
>better way to do this, but I'm not sure what the trigger is.
>
> protected void refresh()
> {
> try
> {
> this.doSetInput( this.getEditorInput() );
> }
> catch( Exception e )
> {
> e.printStackTrace();
> }
> }
>
>Unfortunately, debugging through the 'doSetInput' method doesn't give me
>immediate visual feedback, so I'm not sure when the editor content is
>actually updated.
>
>Any help on this matter would be greatly appreciated.
>
>Thanks,
>Jeff
>
>
|
|
|
Re: best way to refresh/update syntax highlighting? [message #466782 is a reply to message #466752] |
Wed, 25 April 2007 00:41 |
Eclipse User |
|
|
|
Originally posted by: jweeks.neuraldk.org
> Do you update the coloring while typing? If so, do you use a
> presentation reconciler (IPresentationReconciler)? If this is the case
> then you might want to look at
> ITextViewerExtension2.invalidateTextPresentation(int,int).
Perfect!
Thanks,
Jeff
|
|
|
Powered by
FUDForum. Page generated in 0.03425 seconds