Renouncement
When I wrote this question, I was mistaken in the behavior of the SelectionService ... The SelectionService usually notifies you of the cursor moving, but not for every movement: if your IDE flashes quickly, showing detailed information when scrolling the cursor to 10 lines to get what you Itβs interesting and useless, because the information is displayed for too short a period to be useful, very distracting and, possibly, even dangerous for people with potential epilepsy.
For this reason, the SelectionService responds only after the cursor has remained in the same place long enough that it makes sense to update the Eclipse views in response to a new context.
I also heard that a few years ago there was one version of Eclipse that listened for the SelectionService function, so I'm not sure I published it because I decided to develop Eclipse plugins in this version first or because I did not understand why The SelectionService works the way it is, but in the end, using the Eclispe SelectionService is all I have ever needed, or recommended to others.
Original question
I am developing an Eclipse plugin that should respond to the current cursor position in the Eclipse editor.
From the tests performed, it seems that using SelectionService tells you when the editor makes a non-empty selection, and not when moving the cursor.
I found one site that describes how to track selections by logging mouse and keyboard events , but this seems like a bit of a hack.
I also saw someone ask StackOverflow about an alternative to the CaretListener interface for tracking cursor movement in the Eclipse editor and a description of the registration method in the editor (and not the global SelectionService) to receive updates on carriage movement, but they suggest that this is a less efficient method which will be better replaced by the CaretListener interface in later versions of Eclipse.
The latter may be an option, but it seems that using CaretListener would be the preferred approach ... but if so, how can this be done?