GetMethodAtCursor

Ask questions about how to create a script or swap scripts with other users.
Post Reply
jgodfrey
Posts: 471
Joined: 19 Aug 2011 23:02
Location: Missouri, USA

GetMethodAtCursor

Post 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
jgodfrey
Posts: 471
Joined: 19 Aug 2011 23:02
Location: Missouri, USA

Re: GetMethodAtCursor

Post 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
Attachments
selection_bug.png
selection_bug.png (10.61 KiB) Viewed 15588 times
User avatar
Rickard Johansson
Site Admin
Posts: 6577
Joined: 19 Jul 2006 14:29

Re: GetMethodAtCursor

Post by Rickard Johansson »

Fixed in v7.63. Also added 3 new methods to the "Document" object:

CopyToClipboard()
CutToClipboard()
PasteFromClipboard()
jgodfrey
Posts: 471
Joined: 19 Aug 2011 23:02
Location: Missouri, USA

Re: GetMethodAtCursor

Post by jgodfrey »

Great - thanks!

Jeff
Post Reply