[SOLVED] Getting Current Cursor Location [message #765311] |
Tue, 13 December 2011 20:22 |
Kivanc Muslu Messages: 153 Registered: November 2010 |
Senior Member |
|
|
Hi,
Is there an Eclipse API that I can use which will return me the current location of the cursor on the selected (i.e., focused, active) Eclipse editor?
The results can be something like:
- offset: 315
or
- SomeClassFile.java:315
Thanks in advance, best regards,
[Updated on: Wed, 14 December 2011 12:31] Report message to a moderator
|
|
|
|
Re: Getting Current Cursor Location [message #765579 is a reply to message #765509] |
Wed, 14 December 2011 10:29 |
Kivanc Muslu Messages: 153 Registered: November 2010 |
Senior Member |
|
|
Hi Dani,
Though this partly provides what I need, I cannot get the changes done on the cursor (i.e., exact movement path of the cursor on the screen) with this. After adding a listener to a file, I only get if something is selected on that particular file.
I realized that my initial question might be misleading. My problem is following. Let's say that I have a file open in Eclipse and the cursor is on offset 10. I want to be able to get all changes on the cursor (i.e., its new location) as user changes it on the screen.
e.g.,
User moves the cursor by mouse to offset 45 (without selecting any text), I want to get offset = 45
User hits down key, I want to get: offset = 20 (assuming that one line is 10 characters long), etc.
Is there an API (listener) for this?
Thanks,
|
|
|
Re: Getting Current Cursor Location [message #765590 is a reply to message #765579] |
Wed, 14 December 2011 10:54 |
Dani Megert Messages: 3802 Registered: July 2009 |
Senior Member |
|
|
On 14.12.2011 11:29, Kivanc Muslu wrote:
> Hi Dani,
> Though this partly provides what I need, I cannot get the changes done
> on the cursor (i.e., exact movement path of the cursor on the screen)
> with this. After adding a listener to a file, I only get if something
> is selected on that particular file.
>
> I realized that my initial question might be misleading. My problem is
> following. Let's say that I have a file open in Eclipse and the cursor
> is on offset 10. I want to be able to get all changes on the cursor
> (i.e., its new location) as user changes it on the screen.
Add a post selection listener. Either add it on the (post) selection
provider you get from the editor or ask the editor site for the
selection service and add it there. See org.eclipse.ui.ISelectionService
for details.
Dani
>
> e.g., User moves the cursor by mouse to offset 45 (without selecting
> any text), I want to get offset = 45
> User hits down key, I want to get: offset = 20 (assuming that one line
> is 10 characters long), etc.
>
> Is there an API (listener) for this?
>
> Thanks,
|
|
|
|
Powered by
FUDForum. Page generated in 0.03185 seconds