I have an editor that extends a TextEditor class. I would like to know if it is possible to read the text at the cursor position within the editor. Using ITextSelection is not useful since it expects that some text string is selected. I require to read text when the cursor is at some point and no text 开发者_如何学Pythonis selected.
Thanks.
ITextViewer.getSelectedRange(). It will return the offset and the size of the selection. Offset is the caret position and size may be 0. To read the text, use ITextViewer.getDocument().get() and analyze the contents at the respective offset.
精彩评论