From TextEditor you can get a document, document provider and choice. This will give you access to the current cursor offset.
ITextEditor editor = (ITextEditor) editorPart .getAdapter(ITextEditor.class); IDocumentProvider provider = editor.getDocumentProvider(); IDocument document = provider.getDocument(editorPart .getEditorInput()); ITextSelection textSelection = (ITextSelection) editorPart .getSite().getSelectionProvider().getSelection(); int offset = textSelection.getOffset(); int lineNumber = document.getLineOfOffset(offset);
IDocument provides other methods for running rows (you can calculate a column from this).
For more information see http://wiki.eclipse.org/The_Official_Eclipse_FAQs#Text_Editors
Paul webster
source share