Author Topic: _restore_pos2 doesn't after paste  (Read 3301 times)

Mr68360

  • Community Member
  • Posts: 46
  • Hero Points: 3
_restore_pos2 doesn't after paste
« 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


Mr68360

  • Community Member
  • Posts: 46
  • Hero Points: 3
Re: _restore_pos2 doesn't after paste
« Reply #1 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;
}