I would like to do the above programmatically.
I looked on How to get cursor position in an eclipse TextEditor and Eclipse-plugin how to get current text editor corsor position so i kind of know how get the cursor offset from the current open editor. However, I'm trying to set the cursor offset in a new editor which is opened programmatically by me.
The way I'm currently open my new editor is as follows:
IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
if (page != null) {
IEditorPart editor = page.getActiveEditor();
if (editor != null) {
IEditorInput input = editor.getEditorInput();
if (input instanceof IFileEditorInput) {
String fileLocation = ((IFileEditorInput) input).getFile().getLocation().toOSString();
String newFileLocartion = generateNewFileLocation(fileLocation);
File file = new File(newFileLocartion);
IFileStore fileStore = EFS.getLocalFileSystem().getStore(file.toURI());
try {
IDE.openEditorOnFileStore(page, fileStore);
} catch (PartInitException e) {
// TODO error handling
}
}
}
}
Is there a way to open set the new editor to open in a specific offset (assuming i already knows the offset in advance)?
Thanks!