Jump to labels.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Jump to labels.

Post by jassing »

Like clicking on xincludefile or a procedure name, it'd be nice to be able to click on "?myLabel" and have it jump to the actual label.
vmars316
Enthusiast
Enthusiast
Posts: 464
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: Jump to labels.

Post by vmars316 »

Hi jassing ,
What I do for 'jump to my label' :
For example , it seems I frequently need to show the Declares section ,
So I create a bogus Declares Procedure , like this :
;
Procedure Declares()
EndProcedure ; Declares() Only for finding Declares Section
;
Declare OpenWindow_0(x = 0, y = 0, width = 1420, height = 730)

Then when I want to Jump to Declares Section ,
I click Declares() label in Procedures Tab .
hth
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: Jump to labels.

Post by jassing »

that assumes all labels are in the same place, not spread across various source files.
AZJIO
Addict
Addict
Posts: 1298
Joined: Sun May 14, 2017 1:48 am

Re: Jump to labels.

Post by AZJIO »

vmars316 wrote: Wed Jun 28, 2023 9:56 pm So I create a bogus Declares Procedure
make a line like this

Code: Select all

;- Declares
also you can do the following lines:

Code: Select all

;- Enumeration
;- Global
;- ini
;- GUI
;- Menu
;- Loop
;- Loop Menu
Try FindAllReferences, only you need to select a word without the "?" symbol.
BarryG
Addict
Addict
Posts: 3266
Joined: Thu Apr 18, 2019 8:17 am

Re: Jump to labels.

Post by BarryG »

I've been asking for jumping to labels and macros forever. It can be done, because the procedure browser lets you do it with a click. So why not allow it in the source like for Procedures?
jassing
Addict
Addict
Posts: 1745
Joined: Wed Feb 17, 2010 12:00 am

Re: Jump to labels.

Post by jassing »

Glad you all have figured out workarounds that work for you... But if you have a project with dozens of source files, you can double-click on a procedure & the IDE will open the appropriate file & jump to the declaration. your workarounds require you to know the file & open it.

Would be nice to have this for other aspects of the code as well.
But it seems I'm in the minority, so I withdraw the request.
AZJIO
Addict
Addict
Posts: 1298
Joined: Sun May 14, 2017 1:48 am

Re: Jump to labels.

Post by AZJIO »

If I don't use "Project", then when I click on the function located in XIncludeFile, I don't get any result either. That is, XIncludeFile files are not opened to jump to the function.
But I know that I can write this function. To do this, use a regular expression to find the name of the function before which there is a prefix "Procedure". If not found, then look for "XIncludeFile" and open the contents of the files and check. If found, get the line number from the number of line breaks, open the file and jump to the specified position.
I'll make you regular expressions if you do the rest.

Code: Select all

(?mi)^\h*(?:Procedure[CDL$]{0,5}?(?:\h*\.[abcdfilqsuw])?\h+)MyWindowCallback\h*(?=\()
(?mi)^\h*X?Include[a-z]{4,6}\h+\K"[^*?<>|]+?"
Post Reply