How to Get Cursor Position in Class

Hi everyone,

     I need to get my cursor position in open editor. But I cant manage to get correct number.

forum3.jpg

When I click the "create log", I need to get this line information. (In this example it is 21)

0
Avatar
Permanently deleted user

Thx for reply, but I've already tried it and it doesnt work and it is also deprecated.

0

What exactly doesn't work?

0

I assume you have an Action that executes when you select that menu item. In your action you can:

 
public void actionPerformed(AnActionEvent event) {
    Editor editor = PlatformDataKeys.EDITOR.getData(event.getDataContext();

    int
offset = editor.getCaretModel().getOffset();

    //... whatever you were going to do
}
0
Avatar
Permanently deleted user

Thanks for the reply. This method gives me caret with x and y. How can I seperate these these two?

Edit: I did this with using method: editor.getLineHeight.

Now I have new problem: How can I get class or file location information of these files? I mean, I need a classpath of these files for autocomplete.

Edit: I solved it with some string methods. Now I have a new problem in new topic:

http://devnet.jetbrains.com/message/5521111#5521111

0
Avatar
Permanently deleted user

Hi guys,

Now I figure editor.getLineHeight isnt worked. So I need line number of my cursor.

0

请先登录再写评论。