我想在编辑器中光标所在的位置显示弹出对话框。如何获取活动编辑器的文本光标位置(Point)并在此点处显示弹出对话框?
我想在编辑器中光标所在的位置显示弹出对话框。如何获取活动编辑器的文本光标位置(Point)并在此点处显示弹出对话框?
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editor instanceof ITextEditor) {
ISelectionProvider selectionProvider = ((ITextEditor)editor).getSelectionProvider();
ISelection selection = selectionProvider.getSelection();
if (selection instanceof ITextSelection) {
ITextSelection textSelection = (ITextSelection)selection;
int offset = textSelection.getOffset(); // etc.
}
}
getCursorPosition()
方法。