Author Topic: Hey Rho...  (Read 3624 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Hey Rho...
« on: December 31, 2019, 07:20:06 pm »
I just downloaded and used your Notepad++ stuff to help setup Notepad++ for QB64, and I wanted to take a moment to thank you for the hard work you went through putting everything together for everyone.

One trick which I did come up with, which you might want to consider implementing for your own use, is to:

1) Remove REM from the Comment Line Style in the User Defined Language set up.
2) In the Folder & Default tab, set yourself a very simple set of commands for folding code, using that REM statement.  I configured mine for "REM BlockStart" and "REM BlockEnd".

Now, whenever I want a segment of code to be foldable, all I have to do is place the code I want to fold into the middle of those two commands, such as:

Code: [Select]
REM BlockStart: Function ProcessMenu
FUNCTION ProcessMenu$ (k AS LONG, active AS INTEGER)
    'k is for the keyboard
    'active is a return code for which menu we got the result from, in case someone makes multiple menus
    '    with the same options listed in the sub menus, such as PAINT -- Circle as one menu/submenu
    '    and then DRAW -- Circle as another menu/submenu.
    '    Both would just return "Circle" as our final choice, so we'd need to know which menu was active
    '    and where the command came from.


    DIM Caption AS STRING
    STATIC oldmouse AS INTEGER 'the old status of our left mouse button (up or down)
    mb = _MOUSEBUTTON(1) 'shortcut key so I don't have to type _mousebutton(1) multiple times.
    mx = _MOUSEX: my = _MOUSEY 'same here.

    IF mb AND NOT oldmouse THEN 'we only need to check the menu IF we clicked the mouse button
        oldmouse = mb 'placed here in case we exit early (which we can)
        FOR i = 1 TO UBOUND(menu) 'check for mouse interactions
            IF Menu(i).Layout AND Visible THEN 'only if a menu is visible do we check to see if we can do something with it.
                x = Menu(i).Left: y = Menu(i).Top 'top and left
                w = Menu(i).Wide: h = Menu(i).High
                r = x + w: b = y + h 'bottom and right

                IF mx >= x AND mx <= r AND my >= y AND my <= b THEN 'the mouse in over a visible menu
                    IF Menu(i).Active THEN 'if that window is active, return a result
                        IF Menu(i).Layout AND Hortizontal THEN
                            IF Menu(i).Layout AND Minimized THEN
                                Menu(i).Layout = Menu(i).Layout AND NOT Minimized
                                Menu(i).Active = 0
                                HideSubMenus
                                EXIT FUNCTION
                            ELSE
                                FOR j = 1 TO Menu(i).Options
                                    oldpx = px
                                    Caption = SCC(Captions(i, j))
                                    px = px + _PRINTWIDTH(Caption)
                                    IF mx >= oldpx AND mx <= px THEN 'we clicked on an item
                                        Menu(i).Active = j
                                        GOTO itemselected
                                    END IF
                                    px = px + _FONTWIDTH * 2
                                NEXT
                            END IF
                        ELSE 'It's a vertical menu
                            Menu(i).Active = (my - y) \ _FONTHEIGHT + 1
                            GOTO itemselected
                        END IF
                    ELSE 'if the menu we're over isn't active, then make it the active menu
                        Menu(i).Active = 1
                        FOR j = 1 TO UBOUND(menu)
                            IF j <> i THEN 'close all the other (non-main) menus.
                                IF Menu(j).Layout AND SubMenu THEN Menu(j).Layout = Menu(j).Layout AND NOT Visible
                                Menu(j).Active = 0
                            END IF
                        NEXT
                    END IF
                END IF
            END IF
        NEXT
    END IF
    oldmouse = mb 'placed here in case we don't go into the mouse checking loop

    FOR i = 1 TO UBOUND(menu)
        IF Menu(i).Active THEN EXIT FOR
    NEXT
    IF i > UBOUND(menu) THEN EXIT FUNCTION'no menus active

    IF GCC(Captions(i, Menu(i).Active), "É", p%) <> "" THEN
        Menu(i).Active = Menu(i).Active + 1
    ELSEIF GCC(Captions(i, Menu(i).Active), "È", p%) <> "" THEN
        Menu(i).Active = Menu(i).Active - 1
    END IF
    SELECT CASE k
        CASE 13
            itemselected:
            IF Captions(i, Menu(i).Active) = "ð" THEN
                IF Menu(i).Layout AND Minimized THEN
                    Menu(i).Layout = Menu(i).Layout AND NOT Minimized
                ELSE
                    Menu(i).Layout = Menu(i).Layout OR Minimized
                END IF
            ELSE
                active = i
                ProcessMenu$ = SCC(Captions(i, Menu(i).Active)) 'Strip the command code for the return name
                CC$ = GCC(Captions(i, Menu(i).Active), "{", p%) 'but process the command code, if it's available
                IF CC$ <> "" THEN
                    OpenSubMenu i, CC$
                ELSE
                    'we clicked on something without a command code
                    'hide all the submenus which are open from the screen
                    HideSubMenus
                END IF
            END IF
            Menu(i).Active = 0
            k = 0 'keyboard process has been handled internally
            EXIT FUNCTION
        CASE 27, 100319
            FOR i = 1 TO UBOUND(menu) 'Turn all menus inactive
                Menu(i).Active = 0
            NEXT
            HideSubMenus 'and hide them
            k = 0 'don't return a keycode back to the main program itself
            EXIT FUNCTION
        CASE 19200 'left arrow
            IF Menu(i).Layout AND Hortizontal THEN
                Menu(i).Active = Menu(i).Active - 1
                IF Menu(i).Active < 1 THEN Menu(i).Active = Menu(i).Options
            END IF
            k = 0 'keyboard process has been handled internally
        CASE 19712 'right arrow
            IF Menu(i).Layout AND Hortizontal THEN
                Menu(i).Active = Menu(i).Active + 1
                IF Menu(i).Active > Menu(i).Options THEN Menu(i).Active = 1
            END IF
            k = 0 'keyboard process has been handled internally
        CASE 18432 'up arrow
            IF (Menu(i).Layout AND Hortizontal) = 0 THEN
                Menu(i).Active = Menu(i).Active - 1
                IF Menu(i).Active < 1 THEN Menu(i).Active = Menu(i).Options
                recheckup:
                IF GCC(Captions(i, Menu(i).Active), "É", p%) <> "" THEN
                    Menu(i).Active = Menu(i).Active - 1
                    IF Menu(i).Active < 1 THEN Menu(i).Active = Menu(i).Options: GOTO recheckup
                ELSEIF GCC(Captions(i, Menu(i).Active), "È", p%) <> "" THEN
                    Menu(i).Active = Menu(i).Active - 1
                    IF Menu(i).Active < 1 THEN Menu(i).Active = Menu(i).Options: GOTO recheckup
                ELSEIF GCC(Captions(i, Menu(i).Active), "Ì", p%) <> "" THEN
                    Menu(i).Active = Menu(i).Active - 1
                    IF Menu(i).Active < 1 THEN Menu(i).Active = Menu(i).Options: GOTO recheckup
                END IF
            END IF
            k = 0 'keyboard process has been handled internally
        CASE 20480 'down arrow
            IF (Menu(i).Layout AND Hortizontal) = 0 THEN
                Menu(i).Active = Menu(i).Active + 1
                IF Menu(i).Active > Menu(i).Options THEN Menu(i).Active = 1
                recheckdown:
                IF GCC(Captions(i, Menu(i).Active), "É", p%) <> "" THEN
                    Menu(i).Active = Menu(i).Active + 1
                    IF Menu(i).Active > Menu(i).Options THEN Menu(i).Active = 1: GOTO recheckdown
                ELSEIF GCC(Captions(i, Menu(i).Active), "È", p%) <> "" THEN
                    Menu(i).Active = Menu(i).Active + 1
                    IF Menu(i).Active > Menu(i).Options THEN Menu(i).Active = 1: GOTO recheckdown
                ELSEIF GCC(Captions(i, Menu(i).Active), "Ì", p%) <> "" THEN
                    Menu(i).Active = Menu(i).Active + 1
                    IF Menu(i).Active > Menu(i).Options THEN Menu(i).Active = 1: GOTO recheckdown
                END IF
            END IF
            k = 0 'keyboard process has been handled internally
    END SELECT
    FOR j = 1 TO Menu(i).Options
        CC$ = GCC(Captions(i, j), "@", p%)
        IF CC$ <> "" THEN
            c = ASC(LCASE$(CC$))
            IF k = c OR k = c + 32 THEN
                ProcessMenu$ = SCC(Captions(i, j)) 'Strip the command code for the return name
                CC$ = GCC(Captions(i, j), "{", p%) 'but process the command code, if it's available
                IF CC$ <> "" THEN OpenSubMenu i, CC$ ELSE HideSubMenus
                Menu(i).Active = 0
                k = 0
            END IF
        END IF
    NEXT
