A complete code browser for PureBasic [Windows]

Working on new editor enhancements?
User avatar
Zapman
Enthusiast
Enthusiast
Posts: 205
Joined: Tue Jan 07, 2020 7:27 pm

A complete code browser for PureBasic [Windows]

Post by Zapman »

PBBrowser is aimed at all PureBasic developers who want to improve their own codes and navigate into their procedures much more easily than with the native PureBasic editor. PBBrowser is NOT a 'fork' (a rewrite) of the editor. It is a tool that is ADDED to the editor and which provides a large number of functions to help you in your programming tasks.

The following link gives you access to a page allowing you to download PBBrowser in compiled version, or its sources (it's free and OpenSource). You will also find various codes for PureBasic developers under Windows.

https://www.editions-humanis.com/downlo ... ads_EN.htm

I'm looking for active testers. Any feedback you can give me on possible bugs or wishes to improve this tool will be taken into account.
To understand what PBBrowser can be useful to you, I invite you to watch this short demonstration video:
Image

This tool is designed to be installed in and work collaboratively with the PureBasic Editor. Once PBBrowser is downloaded to your computer, its installation in the editor only takes a few seconds (it is automated).

It is the ideal tool for navigating your code, exploring, modifying or cleaning up your programs. Among its many functions, PBBrowser allows you to identify which parts of your code are really useful or can be removed.

Starting from the address of a main file, it lists all "Include" files as well as all procedures, structures, macros, enumerations, labels, constants, etc., defined in the main file and linked files. This analysis is almost instantaneous. It can then move from one procedure to another with a single click while discovering, for example, which procedures call another. It also tells you where a variable is assigned a value and where it is used as an argument to a function or as a test value (with If, While, Until, etc.).

• By clicking on a constant name from the PureBasic editor, you find out in which enumeration it was defined (if it is, of course) and what its value is.
• By clicking on a variable name, you immediately discover where in the code its value is changed, where it is tested, and in which procedures it serves as a parameter or return value.
• By clicking on a procedure name, you obtain the list of variables it uses, as well as the list of unprotected variables. With, of course, the line number where the procedure is defined.
• By clicking on an element name (procedure, structure, constant, variable, etc.) inside PBBrowser, the PureBasic editor is immediately positioned where it appears.
• etc.

Latest version: Beta 0.28 - dec - 21 - 2024

The current version has already benefited from debugging on the French forum (a huge thank you to Cage for his friendly and diligent follow-up) but I am looking for other testers!

Image
Image

Version history:
Beta 0.18 - dec - 04 - 2024 : https://www.purebasic.fr/english/viewto ... 95#p631595 fixed
Beta 0.19 - dec - 04 - 2024 : Some additional improvements to parsing 'Included' statements.
Beta 0.20 - dec - 04 - 2024 : More improvements to parsing 'Included' statements and to the file list.
Beta 0.21b - dec - 05 - 2024 : Russian version added.
Beta 0.22 - dec - 06 - 2024 : Fixes a bug concerning multi-language. Set fixed font and font-size for all gadgets. Fixes a bug for lists color. Fixes a bug with the 'Cosmetic enhancer'. All these bugs were identified by AZJIO https://www.purebasic.fr/english/viewto ... 71#p631671
Beta 0.23 - dec - 07 - 2024 : 'portable' support: PBBrowser can now run as a 'portable' version if you set the first constant of PBBrowserDeclarations.pb to '#True'. It can also be installed as a tool in portable versions of PureBasic.
Beta 0.24 - dec - 09 - 2024 : • PBBrowser is now able to open projects (many thanks to 'le_magn' for his help). Portable mode can now be activated by the command line "\PORTABLE" (exactly as you can do for PureBasic). The tool installation process has been completed and optimized. A small bug of the 'Create or update a PureBasic project' function has been fixed.
Beta 0.25 - dec - 15 - 2024 : 'Preferences' pannel with dark mode options added.
Beta 0.26 - dec - 18 - 2024 : Fixes the bug reported by Little_man and offers more robust parsing of "IncludedFile" mentions.
Beta 0.27 - dec - 19 - 2024 : Fixes a printing problem with some special charaters as "➭".
Beta 0.28 - dec - 21 - 2024 : All secondary windows are now horizontally centered relative to the main window.
Version 1.0 - march - 23 - 2024 : Minor bugs have been fixed. Dark mode is now fully implemented, including for menus. A new tool allows you to remove comments from reviewed code.
Last edited by Zapman on Sat Mar 22, 2025 1:51 pm, edited 16 times in total.
highend
Enthusiast
Enthusiast
Posts: 162
Joined: Tue Jun 17, 2014 4:49 pm

Re: A complete code browser for PureBasic [Windows]

Post by highend »

Thanks for sharing this!

In a project the main .pb file contains this:

Code: Select all

XIncludeFile ".\#includes\constants.pbi"       : UseModule Consts
XIncludeFile "#includes\structures.pbi"      : UseModule Structs
The first line is (in reality) without the ".\", I just want to show the problem.

Both includes work fine when compiling the code.

Your tool doesn't resolve these relative paths correctly and will nag on every single include command...

Wish: If it can't find an include file, add the option to the nag window to don't nag on all other non-findable include files as well.

Code: Select all

One or more files declared as 'Include' or 'XInclude' are empty or do not exist at the indicated address.
The file list will be incomplete.
Empty or missing file(s):
D:\Users\myusername\Development\PureBasic\XY_Config handler\\constants.pbi
D:\Users\myusername\\Development\PureBasic\XY_Config handler\\structures.pbi
Look at the last path separator "\\", probably the source of the problem...
User avatar
Zapman
Enthusiast
Enthusiast
Posts: 205
Joined: Tue Jan 07, 2020 7:27 pm

Re: A complete code browser for PureBasic [Windows]

Post by Zapman »

I absolutely approve. These points are fixed by version Beta 0.18 currently online at the same address.
Many thanks for this first feedback, highend! I hope you find the tool useful for the rest.
highend
Enthusiast
Enthusiast
Posts: 162
Joined: Tue Jun 17, 2014 4:49 pm

Re: A complete code browser for PureBasic [Windows]

Post by highend »

currently online at the same address
I'm afraid that's still the 0.17 :)

