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 »

The Beta 0.21b is online.
It includes Russian language. I made that with ChatGPT, so, there's probably some sentences not perfectly translated. Please tell me, AZJIO.
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 7:39 pm 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.
Hi again, AZJIO . Thanks a lot for your different feedbacks!!

The colors you can see inside the windows are taken from PureBasic pref file. Normally, they are exactly the same as the ones you've in your PureBasic IDE. So, if something is not at your taste, what you have to do is just to change the colors into the IDE and to restart PBBrowser.

[ADDED] : With your screen shot, I can see that your default font is bigger than mine. What's exactly the system you're runing on your PC ?

[ADDED] : Oops! I apologize: I didn't think enough before answering you about the colors. The red in the title does not come from PureBasic preferences, in fact. I'm going to ask you to be a little patient about this: I'm building a preferences panel for PBBrowser, to adjust all the settings specific to it. But it's going to take me a little time. The Color Requester you've seen in another post will be used for settings.
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 made a partial translation. Some words don't fit on the buttons, so I made them abbreviated. I used Google, so some words, although different, have the same meaning, so your version is quite normal.

Ctrl+F
Rechercher, Chercher, Respecter, Mot entie - no translation

I'm using Win10x64 with Arial 11/12 larger font

Can you take the font name and size from PureBasic?
Why do you use EditorGadget for source and expression input fields when StringGadget would be suitable?
On the "Macros" tab, on a black background, there is black text "No element was found."
You can set the height of the button in the PBBrowser.prefs settings and use this for the input field and button when calculating window resizing. Then if someone has a large font, he can fix it with the height of the button.
Why duplicate the "Close" button at the bottom? There is also a button at the top (X) and a hot key (Esc).
"Time spent exploring" -> "Time spent scanning".
"Execute" -> "Site" (HyperLinkGadget?)
Why does only the GUI change when changing the language? From this I conclude that the windows are created but hidden, otherwise using the updated variables would lead to modified windows.
Why include help texts in the executable file? Isn't it possible to make an external CHM file?
"Cosmetic Enhancer" has a problem with "Define * element" pointers. Here you can check whether there is a digit after the asterisk; the variable cannot begin with a digit. Also check which element is before the asterisk; if it is the beginning of a line or a keyword, then the asterisk is a pointer marker. You can look at my Tide utility.
I use tabs for indentation.
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 10:05 pm I made a partial translation. Some words don't fit on the buttons, so I made them abbreviated. I used Google, so some words, although different, have the same meaning, so your version is quite normal.
All right! I've adapted some gadgets width in order to support longer strings. So, I keep my Russion language version which is more complete. If, in the future, you find any word or sentence that is not the right one, please tell me.
AZJIO wrote: Thu Dec 05, 2024 10:05 pmCtrl+F - Rechercher, Chercher, Respecter, Mot entie - no translation
That was an authentic bug. It's fixed with beta 0.22
AZJIO wrote: Thu Dec 05, 2024 10:05 pmI'm using Win10x64 with Arial 11/12 larger font
So, I decided to reset the font used by PBBrowser's gadgets to the standard Segoe UI - 9 pts. The explanation is bellow:
AZJIO wrote: Thu Dec 05, 2024 10:05 pmYou can set the height of the button in the PBBrowser.prefs settings and use this for the input field and button when calculating window resizing. Then if someone has a large font, he can fix it with the height of the button.
I appreciate the suggestion, but it won't solve all the potential problems: for example, width of many gadgets will probably be to tight.
Of course, I could mesure the size of each string and adapt the size of each gadget to it, and, then, adapt the global design of the window to the new gadgets width, but it's a nightmare to put together. Tell me if my solution seems satisfying to you.
AZJIO wrote: Thu Dec 05, 2024 10:05 pmWhy do you use EditorGadget for source and expression input fields when StringGadget would be suitable?
To be able to manage sliders, when the content is to big to fit in the field.
AZJIO wrote: Thu Dec 05, 2024 10:05 pmOn the "Macros" tab, on a black background, there is black text "No element was found."
It was another authentic bug. Fixed with beta 0.22
AZJIO wrote: Thu Dec 05, 2024 10:05 pmWhy duplicate the "Close" button at the bottom? There is also a button at the top (X) and a hot key (Esc).
To respect all possible user habits.
AZJIO wrote: Thu Dec 05, 2024 10:05 pm"Time spent exploring" -> "Time spent scanning".
I don't agree. The 'exploration' expression has a particular meaning in the PBBrowser vocabulary. It corresponds to the 'Elements' identification.
AZJIO wrote: Thu Dec 05, 2024 10:05 pm"Execute" -> "Site" (HyperLinkGadget?)
Why not. But what for?
AZJIO wrote: Thu Dec 05, 2024 10:05 pmWhy does only the GUI change when changing the language? From this I conclude that the windows are created but hidden, otherwise using the updated variables would lead to modified windows.
The editorGadgets content is not reset by the 'Language' command. But as soon as you launch a new search, this content is refreshed with the chosen language. It's really a detail, because we don't change languages ​​every day. But I grant you that it could be improved.
AZJIO wrote: Thu Dec 05, 2024 10:05 pmWhy include help texts in the executable file? Isn't it possible to make an external CHM file?
I wanted to combine help texts and Tools/menu settings because it seem very important to me that each tool (even custom tools added by the user) has its own little description text. As you can see, when you choose a tool description in this pannel, you get access to its shortcut configuration its menu visibility and a possibility to execute it.
AZJIO wrote: Thu Dec 05, 2024 10:05 pm"Cosmetic Enhancer" has a problem with "Define * element" pointers. Here you can check whether there is a digit after the asterisk; the variable cannot begin with a digit. Also check which element is before the asterisk; if it is the beginning of a line or a keyword, then the asterisk is a pointer marker. You can look at my Tide utility. I use tabs for indentation.
Checking if the variable begin with a digit solves only some cases. Looking at what is before the "*" char is safer. There was a bug in that part of the Cosmetic enhancer. It's fixed in Beta 0.22.
I did'nt know your tool which is very interresting. I've seen that it's a sort of dupplicate from another similar tool. If you think that one of these does the things in a better manner than my "Cosmetic Enhancer", please describe what you want to add or modify.