END FUNCTION
REM BlockEnd

That whole function is now collapsable, with only the "REM BlockStart: Function ProcessMenu" displaying in the program listing.

Notepad++'s collapsing is a little glitched with EXIT FUNCTION or EXIT SUB being parsed as a SUB/FUNCTION in regards to folding (and thereby screwing things up majorly), and "ELSE IF" and "ELSE" doesn't want to play nicely together, but you can still work around the process with just a little creative use with comments to create a folding block.

It works quite nicely for me, where I use ' for my remarks, and never really make use of REM.  In a way, it's nice to repurpose that command and make it useful in my coding once more.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Hey Rho...
« Reply #1 on: December 31, 2019, 08:57:26 pm »
Hi Steve,

I'm prettyx drunkenn right now, Happy News Yeas, but sure did implemet '~~~ as fold stat, and '~~~~~ as end.

Code: QB64: [Select]
  1. '~~~ some folds cometnt
  2. code here...
  3. '~~~~~
  4.  

remove REM, if wannt use UDL with no case

Jesus, cant concentrate, ned sleep, checkit latter..............
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

FellippeHeitor

  • Guest
Re: Hey Rho...
« Reply #2 on: December 31, 2019, 10:24:14 pm »
Hi Steve,

I'm prettyx drunkenn right now, Happy News Yeas, but sure did implemet '~~~ as fold stat, and '~~~~~ as end.