Tested it with several browsers and caches deleted...
User avatar
Zapman
Enthusiast
Enthusiast
Posts: 205
Joined: Tue Jan 07, 2020 7:27 pm

Re: A complete code browser for PureBasic [Windows]

Post by Zapman »

highend wrote: Wed Dec 04, 2024 1:32 pmI'm afraid that's still the 0.17 :)
You're so reactive! :) Thank you! It should be the right one now.
highend
Enthusiast
Enthusiast
Posts: 162
Joined: Tue Jun 17, 2014 4:49 pm

Re: A complete code browser for PureBasic [Windows]

Post by highend »

Yeah, now it's 0.18.

But... The errors are still the same

Code: Select all

D:\Users\myusername\Development\PureBasic\XY_Config handler\\constants.pbi
D:\Users\myusername\Development\PureBasic\XY_Config handler\\structures.pbi
And if I check the setting to not report it again after all the single dialog windows:
I click the "Change" button, select the same file again and get all these not found messages again^^
User avatar
Zapman
Enthusiast
Enthusiast
Posts: 205
Joined: Tue Jan 07, 2020 7:27 pm

Re: A complete code browser for PureBasic [Windows]

Post by Zapman »

highend wrote: Wed Dec 04, 2024 1:50 pm Yeah, now it's 0.18.

But... The errors are still the same

Code: Select all

D:\Users\myusername\Development\PureBasic\XY_Config handler\\constants.pbi
D:\Users\myusername\Development\PureBasic\XY_Config handler\\structures.pbi
And if I check the setting to not report it again after all the single dialog windows:
I click the "Change" button, select the same file again and get all these not found messages again^^
:shock: I don't have the same on my PC.
  • "D:\Users\myusername\Development\PureBasic\XY_Config handler\\constants.pbi" is normally interpreted as
    "D:\Users\myusername\Development\PureBasic\XY_Config handler\constants.pbi" (like the compiler does).

    if "D:\Users\myusername\Development\PureBasic\XY_Config handler\constants.pbi" does'nt exist, the message is normal.
  • If you click the "Do not report again" button, you won't have anymore report until you change the main file. If you change it to another and come back to the first one, you'll have the message again. Is that right?
