SlickEdit Community

SlickEdit Product Discussion => SlickEditĀ® => Slick-CĀ® Macro Programming => Topic started by: Mr68360 on March 22, 2007, 10:53:34 pm

Title: _restore_pos2 doesn't after paste
Post by: Mr68360 on March 22, 2007, 10:53:34 pm
I want to create a macro that, after pasting the clipboard (ala Ctrl-V), returns the cursor to the location of the of the cursor at the start of a paste, rather than at the end of what was pasted:

                           Normal paste leaves cursor here
                           v
|this_is_pasted_text
^
I want cursor here after the paste.


(BTW, if there already is a setting for this, I'll take that as well)

I tried the following:

_command paste_stay(_str name='', boolean isClipboard=true) name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   typeless p;
   _save_pos2(p);
   int retval = paste(name, isClipboard);
   _restore_pos2(p);
   return retval;
}

However, the _restore_pos2() call placed the cursor at the end of the pasted text.  It's as if the position value _save_pos2() returns is modified via the paste function to the "post-paste" location.

Is there anyway to obtain the "pre-paste" location, and return the cursor to that spot?

Thanks,
Chuck

Title: Re: _restore_pos2 doesn't after paste
Post by: Mr68360 on March 24, 2007, 04:03:06 pm
Figured it out!

_command paste_stay(_str name='', boolean isClipboard=true) name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   long ofs = _QROffset();
   int retval = paste(name, isClipboard);
   _GoToROffset(ofs);
   return retval;
}