Code: QB64: [Select]
  1. '~~~ some folds cometnt
  2. code here...
  3. '~~~~~
  4.  

remove REM, if wannt use UDL with no case

Jesus, cant concentrate, ned sleep, checkit latter..............




🤣🍾

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Hey Rho...
« Reply #3 on: January 01, 2020, 05:56:34 am »
Hi Steve,

I'm prettyx drunkenn right now, Happy News Yeas, but sure did implemet '~~~ as fold stat, and '~~~~~ as end.

Code: QB64: [Select]
  1. '~~~ some folds cometnt
  2. code here...
  3. '~~~~~
  4.  

remove REM, if wannt use UDL with no case

Jesus, cant concentrate, ned sleep, checkit latter..............

I see that now, though I think I still prefer the REM StartBlock for myself personally, just for my own readability.  :P

A few things I've noticed, which you may know a way around:

1) The encoding page is wrong for us, by default.  QB64 needs OEM-US so that it'll display the ASCII set which we use by default with QB64.  (Change that by going into Encoding, Character Sets, Western European, OEM-US.)

2) Even though you added the user functions to the auto-complete function list, I can't find any way to change the color of user functions in the IDE.  Is there anyway to do that, so user functions/variables can be highlighted a different color for readability, that you know of?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Hey Rho...
« Reply #4 on: January 01, 2020, 07:30:43 am »
Oh boys, what a party, Happy 2020 to everyone,

Steve, hope you didn't install the latest 7.8.2 of Notepad++, if so you should revert back to 7.8.1 at least until 7.8.3 comes out. This is as I've noticed 7.8.2 has a bug that scrambles up the syntax highligting and sometimes even eats one or two lines of code. As far as I can replicate this odd behavior it seems to be especially happen when pasting content from the clipboard, but it's sporadic, it does not always happen.

