Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » selecting text programmatically
selecting text programmatically [message #151531] Thu, 18 August 2005 20:11 Go to next message
Eclipse UserFriend
Originally posted by: no.yes.maybe

Hi,
given the IFile for a C file currently opened in an editor, I need to
programmatically reveal its editor and select a certain line number. How
can I do this?

THank you,
Roberto
Re: selecting text programmatically [message #151716 is a reply to message #151531] Sun, 21 August 2005 15:31 Go to previous message
Eclipse UserFriend
roberto wrote:
> given the IFile for a C file currently opened in an editor, I need to
> programmatically reveal its editor and select a certain line number. How
> can I do this?

This works from a view, where you have the ViewPart

int lineNumber=0;
IFile file=... ;
ViewPart vp=... ;

if (file != null && file.exists()) {
IWorkbenchPage wbp = vp.getSite().getPage();
try {
IEditorPart editor = IDE.openEditor(wbp, file);
String markerID="org.eclipse.core.resources.textmarker";
IMarker marker =file.createMarker(markerID);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
IDE.gotoMarker(editor, marker);
} catch (Exception e) {
e.printStackTrace();
}
}
Previous Topic:A Bug?
Next Topic:setting text markers on a resource
Goto Forum:
  


Current Time: Sun May 11 15:53:15 EDT 2025

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

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

Back to the top