Hi,
I registered an entry for the context menu of the text editor and in the handler for that menu entry I'd like to get the current line as a string.
So the procedure for the user should be: right click the line and select the menu entry.
For me the current line is the line in which the cursor is located at the moment. an example:
line1: abcdefg
line2: hijklmn
line3: opqrstuvw
if the cursor is currently located after the "k" I'd like to have "line2: hijklmn" be returned.
At the moment I do
ITextSelection selection= (ITextSelection)HandlerUtil.getCurrentSelectionChecked(event);
to get the current selection. The problem is, that the offset of the selection is kind of unpredictable. sometimes I get line1 or line3 instead of line2. Once I get the correct line I will always get the correct one when repeat the steps. So it seems to me that the selection is not "up to date".
Is there a better way to get the cursor position (current row and current column)?
And is there a handy way to get the full line of a text editor?
- Alex
[Updated on: Fri, 30 July 2010 04:21]
Report message to a moderator