Also since 7.x.x (don't remember the exact version) there's a not yet fixed bug in the "Themes" and "UDL" import logic, which sometimes fills the "fontName" and "fontSize" properties of the imported XML files with garbage. So you should rather copy the files manually over to the respective N++ folders, rather than using the "Import" Menu/Button.

1) The encoding page is wrong for us, by default.  QB64 needs OEM-US so that it'll display the ASCII set which we use by default with QB64.  (Change that by going into Encoding, Character Sets, Western European, OEM-US.)
Not part of any of my provided files, but indeed worth to be mentioned in the documentation in the next release.

2) Even though you added the user functions to the auto-complete function list, I can't find any way to change the color of user functions in the IDE.  Is there anyway to do that, so user functions/variables can be highlighted a different color for readability, that you know of?
Guess you mean functionList.xml, that's no auto-completion, it's a regex based search pattern to find defined '~~~ style fold markers, SUB and FUNCTION keywords to display those in the function list panel of N++ (see menu "View" and tick "Function List" or use the respective toolbar button)

There's no auto-complete stuff at all for QB64 (would be a file similar to those in N++'s "API" folder),

1.) To change colors of the user defined stuff, just open the UDL dialog (menu "Language" > "User Defined Language" > "Define your Language..." or press the respective toolbar button)
2.) press the "Stylers" button right next to the items/group you wanna change
3.) in the popped styles dialog simply click on the colored squares labeled
Foreground/Background color and a palette will popup

Note that you should first be sure which theme you wanna use, and then adapt the background color of all UDL items to that theme's default background, otherwise it might produce an undesireable ugly display, if the theme and UDL colors doesn't match.
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Hey Rho...
« Reply #5 on: January 01, 2020, 08:03:57 am »
There's no auto-complete stuff at all for QB64 (would be a file similar to those in N++'s "API" folder),

I'm getting auto-complete for QB64 code, as illustrated by the screenshot below.



What I'm curious about is setting a custom color for run-time variables and functions.  For example:

Code: [Select]
X = 123
Foo X
PRINT X

SUB Foo (Param)
    Param = Param + 2
END SUB

Now currently, the IDE will color PRINT, SUB, the 2, and 123; but X, Foo, and Param won't be, as they're not a language-specific function which we included in our predefined list.   In the screenshot, you can see where some of my user-functions are now included in the drop-down auto-complete menu, so the IDE is tracking those functions/words for us..  What I'm curious about, is if there's a way to color them differently, if one wants to, so we can see something like the following:

X = 123
Foo X
PRINT X

SUB Foo (Param)
    Param = Param + 2
END SUB

As you can see, my QB64 functions are Green, the user function Foo is Red, My Variables are Yellow, and my constants are Blue...

I've sorted out how to make the native qB64 functions one color, and the constants another color, but is there a way to set a color for the user functions to highlight them, to make it easier to tell at a glance if FOO is a variable, or a Function inside the code?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Hey Rho...
« Reply #6 on: January 01, 2020, 08:38:10 am »
I'm getting auto-complete for QB64 code, as illustrated by the screenshot below.

In the screenshot, you can see where some of my user-functions are now included in the drop-down auto-complete menu, so the IDE is tracking those functions/words for us..

What I'm curious about, is if there's a way to color them differently, if one wants to..

Oh see, I never noticed this, as I usually install N++ completly without auto-completion. I hate if every moment anything's popup while typing, it just confuses me, so I rather write completely by myself than using this feature :), but good to know that the addition to the functionList.xml (which I guess is responsible to collect this list of auto-complete names) will work that way.

However, the only way I know for that kind of coloring you want, is to reserve an own group for it in the UDL, but you've to enter each variable name you ever use, probably not what you're looking for :(

Probably you'll find more information here https://npp-user-manual.org/docs/auto-completion/
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Hey Rho...
« Reply #7 on: January 01, 2020, 09:20:59 am »
Just see you can mark things with 5 different styles (menu Search > Mark All...), which you can change under Settings > Style configurator, left list "Global Styles" right list "Mark Style 1-5".

However, this is only temporarily, but might help if you're looking to find the spots, where a particular variable is used, as you may use the Search menu > Jump up/down to go through the marked words like with regular bookmarks or search results.
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack