Highlight Procedure and copy to clipboard

Working on new editor enhancements?
JoeC4281
User
User
Posts: 32
Joined: Fri Aug 06, 2021 4:47 pm

Highlight Procedure and copy to clipboard

Post by JoeC4281 »

Code: Select all

PureBasic 6.10 LTS (Windows - x64)
From the Procedure Browser in the IDE,
I would like the ability to right-click on a procedure,
have the procedure highlighted,
and then copy the highlighted procedure to the clipboard.

At the present time,
I have an AutoHotKey Script that does most of this.

Code: Select all

; AutoHotKey script to automate the task in PureBasic IDE

#q::ExitApp  ; Assign a hotkey to terminate this script

; Hotkey to activate the script (Ctrl+J)
^j::
    ; Start the selection from the current line to the next EndProcedure statement
    Send, +{Down}

    ; Continue holding Shift and pressing Down until reaching the EndProcedure statement
    Loop
    {
        ; Send the Down key to move to the next line
        Send, +{Down}
        Sleep, 5  ; Adjust the delay as needed

        ; Check if the current line contains "EndProcedure"
        Clipboard := ""  ; Clear the clipboard
        Send, ^c         ; Copy the current line to the clipboard
        Sleep, 25        ; Wait for the clipboard to update
        ClipWait, 1      ; Wait up to 1 second for the clipboard to contain data
        if InStr(Clipboard, "EndProcedure")
            break  ; Exit the loop if "EndProcedure" is found
    }

    ; Copy the selected text to the clipboard
    Send, ^c
    
    Send, {Down}
Return
This does what I want,
except I have to press Ctrl+J once I have selected the procedure from the Procedure Browser.

Not a big deal to press the Ctrl+J hotkey.

Would it be possible to make this a feature in the PureBasic IDE,
without having to use AutoHotKey?

Joe
BarryG
Addict
Addict
Posts: 4128
Joined: Thu Apr 18, 2019 8:17 am

Re: Highlight Procedure and copy to clipboard

Post by BarryG »

You can press Ctrl+M to select all code inside the current procedure, then Ctrl+C to copy that selection. Or, after selection with Ctrl+M, you can just Shift+UpArrow a few times to select the "Procedure" line for copying as well.

Alternatively: if a procedure is folded, you can copy the "Procedure" line + carriage return to copy the entire procedure without scrolling.

Source for these tips -> viewtopic.php?p=500269
JoeC4281
User
User
Posts: 32
Joined: Fri Aug 06, 2021 4:47 pm

Re: Highlight Procedure and copy to clipboard

Post by JoeC4281 »

Thanks for the Ctrl+M tip.

I looked in the help file for Ctrl+M,
and found it under "Editing Features".

Within "Editing Features",
it has "Selecting blocks of code:",
which states...
Repeated usage of the shortcut selects further surrounding code blocks.
Thus, selecting the procedure from the Procedure Browser,
and pressing Ctrl+M Ctrl+M selects everything from ProcedureDLL to and including EndProcedure.

I then press Ctrl+C to copy it to the clipboard.

Thus, I no longer need to use the AutoHotKey script.

Joe
BarryG
Addict
Addict
Posts: 4128
Joined: Thu Apr 18, 2019 8:17 am

Re: Highlight Procedure and copy to clipboard

Post by BarryG »

JoeC4281 wrote: Tue Jan 14, 2025 7:57 pmpressing Ctrl+M Ctrl+M selects everything from ProcedureDLL to and including EndProcedure.
Nice, I didn't notice that. Thanks!
Post Reply