highend
Enthusiast
Enthusiast
Posts: 162
Joined: Tue Jun 17, 2014 4:49 pm

Re: A complete code browser for PureBasic [Windows]

Post by highend »

if "D:\Users\myusername\Development\PureBasic\XY_Config handler\constants.pbi" does'nt exist, the message is normal.
It DOES exist.

On my system it still has "\\" before the file name, that's the reason why your app doesn't find it / them.

Windows Server 2022 x64 if it matters.

I guess it's a misunderstanding regarding the "don't nag again".

I'd like to see that every dialog window that pops up because it didn't find an include file has a button (or a checkmark) to NOT show more of those dialog windows if it encounters more include files that weren't found. So you'll get only a single one when it encounters the first missing include file...

But hey, I'll download the source and take a look why it isn't able to find the include files here :)

Will take a bit, still on work atm
User avatar
le_magn
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Aug 24, 2005 12:11 pm
Location: Italia

Re: A complete code browser for PureBasic [Windows]

Post by le_magn »

Nice tool, how to set it on purebasic tool configuration? Simply add it or i add any specific arguments in the options?Thank's
Image
Axolotl
Addict
Addict
Posts: 802
Joined: Wed Dec 31, 2008 3:36 pm

Re: A complete code browser for PureBasic [Windows]

Post by Axolotl »

Hi Zapman,

nice tool, nice code. Thanks for sharing.

I'm surprised that the first part works.
But I'm not sure if that's really the intention?
And I am sure that I only use the second variant.

Code: Select all

PBPrefAddr$ = GetHomeDirectory() + "AppData\\Roaming\\PureBasic\\PureBasic.prefs"
Debug "1. '" + PBPrefAddr$ + "'" 
Debug " filesize = " + FileSize(PBPrefAddr$) 

PBPrefAddr$ =  = GetHomeDirectory() + "AppData\Roaming\PureBasic\PureBasic.prefs"
Debug "2. '" + PBPrefAddr$ + "'" 
Debug " filesize = " + FileSize(PBPrefAddr$) 
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Axolotl
Addict
Addict
Posts: 802
Joined: Wed Dec 31, 2008 3:36 pm

Re: A complete code browser for PureBasic [Windows]

Post by Axolotl »

le_magn wrote: Wed Dec 04, 2024 2:21 pm Nice tool, how to set it on purebasic tool configuration? Simply add it or i add any specific arguments in the options?Thank's
I am pretty sure this code snippet explains the command line arguments.

Code: Select all

; *****************************************************************************
;
;      Retrieving the arguments passed by PureBasic when launching
;                 the application using the "Tools" menu
;
nl = 0
Repeat
  SAppArgument$ = ProgramParameter()
  nl + 1
  If SAppArgument$
    If nl = 1     ; In principle, the first argument passed by the tool call is "%HOME"
                  ; which contains the full path to the PureBasic application.
      PureBasicProgAddr$ = SAppArgument$ + "PureBasic.exe"
    ElseIf nl = 2 ; In principle, the second argument passed by the tool call is "%WORD"
                  ; which contains the word under the cursor in the PureBasic editor.
      PBUnderCursor$ = SAppArgument$
    ElseIf nl = 3 ; In principle, the third argument passed by the tool call is "%SELECTION"
                  ; which contains the position of the selection in the file.
      PBSelection$ = SAppArgument$
    ElseIf nl = 4 ; In principle, the fourth argument passed by the tool call is "%CURSOR"
                  ; which contains the position of the cursor in the currently opened
                  ; file in the PureBasic editor.
      PBCursor$ = SAppArgument$
    ElseIf nl = 5 ; In principle, the fifth argument passed by the tool call is "%FILE"
                  ; which contains the file currently opened in the PureBasic editor.
      FicPrincipalPB$ = SAppArgument$
      FicActualPB$ = SAppArgument$
    Else          ; In principle, the sixth argument passed by the tool call is "%TEMPFILE"
                  ; which contains the file currently opened in the PureBasic editor.
      TempFile$ = SAppArgument$
      If FicActualPB$ = ""
        FicActualPB$ = TempFile$
        FicPrincipalPB$ = TempFile$
      EndIf
    EndIf
  EndIf
