move cursor to end of selection

Help with writing and running scripts

move cursor to end of selection

Postby UltraBoG » Fri Jun 29, 2007 8:39 am

Does anyone know how to move the cursor to the end of the current selection?

I want to do a findReplace.find, but leave the cursor at the end of the selection.

When I do an ordinary find/findnext in the editor (F3 key), the cursor is left at the end of the selection. But if I use findReplace.find within a .js script, the cursor is left at the beginning of the selecion.
User avatar
UltraBoG
Newbie
 
Posts: 4
Joined: Thu Nov 09, 2006 12:00 am

Re: move cursor to end of selection

Postby Bego » Fri Jun 29, 2007 8:58 am

I thought sth. like this would do the job:

Code: Select all
UltraEdit.activeDocument.findReplace.find("WHATER_YOU_WANT");
//unmark
UltraEdit.activeDocument.key("RIGHT ARROW");
UltraEdit.activeDocument.key("LEFT ARROW");


but I think there is a bug. When I start the script It finds "WHATER_YOU_WANT" and then loses focus completely. (Focus is in scripting-window).
Can you confirm this ?

rds Bego
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: move cursor to end of selection

Postby Jaretin » Fri Jun 29, 2007 9:15 am

I think the easiest way is
Code: Select all
UltraEdit.activeDocument.cut();
UltraEdit.activeDocument.paste();
User avatar
Jaretin
Basic User
Basic User
 
Posts: 19
Joined: Sun Mar 25, 2007 11:00 pm

Re: move cursor to end of selection

Postby jorrasdk » Fri Jun 29, 2007 9:47 am

Spooky!!!

I used Begos simple scripting find:

Code: Select all
UltraEdit.activeDocument.findReplace.find("WHATER_YOU_WANT");


and as UltraBoG described, the cursor is in the beginning of the selection.

And here is the spooky part - add a ueReOn:
Code: Select all
UltraEdit.ueReOn();
UltraEdit.activeDocument.findReplace.find("WHATER_YOU_WANT");


even though we're not using Regex, suddenly the cursor is at the end of the selection. Go figure.

Default regex engine in scripting is perl, so if I add
Code: Select all
UltraEdit.perlReOn();
UltraEdit.activeDocument.findReplace.find("WHATER_YOU_WANT");


again the cursor is at the beginning. Hmmm.

(btw in both cases I also tested with "UltraEdit.activeDocument.findReplace.regExp=false;" just to be sure regex was not on. Same result).
User avatar
jorrasdk
Master
Master
 
Posts: 275
Joined: Mon Mar 19, 2007 11:00 pm
Location: Denmark


Return to Scripts