You gave me a wonderful list of comments and bug reports. A huge thank you! I hope I have answered most satisfactorily.
If you have special wishes, I am here to listen to you.

Beta 0.22 is online.
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: A complete code browser for PureBasic [Windows]

Post by HeX0R »

For an automatic installation of your tool into PB, you could also use this:
viewtopic.php?f=12&t=62033
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Re: A complete code browser for PureBasic [Windows]

Post by AZJIO »

Zapman wrote: Fri Dec 06, 2024 4:06 pm I did'nt know your tool which is very interresting
Do you know about this FindAllReferences tool? Video15minutes, Video3minutes.
Zapman wrote: Fri Dec 06, 2024 4:06 pm So, I decided to reset the font used by PBBrowser's gadgets to the standard Segoe UI - 9 pts. The explanation is bellow:
You can add font size in settings. If the text does not fit, the user will decide what to do, leave small font or shorten the words in the language translation file. You can add the font size for Scintilla in the settings, this will not lead to a problem in any case.
You can use the Limit() function to limit how much font size can be adjusted.
I tried version 022 with font 9, it doesn’t look critical, but the text in Scintilla is too small for me. It's not comfortable. I use Arial even though it's not monospaced. The code is not tabular data, although some of it may be present in the DataSection. I'm used to my font and it's not difficult to add to the settings.
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: Fri Dec 06, 2024 6:05 pmDo you know about this FindAllReferences tool? Video15minutes, Video3minutes.
No, I didn't know. The approach is different from that of PBBrowser and it is very, very interresting. And, what's more, the code is open source! I couldn't try it because there was a compilation problem ("The required compiler was not found: PureBasic 6.04 LTS - C Backend (Windows - x86)") but I'll work on it. Even if it doesn't do all what PBBrowser does, it is a very good concept and I can perhaps integrate a part of it in PBBrowser, if you agree.
AZJIO wrote: Fri Dec 06, 2024 6:05 pmYou can add font size in settings. If the text does not fit, the user will decide what to do, leave small font or shorten the words in the language translation file. You can add the font size for Scintilla in the settings, this will not lead to a problem in any case.
For sure! I just precise that PBBrowser doesn't use Scintilla but an ordinary editorGadget.
AZJIO wrote: Fri Dec 06, 2024 6:05 pmThe code is not tabular data, although some of it may be present in the DataSection.
Sorry :oops: I don't understand that remark. The code presented in the PBBrowser editorGadget is tab organized. When the original source is not, PBBrowser replace all double-spaces by a tab.
AZJIO wrote: Fri Dec 06, 2024 6:05 pmI'm used to my font and it's not difficult to add to the settings.
I fully understand. It will need some days to finish the preferences pannel that I'm actally building.
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Re: A complete code browser for PureBasic [Windows]

