Page 1 of 6

Integrated 'Multicolored Procedure List' in IDE

Posted: Tue Sep 24, 2024 12:40 pm
by PeDe
I would like to work more with Linux, maybe switch completely from Windows. But without the 'Multicolor Procedure List' tool from RSBasic, I don't want to use PB. That's why I reprogrammed most of the functions and inserted them directly into the IDE.

Here are compiled test versions of the 'PureBasic.exe' for Windows 32-/64-Bit, Debian 12 64-Bit and Raspberry Pi OS 12 64-Bit (12 MB):

Code: Select all

https://www.dreisiebner.at/temp/PB-v612-MulticolorProcedureList.zip
You can activate the colored procedure list in the settings in the tools in the configuration of the 'Procedure Browser'.

If the set colors of the procedure list are important, you should save the preference file of PB. Otherwise they will be deleted when the official IDE is started.

Here is the modified code of the PB IDE v6.12 from 2024-09-13 (60 KB):

Code: Select all

https://www.dreisiebner.at/temp/PB-IDE-v612-Code-MulticoloredProcedureList.zip
The files have been changed:
Common.pb
Language.pb
ProcedureBrowser.pb

For each change there is a comment at the end with '; PeDre'
There are no debug outputs or speed measurements.

The buttons have no icons, only letters.

At the moment I don't know what to do with the code. Maybe it is also useful for someone else.

Peter

EDIT: The code archive has been updated.

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Tue Sep 24, 2024 2:35 pm
by Quin
Maybe consider opening a pull request against the GitHub repository. This is how many other members have gotten their changes officially added to the IDE.

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Wed Sep 25, 2024 11:50 am
by ChrisR
Very nice and well integrated into the IDE.

It would be nice to have an additional toggle button “Sort Procedure by name” here, rather than in the parameters.

Personally, I don't really understand the purpose of the S button (Automatically scroll to current procedure).
In my opinion, auto scroll should always be enabled together with the H button (Automatically determine and highlight the current procedure).

Thank you for sharing with also the modified sources.
It would be nice, indeed with a GitHub Pull Request, otherwise, it will be useful for rebuilding with future IDE updates .

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Wed Sep 25, 2024 5:47 pm
by PeDe
Hello ChrisR,

thanks for the nice comment.

Sometimes the automatic scrolling bothers me when I double-click on procedures to jump around in the code and then want to go back to the original procedure. It's easier if the list stays as it is.

I think the buttons belong at the bottom of the list, as it is with Explorer and Issues.

I have never used Git, but I have read the documentation.
But first of all the list has to be error-free in use, so far everything works.

Peter

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Wed Sep 25, 2024 8:13 pm
by AZJIO
Is it possible to make a regular expression or do the search from the beginning. For example, make marks starting with "●" red.

Code: Select all

[ProcedureBrowser_ItemColor]
" ● Global" = 12615935,-1
" ● ini" = 12615935,-1
"┌──GUI──┐" = 12615935,-1
"┌──Loop──┐" = 12615935,-1
screenshot

There is no icon for *.pb associations in the PureBasic.exe resources, you need to add it.

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Thu Sep 26, 2024 12:43 pm
by PeDe
I have moved the buttons to the bottom of the procedure list.

The second icon for the PB files is now available in the exe.

The ZIP archives have been updated. But the Raspberry Pi version is still the old one.

The Debian version crashes when using the copy button. I'm using ExamineKeyboard(), maybe that's the reason. I have to have a look at it first.

Peter

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Thu Sep 26, 2024 1:46 pm
by AZJIO

Code: Select all

; [ProcedureBrowser_ItemColor]
; " ● Global" = 12615935,-1 (delete, replace with another method)
; " ● ini" = 12615935,-1 (delete, replace with another method)
; "# Constants" = 12615935,-1 (delete, replace with another method)
; " ●" = 12615935,-1
; "#" = 12615935,-1

NewList Label$()
AddElement(Label$())
Label$() = " ● ini"
AddElement(Label$())
Label$() = " ● Global"
AddElement(Label$())
Label$() = "# Constants"
ini_find$ = " ●"
ini_find2$ = "#"

Len1 = Len(ini_find$)
ForEach Label$()
	If Left(Label$(), Len1) = ini_find$
		Debug Label$() + #TAB$ + "- highlight the code of the specified elements (color1)"
	EndIf
Next

Debug "———————"

Len2 = Len(ini_find2$)
ForEach Label$()
	If Left(Label$(), Len2) = ini_find2$
		Debug Label$() + #TAB$ + "- highlight the code of the specified elements (color2)"
	EndIf
Next
Use CopyMemory() to make it faster

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Thu Sep 26, 2024 3:31 pm
by ChrisR
The buttons at the bottom are fine.

