Is there an alternative to CaretListener in Eclipse?

In the Eclipse plugin, I need to find out when the carriage moves in the code editor (implicitly or explicitly). I am currently achieving this with CaretListener.

I'm just wondering if there is an alternative way to do this? The reason is that CaretListener is only available from version 3.5, and I think this is the only thing that keeps me from supporting older versions.

Thanks Alan

0
source share
1 answer

I found another way to be notified when the carriages moved. By calling textViewer.addPostSelectionChangedListener on the TextViewer instance, you get a notification when the caret moves.

I also used this answer to get a TextViewer from IEditorPart.

The only problem is that this method is noticeably slower than the one I did before with the caretMoved event. So, I hope there is a way to change the behavior depending on the version of Eclipse, because I'm not sure that I would be happy to make such a compromise in speed in newer versions.

I hope this helps others who come across this issue.

Alan

+1
source

Source: https://habr.com/ru/post/1382067/


All Articles