Page 1 of 1

GetMethodAtCursor

Posted: 20 Aug 2011 17:07
by jgodfrey
I'm attempting to write a script that will select the entire method that contains insertion cursor. Looking at the scripting docs, GetMethodAtCursor(True) sounds like exactly what I need.

However, using that, the lines that get selected seem to depend on where the cursor is in the method. For instance, placing the cursor on the first line of a method generally selects the entire method, but placing the cursor somewhere within the method generally "misses" a few lines at seemingly random locations (so most of the method is selected, but a few random lines are not part of the selection).

If you need more details, I'll try to provide them.

Once I'm able to successfully select the current method, I'd like to automatically copy the selection to the clipboard. However, I didn't see any clipboard-related methods in the scripting docs. Is that possible?

Thanks,

Jeff

Re: GetMethodAtCursor

Posted: 20 Aug 2011 22:47
by jgodfrey
Here's what's happening with the selection, assuming the insertion cursor is somewhere within the body of a method:

- All lines are selected between the line *containing* the insertion cursor and the end of the method
- The first line of the method is selected

All lines that are *above* the insertion cursor are not selected (except the first line).

I've attached an image of the selection results in a simple Pascal procedure. In this image, the insertion cursor was on line 12 when the script was run.

Jeff

Re: GetMethodAtCursor

Posted: 27 Aug 2011 15:56
by Rickard Johansson
Fixed in v7.63. Also added 3 new methods to the "Document" object:

CopyToClipboard()
CutToClipboard()
PasteFromClipboard()

Re: GetMethodAtCursor

Posted: 27 Aug 2011 15:58
by jgodfrey
Great - thanks!

Jeff

Re: GetMethodAtCursor

Posted: 20 Dec 2014 06:45
by sajjad321
So, using that, I knocked up a quick and dirty persistence library (dubbed DSPL for "Dead Simple Persistence Library). It's not fancy, and provides only basic functionality, but I think it might come in handy.