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

Re: A complete code browser for PureBasic [Windows]

Post by Zapman »

highend wrote: Wed Dec 04, 2024 3:19 pmThe error comes from inside the function CompleteListOfFiles()
It treats the first part of the relative path "#includes\<a file>" as a constant^^
Well done, highend!
Right, I have to optimize the constant recognition part (it should have on operator (+) after it to be recognized as a constant). Thanks a lot!
highend wrote: Wed Dec 04, 2024 3:19 pmIt will produce an AlertInPBBWindow(...) for EVERY single include file that it can't find.
I guess I was in too much of a hurry to sort it out. It works well for me, but there's definitely an explanation if it doesn't work for you. I'm sorry. I will take the time to review this part of the code.
Thank you for your patience.
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,
if you don't mind, I found this, where the code below does not match the comment.
Without further testing, I would recommend #PM_NOREMOVE for PeekMessage_().

Code: Select all

; Found in the ZapmanCommon.pb 
Procedure WaitForEventAchieve()
  ;
  ; Wait for system redrawing windows and gadgets
  ; without loosing PureBasic or other events.
  ;
  ; This is equivalent to "While WindowEvent() : Wend"
  ; except that it doesn't erase messages.
  ;
  ; This is also equivalent to a simple 'delay(1)'
  ; except that duration is not fixed here : the procedure
  ; get out of the loop when current operation (as redrawing
  ; a window) is completed.
  ;
  Protected msg.MSG
  ;
  While PeekMessage_(@msg, 0, 0, 0, #PM_REMOVE)   ; <== #PM_NOREMOVE ; ??? 
    TranslateMessage_(@msg)
    DispatchMessage_(@msg)
  Wend
EndProcedure
Don't worry, I've stopped snooping ... :oops:
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 »

What a harvest of feedback in just a few hours! This is fantastic, thank you, everyone!
Axolotl wrote: Wed Dec 04, 2024 3:42 pm Hi Zapman,
if you don't mind, I found this, where the code below does not match the comment.
Without further testing, I would recommend #PM_NOREMOVE for PeekMessage_().
You're absolutely right, Axolotl. I'll fix that, thank you again.
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 »

Zapman wrote: Wed Dec 04, 2024 3:17 pm
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".
Yes i do it, it say is installed, the shortcut is CTRL + Q, but no newtool in tool menu of purebasic editor(i restarted the editor and also click on unintall and install again from pbbrowser), and if i select a keyword/procedurename in editor and press ctrl+q nothing appear
Image
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 4:04 pmno newtool in tool menu of purebasic editor(i restarted the editor and also click on unintall and install again from pbbrowser), and if i select a keyword/procedurename in editor and press ctrl+q nothing appear
It seems that your PureBasic installation is not standard and that interrests me a lot.

Usually, when running for the first time, PureBasic creates a file named 'PureBasic.prefs' in a folder that the address is something like:
C:\Users\YourUserName\AppData\Roaming\PureBasic

In the same folder, there can be a 'Tools.prefs' that contains the tools configuration for the IDE. That's where PBBrowser tries to install the tool parameter for itself. If this file doesn't exist, PBBrowser creates it and fill it. If it allready exists, PBBrowser just adds its own parameters after having made a security copy of the original file (named ''ToolsBak1.prefs").

I propose to you 2 options:
1- I you have enough time for that, I'd love to understand what's particular in your configuration. Could you please try to follow the path given above (C:\Users\YourUserName\AppData\Roaming\PureBasic - Replace 'YourUserName' by your PC user name) and tell me what you have in this folder. If you find a 'Tools.prefs' file, what have you inside?
2- If you don't care to help for debugging, you can configure the tool manually - > Create a new custom tool in the IDE, and set it as following:
[*]Command line: open the compiled version of PBBrowser (PBBrowser.exe) on your disk
[*]Arguments: "%HOME" "%WORD" "%SELECTION" "%CURSOR" "%FILE" "%TEMPFILE"
[*]Name: PB Browser
[*]Event: Menu or Shortcut
[*]Shortcut: CTRL + Q
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 3:19 pm
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.
I think I get it, highend. I was misled, because the message you got repeatedly was probably NOT "One or more files declared as 'Include' or 'XInclude' are empty or do not exist at the indicated address." but "Error while analysing file XXXX --> Unsolved file name in an 'Include' declaration...".
Right?

The Beta 0.18e should solve the problem. It's online.
I thank you again for your help. This part of the program is strongest, now.
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 »

Zapman wrote: Wed Dec 04, 2024 4:38 pm
le_magn wrote: Wed Dec 04, 2024 4:04 pmno newtool in tool menu of purebasic editor(i restarted the editor and also click on unintall and install again from pbbrowser), and if i select a keyword/procedurename in editor and press ctrl+q nothing appear
It seems that your PureBasic installation is not standard and that interrests me a lot.

Usually, when running for the first time, PureBasic creates a file named 'PureBasic.prefs' in a folder that the address is something like:
C:\Users\YourUserName\AppData\Roaming\PureBasic

1- I you have enough time for that, I'd love to understand what's particular in your configuration. Could you please try to follow the path given above (C:\Users\YourUserName\AppData\Roaming\PureBasic - Replace 'YourUserName' by your PC user name) and tell me what you have in this folder. If you find a 'Tools.prefs' file, what have you inside?
Hi Zapman, i use purebasic in portable mode, start purebasic.exe /portable to use prefs on the installation dir and not in windows appdata
Image
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 5:21 pmHi Zapman, i use purebasic in portable mode, start purebasic.exe /portable to use prefs on the installation dir and not in windows appdata
Of course! I should have guessed on my own.
I'm going to install a portable version on my workstation and see how to handle this case as best as possible. Thank you so much.
highend
Enthusiast
Enthusiast
Posts: 162
Joined: Tue Jun 17, 2014 4:49 pm

Re: A complete code browser for PureBasic [Windows]

Post by highend »

0.18e works fine so far and thanks for summarising the files that couldn't be excluded instead of presenting one dialog for each of them^^

A feature request:
Atm the includes are listed like this:
It seems you are descending into each new include if finds to get further includes from that one and put it straight into the list?

Code: Select all

XY_Config handler.pb (main file)
constants.pbi included by XY_Config handler.pb
structures.pbi included by XY_Config handler.pb
...
includes.pbi included by includes.pbi
HideForm.pbi included by includes.pbi
includes.pbi included by includes.pbi
declarations.pbi included by includes.pbi
...
The problem: Without path information these infos aren't always very useful.

Look at:

Code: Select all

includes.pbi included by includes.pbi
HideForm.pbi included by includes.pbi
includes.pbi included by includes.pbi
These are includes.pbi files in a several module subfolders that import their own stuff.

But you have no clue when you look at the names from where they really are...

Would it be possible to create tooltips in the gui when you hover over the links?
They should contain the relative path derived from the root of your main file...

E.g.:

Code: Select all

.\#includes\forms\contstants.pbi [.\#includes\forms\includes.pbi]
.\#includes\forms\functions.pbi [.\#includes\forms\includes.pbi]
...
Thanks so far!
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: Thu Dec 05, 2024 2:43 pm 0.18e works fine so far and thanks for summarising the files that couldn't be excluded instead of presenting one dialog for each of them^^
I uploaded Beta version 0.20, which addresses the problem in an even more radical way: from now on, the examination of files stops when PBBrowser cannot interpret 'Included'-type declarations. In any case, the project analysis will not be valid if all 'Included' declarations are not correctly interpreted. But I don't think this will be a problem for you, since, from now on, mentions containing the '#' character are correctly interpreted, as well as those containing '//'.

highend wrote: Thu Dec 05, 2024 2:43 pm A feature request: Would it be possible to create tooltips in the gui when you hover over the links? They should contain the relative path derived from the root of your main file...
For now, none of the panels offer tooltips for anything. It's something I plan to add in the future, but it requires quite a bit of tweaking because the content of the panels is displayed in EditorGadgets, and it's not simple to add tooltips to specific mentions in the text.

I've choosen a solution more closely with the current logic of PBBrowser. Let me explain:
• When clicking on one of the included file names in the file list, it opened the file in the PureBasic IDE without positioning the cursor at a specific location in the code.
• With Beta 0.20, the file is opened into the IDE by positioning the cursor precisely where the 'Included' declaration is made. This shows the user the entire path declared at that location. It also allows him to modify this declaration if he wishes.

I hope you'll find that usefull
highend wrote: Thu Dec 05, 2024 2:43 pm Thanks so far!
Thanks for your valuable help. I'm committed to improving PBBrowser as much as I can.
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Re: A complete code browser for PureBasic [Windows]

Post by AZJIO »

Where does it look for language files? I added the Russian language, partially translated it and decided to enable it, but the program does not add a new language to the selection list. I have several PureBasic installations and I would not like to install manually without understanding what changes will be made by the program. It would be easier to create a “PBBrowser” folder in the tools folder and in it all the files necessary for it, and in the PureBasic settings I would add the tool myself.
I tried to compile, but it gives the error "IncludeBinary "Français\PBBrowser.catalog" the path does not exist because the file names use the Win1251 encoding and the letter ç has changed to "3".
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 »

AZJIO wrote: Thu Dec 05, 2024 6:10 pm Where does it look for language files? I added the Russian language, partially translated it and decided to enable it, but the program does not add a new language to the selection list. I have several PureBasic installations and I would not like to install manually without understanding what changes will be made by the program. It would be easier to create a “PBBrowser” folder in the tools folder and in it all the files necessary for it, and in the PureBasic settings I would add the tool myself.
Hi AZJIO,
  • PureBasic register 'PureBasic.prefs' in a folder with an address like: C:\Users\YourUserName\AppData\Roaming\PureBasic.
    In the same folder, there can be a 'Tools.prefs' that contains the tools configuration for the IDE. That's where PBBrowser tries to install the tool parameter for itself. If this file doesn't exist, PBBrowser creates it and fill it. If it allready exists, PBBrowser just adds its own calling parameters after having made a security copy of the original file (named ''ToolsBak1.prefs").
    Normally, even if you have several installations of PureBasic, you have only ONE parameter file ('PureBasic.prefs') for all, except if you use 'StandAlones' (portable mode) versions of PureBasic. For StandAlones versions, the .prefs file of each one is in the same folder as PureBasic.
  • To avoid the risk of polluting or disrupting PureBasic, PBBrowser saves its own parameters in an independent folder that can be easily found following the address: C:\ProgramData\PBBrowser. The language files are in C:\ProgramData\PBBrowser\Catalogs. If you add a folder inside this folder, you'll have automatically the possibility to choose a new language with PBBrowser (after a restart). You DON'T need to change the code.
AZJIO wrote: Thu Dec 05, 2024 6:10 pmI tried to compile, but it gives the error "IncludeBinary "Français\PBBrowser.catalog" the path does not exist because the file names use the Win1251 encoding and the letter ç has changed to "3".
Thank you very much for the information. I didn't imagine that the "ç" character could be a problem. I'll fix that. You can do it yourself if you want to gain time : change the folder name in C:\ProgramData\PBBrowser\Catalogs and replace Français by Francais in the code.
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Re: A complete code browser for PureBasic [Windows]

Post by AZJIO »

I managed to trace the path

Code: Select all

; PBBrowser
#NomProg = "PBBrowser"

; PBBrowserDeclarations
Global MyAppDataFolder$ = GetSystemFolder(#CSIDL_COMMON_APPDATA) + "\" + #NomProg + "\" ; Address of the data folder.
; = C:\ProgramData\PBBrowser\Catalogs\

; ZapmanCommon
Procedure.s GetSystemFolder(FolderType)
  If SHGetSpecialFolderLocation_(0, FolderType, @ItemID) = #NOERROR
    Location$ = Space(#MAX_PATH)
    If SHGetPathFromIDList_(ItemID, @Location$)
      ProcedureReturn Location$
    EndIf
  EndIf
EndProcedure

; PBBrowserInitialize
PBBLanguageFolder$ = ChooseLanguage(MyAppDataFolder$ + "Catalogs\")

; ChooseLanguage
Procedure.s ChooseLanguage(folder$, LDefault$ = "")
  ;...
  If ExamineDirectory(0, folder$, "*.*") ; ->C:\ProgramData\PBBrowser\Catalogs\
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 »

AZJIO wrote: Thu Dec 05, 2024 6:47 pm I managed to trace the path

Code: Select all

; PBBrowser
#NomProg = "PBBrowser"

; PBBrowserDeclarations
Global MyAppDataFolder$ = GetSystemFolder(#CSIDL_COMMON_APPDATA) + "\" + #NomProg + "\" ; Address of the data folder.
; = C:\ProgramData\PBBrowser\Catalogs\

; ZapmanCommon
Procedure.s GetSystemFolder(FolderType)
  If SHGetSpecialFolderLocation_(0, FolderType, @ItemID) = #NOERROR
    Location$ = Space(#MAX_PATH)
    If SHGetPathFromIDList_(ItemID, @Location$)
      ProcedureReturn Location$
    EndIf
  EndIf
EndProcedure

; PBBrowserInitialize
PBBLanguageFolder$ = ChooseLanguage(MyAppDataFolder$ + "Catalogs\")

; ChooseLanguage
Procedure.s ChooseLanguage(folder$, LDefault$ = "")
  ;...
  If ExamineDirectory(0, folder$, "*.*") ; ->C:\ProgramData\PBBrowser\Catalogs\
That's what I told you in my precedent message: "C:\ProgramData\PBBrowser\Catalogs".
Anyway, I've updated the code. The beta 0.21 is online as the same adresse given above (in the first post). It should solve the "ç" problem on your PC.
While runing this new version, you will probably get two language choices: 'Français' and 'Francais'. So you will have to delete the C:\ProgramData\PBBrowser\Catalogs folder to clean your machine (and then, restart PBBrowser).

A complete Russian version of PBBrowser will be soon proposed in standard. :wink:
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Re: A complete code browser for PureBasic [Windows]

Post by AZJIO »

Red text is not visible.
Gray is too faded.
I think it's worth determining if the background is black so that you can use other colors for the black theme.
Image

Code: Select all

IsWhite = 1
background = $3F3F3F
AverageValue = (Red(background) + Green(background) + Blue(background)) / 3
Debug "AverageValue = " + Str(AverageValue)
If AverageValue < 128
	IsWhite = 0
EndIf
Debug "IsWhite = " + Str(IsWhite)
Last edited by AZJIO on Thu Dec 05, 2024 9:40 pm, edited 2 times in total.
Post Reply