Until nl > 5
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
Zapman
Enthusiast
Enthusiast
Posts: 205
Joined: Tue Jan 07, 2020 7:27 pm

Re: A complete code browser for PureBasic [Windows]

Post by Zapman »

highend wrote: Wed Dec 04, 2024 2:12 pm
if "D:\Users\myusername\Development\PureBasic\XY_Config handler\constants.pbi" does'nt exist, the message is normal.
It DOES exist.
I apologize for not being able to understand how it can happen. It would really be more easy for me if you can simply give me a copy of your 'IncludeFile' declarations. It appears that I'm not able to imagine what type of declarations can do that. With a copy of yours, I'll be in position to test by myself and understand the case.
highend wrote: Wed Dec 04, 2024 2:12 pmI'd like to see that every dialog window that pops up because it didn't find an include file has a button (or a checkmark) to NOT show more of those dialog windows
That is the case with the Beta 0.18. That's why I don't understand. I you expect to erase this dialog window definitely for all new opened project, I'm not sure that would not be criticized by other users who would probably like to not have the message for a project, but to be prevented for another. It's important to understand that, if PBBrowser is unable to read some file of the project, all its procedures and variables analysis will be uncomplete and the results printed will probably be wrong. So, this message is important.
In the same time, I understand that if you want to delete it for one specific project, you must be able to do it. That's how it works with Beta 0.18 if everything works on your PC like on mine.
highend wrote: Wed Dec 04, 2024 2:12 pmBut hey, I'll download the source and take a look why it isn't able to find the include files here :)
Will take a bit, still on work atm
That's very nice! I thank you very much for your feedback!
User avatar
Zapman
Enthusiast
Enthusiast
Posts: 205
Joined: Tue Jan 07, 2020 7:27 pm

Re: A complete code browser for PureBasic [Windows]

Post by Zapman »

le_magn wrote: Wed Dec 04, 2024 2:21 pm Nice tool, how to set it on purebasic tool configuration? Simply add it or i add any specific arguments in the options?Thank's
The installation into Purebasic tools is automated:
* Compile the application if your running it from the sources
* Launch the application
* Click on "Help and tools"
* Choose "Install PBBrowser in PureBasic tools".
highend
Enthusiast
Enthusiast
Posts: 162
Joined: Tue Jun 17, 2014 4:49 pm

Re: A complete code browser for PureBasic [Windows]

Post by highend »

@Zapman

The error comes from inside the function CompleteListOfFiles()
It treats the first part of the relative path "#includes\<a file>" as a constant^^

To reproduce this on your system just add this to your test file
XIncludeFile "#includes\constants.pbi"

and then create that file "constants.pbi" in a subfolder "#includes" in your test project
That is the case with the Beta 0.18
No, that's not the case in 0.18.
It will produce an AlertInPBBWindow(...) for EVERY single include file that it can't find.
So 10 include files that aren't resolved correctly = 10 nagging windows.

You're asking AFTER creating all those windows if it should do it again instead of giving the user the option in every single nagging windows to skip all following ones.
User avatar
Zapman
Enthusiast
Enthusiast
Posts: 205
Joined: Tue Jan 07, 2020 7:27 pm

Re: A complete code browser for PureBasic [Windows]

Post by Zapman »

Axolotl wrote: Wed Dec 04, 2024 2:59 pmI'm surprised that the first part works.

Code: Select all

PBPrefAddr$ = GetHomeDirectory() + "AppData\\Roaming\\PureBasic\\PureBasic.prefs"
PureBasic has not any problem with that. But I agree that it's not clean. I really don't know how this syntax managed to slip into my code :?
It will be rectified into the next version.
Post Reply