java - Eclipse:Get and set caret position of the editor -
i'm developing voice recognition plugin eclipse. example when writing code can "for" , "for(){}" printed editor. works great, however, when scope of cursor goes out of eclipse e.g. when click on browser search next thing printed here instead of eclipse editor.
is there way find out caret position on eclipse editor when goes out of scope, because when click on part of eclipse ui old caret position pops up.
i using javarobot api emulate string screen. don't believe has option of setting caret position, courser position.
update: needed text editor caret position x , y co-ordinates, can use java robot move mouse(caret position x,y) , mouse press bring eclipse platform scope before emulation occurs.
assuming have ieditorpart
interested in can caret position using:
ieditorpart editor = .... part .. control control = editor.getadapter(control.class); // text editor control styledtext if (control instanceof styledtext) { styledtext text = (styledtext)control; // position of caret relative top left of control point relpos = text.getlocationatoffset(text.getcaretoffset()); // position relative display point abspos = textwidget.todisplay(relpos); }
Comments
Post a Comment