Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Changing file content without scroll reset
Changing file content without scroll reset [message #464127] Mon, 26 February 2007 09:03 Go to next message
Eclipse UserFriend
Hi all,
I am writing a preprocessor plugin that comments bits of the code based
on preprocessing directives.

following advice from here, I hooked into stateChanging(IFileBuffer),
and replaces single lines that changes.
this worked until I introduced an #include directive, that can change
the line numbers.
this makes it really hard to replace just that section that changed in
the document, so I am looking for an alternative solution for the
problem of replacing the content of the file without the scroll being
effected.

any thoughts?
maybe I can restore the scroll myself after I change the content of the
IBuffer? if so, how can I do that?

thanks,
Re: Changing file content without scroll reset [message #464134 is a reply to message #464127] Mon, 26 February 2007 09:56 Go to previous message
Eclipse UserFriend
Found a solution!

AbstractDocument document = (AbstractDocument) fileBuffer.getDocument();
DocumentRewriteSession session =
document.startRewriteSession(DocumentRewriteSessionType.UNRE STRICTED);

document.set(text);
document.stopRewriteSession(session);


This magically preserves the scroll position.



Omry Yadan wrote:
> Hi all,
> I am writing a preprocessor plugin that comments bits of the code based
> on preprocessing directives.
>
> following advice from here, I hooked into stateChanging(IFileBuffer),
> and replaces single lines that changes.
> this worked until I introduced an #include directive, that can change
> the line numbers.
> this makes it really hard to replace just that section that changed in
> the document, so I am looking for an alternative solution for the
> problem of replacing the content of the file without the scroll being
> effected.
>
> any thoughts?
> maybe I can restore the scroll myself after I change the content of the
> IBuffer? if so, how can I do that?
>
> thanks,
Previous Topic:Shortening the length when Exporting my RCP application
Next Topic:No image icons or names in the resource navigator in a RCP product
Goto Forum:
  


Current Time: Mon Mar 17 05:20:58 EDT 2025

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

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

Back to the top