Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » best way to refresh/update syntax highlighting?
best way to refresh/update syntax highlighting? [message #466608] Sun, 22 April 2007 20:31 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:Update... doesn't do anything
Next Topic:Re: Event Handler for 'Next' button in a wizard.
Goto Forum:
  


Current Time: Thu Apr 25 11:35:08 GMT 2024

Powered by FUDForum. Page generated in 0.03425 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top