Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Maintaining viewport in TextEditor
Maintaining viewport in TextEditor [message #262956] Wed, 21 July 2004 15:26 Go to next message
Eclipse UserFriend
Originally posted by: oleg.configurecode.com

Here is what I would like to do inside of a text editor:

ISourceViewer viewer = this.getSourceViewer();
StyledText textWidget = viewer.getTextWidget();
int offset=textWidget.getCaretOffset();
textWidget.setText(text);

textWidget.setCaretOffset(offset);

this does, in fact, put the cursor where it was before.

However, the viewport is scrolled back to the top.

How can I keep it where it was before setting the text ?

Oleg
Re: Maintaining viewport in TextEditor [message #263751 is a reply to message #262956] Mon, 26 July 2004 04:47 Go to previous message
Eclipse UserFriend
Oleg wrote:
> Here is what I would like to do inside of a text editor:
>
> ISourceViewer viewer = this.getSourceViewer();
> StyledText textWidget = viewer.getTextWidget();
> int offset=textWidget.getCaretOffset();
> textWidget.setText(text);
>
> textWidget.setCaretOffset(offset);
>
> this does, in fact, put the cursor where it was before.
>
> However, the viewport is scrolled back to the top.
>
> How can I keep it where it was before setting the text ?

See

- ITextViewer::getTopIndex, getTopInset
- StyledText::getTopPixel

-tom
Previous Topic:Find/Replace, Regular expressions and capturing groups
Next Topic:[RCP] The concepts 'View' and 'Editor'
Goto Forum:
  


Current Time: Sun Jul 27 16:11:40 EDT 2025

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

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

Back to the top