I've made a few changes (commented with the tag: ChrisR), take a look and see if it suits you.
PB-IDE-v612-Code-MulticoloredProcedureList_mod.zip

- With Highlight ON, the automatic highlighting is also done for markers and macros, not just for procedures
- With Highlight OFF, nothing is highlighted! changed to keep current default IDE display with the last selected procedure highlighted

It's more in line with my tastes but maybe it's just a question of taste

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Thu Sep 26, 2024 4:41 pm
by PeDe
Hello ChrisR,

with your changes, everything could actually be selected, even within procedures.
With Highlight ON there is only the additional automatic selection in the procedure list.

Edit: No, it is not a good idea to select within procedures. Your changes are fine as they are.

@AZJIO
Comparing only with the beginning of an entry is not a problem.
To create a color preset, you would have to create a line in the code with only the desired part:

Code: Select all

Then select the colors and delete the line again.
Just remember to remove the colors and repeat the process.

The Debian and Raspberry Pi version really crashes on ExamineKeyboard(), or the IDE is terminated. A replacement for querying the keys would certainly be better. Under Windows I use GetAsynKeyState_().

Peter

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Thu Sep 26, 2024 5:53 pm
by AZJIO
I thought you were interested in making your add-ons more flexible. It will take me a long time to learn the code. therefore, I decided that small movements would not be difficult for you.

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Thu Sep 26, 2024 6:09 pm
by PeDe
Hello AZJIO,

this is probably a misunderstanding. I only described what I would have to program for your idea to work. And how you then have to use coloring and removing again.

Peter

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Thu Sep 26, 2024 6:27 pm
by ChrisR
Hello Peter,
PeDe wrote: Thu Sep 26, 2024 4:41 pm with your changes, everything could actually be selected, even within procedures.
With Highlight ON there is only the additional automatic selection in the procedure list.

Edit: No, it is not a good idea to select within procedures. Your changes are fine as they are.
I've read the edit now.
Cool if you like the idea, I didn't understand why it was limited to just procedures before.
And with Highlight Off, it is as before in the default IDE.

Maybe there could be a different default color for macros, like it is done for comments (ie: ProcedureBrowserCommentFront(Back)Color)

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Thu Sep 26, 2024 7:26 pm
by PeDe
Hello ChrisR,

I have adopted your changes and changed the ForEach loop in ProcedureBrowser_HighlightTimer().
If the cursor is outside a procedure, the next procedure, marker, macro or issue above is selected.

Peter

Code: Select all

    ; Search the procedure list and find the last procedure, marker, macro or issue before or at the cursor position.
    CurrentLine = *ActiveSource\CurrentLine
    Index = -1
    AboveLine = -1
    ForEach ProcedureList()
      With ProcedureList()

        ; Search for a procedure with the current line.
        If \Type = 0 And \Line <= CurrentLine And \LineProcedureEnd >= CurrentLine
          Index = Counter
          Type = \Type
          Break

        ; Search for procedure, marker, macro or issue above the current line.
        Else
          If ProcedureBrowserSort = 0 ; unsorted list
            If \Line <= CurrentLine
              Index = Counter
              Type = \Type
            Else
              Break
            EndIf
            
          Else ; sorted list
            If \Line <= CurrentLine
              If \Line > AboveLine
                AboveLine = \Line
                Index = Counter
                Type = \Type
              EndIf
            EndIf
          EndIf
        EndIf

      EndWith
      Counter + 1
    Next

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Thu Sep 26, 2024 8:49 pm
by ChrisR
It looks good with the list unsorted as sorted.
Thanks again for sharing Peter, it's useful, I will adopt it 8)

Re: Integrated 'Multicolored Procedure List' in IDE

Posted: Thu Sep 26, 2024 9:24 pm
by ChrisR
With the buttons at the bottom, there is no need to have the "Procedures" column header for the ListIconGadget, it is already written.
From Shardik's ListIconGadget without table header?

Code: Select all

    ListIconGadget(#GADGET_ProcedureBrowser, 0, 0, 0, 0, "Procedures", 100, #PB_ListIcon_FullRowSelect)
    CompilerSelect #PB_Compiler_OS
      CompilerCase #PB_OS_Linux
        gtk_tree_view_set_headers_visible_(GadgetID(#GADGET_ProcedureBrowser), #False)
      CompilerCase #PB_OS_MacOS
        CocoaMessage(0, GadgetID(#GADGET_ProcedureBrowser), "setHeaderView:", #False)
      CompilerCase #PB_OS_Windows
        SetWindowLongPtr_(GadgetID(#GADGET_ProcedureBrowser), #GWL_STYLE, GetWindowLongPtr_(GadgetID(#GADGET_ProcedureBrowser), #GWL_STYLE) | #LVS_NOCOLUMNHEADER)
    CompilerEndSelect