Post by AZJIO »

Zapman wrote: Fri Dec 06, 2024 6:48 pm The required compiler was not found: PureBasic 6.04 LTS - C Backend (Windows - x86)
You can choose any compiler.
Zapman wrote: Fri Dec 06, 2024 6:48 pm if you agree.
It was created by several authors. I think no one will be against using it for their own purposes, including me. Usually if I don't want my code to be used, I just don't post it.
Zapman wrote: Fri Dec 06, 2024 6:48 pm It will need some days to finish the preferences pannel that I'm actally building.
In such cases, I make a button “Open ini file” because I’m too lazy to make a panel.
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: A complete code browser for PureBasic [Windows]

Post by Michael Vogel »

If added a constant to use the program in portable mode and changed the declaration code a little bit...

Added to main program:

Code: Select all

#PortableMode= #True
Change in 'PBBrowserDeclarations.pb':

Code: Select all

#FileSystem_Directory=	-2
#FileSystem_Nonexistent=	-1

Global MyAppDataFolder$

CompilerIf #PortableMode
	MyAppDataFolder$= GetPathPart(ProgramFilename()) + "Portable" + "\"
	If FileSize(MyAppDataFolder$)>#FileSystem_Directory
	CompilerEndIf
	
	MyAppDataFolder$= GetSystemFolder(#CSIDL_COMMON_APPDATA) + "\" + #NomProg + "\" ; Address of the data folder.
	
	CompilerIf #PortableMode
	EndIf
CompilerEndIf
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 »

Michael Vogel wrote: Sat Dec 07, 2024 2:08 pm If added a constant to use the program in portable mode and changed the declaration code a little bit...
Excellent! But I'd rather suggest:

Code: Select all

#PortableMode = #True ; Suggestion from Michael Vogel https://www.purebasic.fr/english/viewtopic.php?p=631763#p631763
;
CompilerIf #PortableMode
  Global MyAppDataFolder$= GetCurrentApplicationPath() + #NomProg + "_Data" + "\"
CompilerElse
  Global MyAppDataFolder$= GetSystemFolder(#CSIDL_COMMON_APPDATA) + "\" + #NomProg + "\" ; Address of the data folder.
CompilerEndIf
Explanations:
-> GetCurrentApplicationPath() (from ZapmanCommon.pb) return the path of the .exe file OR the path of PBBrowser.pb if the application is running from IDE. So, the settings of the user will remain the same until he/she compile the .exe at the same level as the .pb source-code.
-> If MyAppDataFolder$ does'nt exist, it's not a problem. It will be automatically created by the procedure UpdateAppDataFolder() at the beggining of PBBrowserInitialize.pb

I've integrated the code above at the beggining of PBBrowserDeclaration.pb
Thank you very much :)
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: Fri Dec 06, 2024 7:25 pmIt was created by several authors. I think no one will be against using it for their own purposes, including me. Usually if I don't want my code to be used, I just don't post it.
Thank you so much. I tried it. I really think it would be a good idea to implement something similar in PBBrowser, as an additional approach to finding something in the code or to get a feel for the nature of the code being looked at.
I'll think about it later.
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 »

Beta 0.23 is online. BPProwser can now be installed and uninstalled as a tool, in portable versions of PureBasic. Also, PBBrowser can be set itself as portable, by changing the value of the first constant figuring into the file "PBBrowserDeclarations.pb".
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Re: A complete code browser for PureBasic [Windows]

Post by AZJIO »

Code: Select all

; To Do: ...
; ...
;        Mac OS and Linux versions.
I did a search and got 309 WinAPI functions. It will be difficult to remake this for Linux. I still don't know how to change the line position with an external tool. The FindAllReferences tool uses the third-party utility xdotool to invoke the Ctrl+G hotkey to bring up the move to line dialog and invokes the Ctrl+V and Enter hotkeys. But this doesn't work reliably.

If you add this information to the end of the file, then when you hover over the file, the file version will be displayed in the tooltip.

Code: Select all

; IncludeVersionInfo
; VersionField0 = 0.23.0.0
; VersionField2 = Zapman
; VersionField3 = PBBrowser
; VersionField4 = 0.23.0.0
; VersionField6 = PBBrowser
; VersionField9 = Zapman

Code: Select all

DeleteCommentsAndSpacesFromPBCode
You might be interested in my version
You can see other things here (alignment of comments)
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 »

Beta 0.24 is online.
• PBBrowser is now able to open projects. Also, if a file is open in PBBrowser and it appears that it belongs to a project currently open in the IDE, this project will be entirely considered.
• In addition to the constant #PBBPortableMode that allow you to set a portable mode for PBBrowser, it is also possible now to send the command line "\PORTABLE" to PBBrowser (exactly as you can do for PureBasic).
• The tool installation process has been completed and optimized.
• A small bug of 'Create or update a PureBasic project' function has been fixed. I would like to take this opportunity to tell you about this function and its benefits:
  • From the list of files that PBBrowser draws up by examining the 'IncludedFile' mentions they contain, it creates a project in a fully automated manner.
  • The big advantage of this function is that it recovers all the settings you may have made in the compilation options and transfers these settings to the created project. This way, it is no longer necessary to have to redo everything by hand.
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: Sun Dec 08, 2024 5:01 amI did a search and got 309 WinAPI functions. It will be difficult to remake this for Linux.
There’s definitely work to be done. But by moving forward file by file, I think I can achieve it. It will take a few months.
AZJIO wrote: Sun Dec 08, 2024 5:01 amI still don't know how to change the line position with an external tool. The FindAllReferences tool uses the third-party utility xdotool to invoke the Ctrl+G hotkey to bring up the move to line dialog and invokes the Ctrl+V and Enter hotkeys. But this doesn't work reliably.
What I see in your code is that you find the Scintilla handle in the procedure 'Initialization()' and then send messages to it. I chose a much more simplistic method which works well: I send a command line to PureBasic:

Code: Select all

Procedure OpenFileWithPureBasic(FNameWithoutPath$, LineNumber$)
  ;
  ; Searches for FNameWithoutPath$ in PBBListOfFiles$ and opens the file
  ; in the PureBasic editor if a result is found.
  ;
  ; Uses global variables PBBListOfFiles$ and PureBasicProgAddr$
  ;
  Shared MustStayActive
  ;
  Protected PosInList, pf, FFile$, FParam$, FPath$
  ;
  PosInList = FindString(PBBListOfFiles$, "\" + FNameWithoutPath$, 0) ; Searches for the expression in PBBListOfFiles$.
  If PosInList
    pf = PosInList + Len(FNameWithoutPath$) + 1
    While PosInList > 1 And Mid(PBBListOfFiles$, PosInList - 1, 1) <> Chr(9) And Mid(PBBListOfFiles$, PosInList - 1, 1) <> Chr(13) : PosInList - 1 : Wend
    FFile$ = Mid(PBBListOfFiles$, PosInList, pf - PosInList)
    If FindString(FFile$, "\Temp\PureBasic_TempFile") ; This is a temporary file. Its address is not passed.
      FParam$ = ""
      FPath$ = ""
      AlertInPBBWindow(GetTextFromCatalogPB("SaveFilePrompt"))
    Else
      FPath$  = Chr(34) + GetPathPart(FFile$) + Chr(34)
      FParam$ = Chr(34) + FFile$ + Chr(34)
    EndIf
    If LineNumber$
      FParam$ + " /L " + LineNumber$ ; This addition to the parameters positions the PureBasic editor on a specific line.
    EndIf
    ;
    ; In case of double-click by the user, avoid
    ; overwhelming the editor with too many requests:
    ; there must be at least 500 ms since the last
    ; click for it to be taken into account.
    If PureBasicProgAddr$ And (ElapsedMilliseconds() - MustStayActive) > 500
      RunProgram(Chr(34) + PureBasicProgAddr$ + Chr(34), FParam$, FPath$)
      MustStayActive = ElapsedMilliseconds()
    EndIf
  EndIf
EndProcedure
Every time the user clicks on something that should be opened in the IDE, I call this procedure. If the file is allready open in the editor, it is simply set to the asked line. It's a little brutal, but effective.
AZJIO wrote: Sun Dec 08, 2024 5:01 amYou can see other things here (alignment of comments)
The first link is a fantastic collection of quality tools!! Thanks again for all the amazing ideas you come up with :!:
I've too much to do atm to work on that, but I keep the link as a treasure.
Post Reply