Feature Request: colorize UDFs and UDSs

Started by cssyphus, May 18, 2024, 09:38:43 AM

Previous topic - Next topic

cssyphus

With the new feature of listing all UDFs/UDSs in dropdown on toolbar, you already have them all... Would it be possible to colorize those in the code?

That would be great for helping to catch spelling mistakes, and to make them stand out in code.

If accepted, please colorize as different from in-built funcs... and could that color be tweakable in WIL.clr?

---

Other wishes:

- Editor: when select a variable name (or any text), highlight that string throughout the file

- Editor: Duplicate Line via keyboard (without replacing clipboard contents - Ctrl+D, for example)

- Editor: Move line up/down via keyboard (e.g. Alt+Up, Alt+Dn or Ctrl+Up etc)

- Tabbed Interface: allow drag tabs to reorganize tab positions when multiple scripts open

td

 You can already colorize UDPs using the right-click context menu. You can add many of the features you mention yourself by editing WSP-USER.MNU file located in the WinBatch System directory.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

cssyphus

Thanks Tony. I've already used the wsp-user.mnu to add those (and other even more useful) additions. Love that capability for creating intelligent editor macros. However, for editor features like move line up/down, it is dreadfully slow. For example, it is not workable to move a line up 5 lines - each (Ctrl+J, in my case) takes a full second to complete on my (not slow - P7 2.8Ghz 32Gig 2TbSSD) machine.

Re the colorization of UDF/UDS function names in the code - and I appreciate that my usage of the product might not be typical - but in this current script I have 43 UDFs and 18 UDSs. My most-used script has over 120 UDF/UDS combined. The right-click, colorize-one-UDF-at-a-time would not be feasible. (Besides, that R-Click was useful in the days before the toolbar UDF dropdown - it helped to quickly identify the UDF in a sea of UDFs - but it's not really required now)

I only wish for the name of the UDF within the code colorized, not the actual #DEFINEFUNCTION udfMyNameOfMyFunction(param1, param2) def.  BUT... it would be great to then double-click on the name of a UDF in the code and jump down to the function...

I know I am asking too much... but there's an ancient saying, "you have not because you ask not" - so I'm askin'. No offense intended at all, I love the product.

For casual WinBatch users it's no big deal, but for serious users... it is like Jim commented in a different thread about the Display(-1) taking a full second from the program flow. Coincidentally, I also made that request many, many years ago (during DF's time) - Display(x, "title", "message") would be much enhanced by allowing fractional increments, like TimeDelay(0.25) allows.

Please, all I am asking is that you add these to your "If I can someday" list...

kdmoyers

This sounds very cool but pretty difficult.  Perhaps the color tables could be updated only when the user clicks the function navigator dropdown, or on file load.

Even then, the underlying editor may not support changing horses in the middle of the stream.

The mind is everything; What you think, you become.

td

Quote from: cssyphus on May 19, 2024, 07:41:42 AMRe the colorization of UDF/UDS function names in the code - and I appreciate that my usage of the product might not be typical - but in this current script I have 43 UDFs and 18 UDSs. My most-used script has over 120 UDF/UDS combined. The right-click, colorize-one-UDF-at-a-time would not be feasible. (Besides, that R-Click was useful in the days before the toolbar UDF dropdown - it helped to quickly identify the UDF in a sea of UDFs - but it's not really required now)

If you colorize as you write, you don't need to colorize them all at once. It is just a question of developing the habit.
To make up for past iniquities you could write a script to parse UDPs from the input script and add the name to UDP file in the system directory.

QuoteI only wish for the name of the UDF within the code colorized, not the actual #DEFINEFUNCTION udfMyNameOfMyFunction(param1, param2) def.  BUT... it would be great to then double-click on the name of a UDF in the code and jump down to the function...

The built-in context menu UDP colorization menu item only colorized the names of UDPs within the script. Nothing more.

I use the "Find All" context menu item to be a better choice for moving between USP definitions and usage points in a script. I can look at a definition and return to the calling point because all the lines of usage are displayed in the Fined window at the bottom of the edit window.

 But to each their own.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

<<To make up for past iniquities you could write a script to parse UDPs from the input script and add the name to UDP file in the system directory.>>
This sounds like a great idea to me!  what is that file name?...

...Oh I get it -- add the UDF name to the WIL.CLR file.
MyFuncName=UDF

Yeah, why didn't I think of that?  Thanks Tony!
The mind is everything; What you think, you become.

kdmoyers

Follow up question Tony: how often does Studio look at the wil.clr file?  is it when the whole Studio program starts? or when a new .wbt file is opened? or something else?
Thanks!
The mind is everything; What you think, you become.

td

Two .CLR files are used for WIL file syntax coloring. The files are "WIL.CLR" and "WIL.CLUSER". The "WIL.CLUSER" file stores UDP names so that they are preserved between WinBatch versions. Here is a copy of the code for the "Colorize UDF Function" menu option. from your wspopum.mnu file.

helpword = wGetWord()              ; Get Selected word.

    If helpword==""
         wLeft()                       ; End of word? Try one position to the left.
         helpword = wGetWord()         ; Select possible word & reset cursor.
         wRight()                      ; Saves time-wasting manual cursor manipulation.
    EndIf                              ; Helpword=="".

    If helpword==""
         Message("No UDF/UDS Found","Must hilight a UDF/UDS function name to colorize it.")
         Exit
    EndIf                              ; Helpword=="".

    ;Does color already exist?
    wilclr=StrCat(DirHome(),"WIL.CLR")
    wilclruser=StrCat(DirHome(),"WIL.CLUSER")
    a=IniReadPvt("COLORS","UDF","XXX",wilclr)
    If a=="XXX"
         IniWritePvt("COLORS","UDF","0,128,255",wilclr)
         IniWritePvt("COLORS","UDF","0,128,255",wilclruser)
    EndIf                              ; A=="XXX".
    a=IniReadPvt("KEYWORDS",helpword,"XYZZY123XXYZ",wilclr)
    If a !="XYZZY123XXYZ"
         Message(helpword,"Already colorized")
         Exit
    EndIf                              ; A !="XYZZY123XXYZ".
    IniWritePvt("KEYWORDS",helpword,"UDF",wilclr)
    IniWritePvt("KEYWORDS",helpword,"UDF",wilclruser)
    synctime=TimeYMDHMS()
    IniWritePvt("SYNC","Time",synctime,wilclr)
    IniWritePvt("SYNC","Time",synctime,wilclruser)

WBS builds a hash table of syntax keywords mapped to colors. The process of checking for colorization changes happens often. Although, in most cases, nothing has changed so no processing is necessary.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

cssyphus

This is gold, thanks gents.

I notice that defs in WIL.clr take precedence over identically-named defs in WIL.clusr. Shouldn't it work the other way around? Also, when I manually add defs to WIL.clusr they do not work, but if I add them to WIL.clr they do (I used Save-All-Files *AND* Exit/Restart WB when testing). 

When I use the R-Click popmenu choice to colorize UDFs, it adds the def to both files (which would make it difficult to realize that the WIL.clusr file is not working).

For example:
WIL.clr
[KEYWORDS]
udfMyCoolFunction=UDF
udfAnotherCoolOne=UDF

WIL.clusr
[KEYWORDS]
udfMyCoolFunction=UDF
udfMyDifferentFunc=UDF

udfMyCoolFunction and udfAnotherCoolOne will be colorized, but not udfMyDifferentFunc.

The same is true of color definitions:
[COLORS]
UDF=255,128,191
The above will only work if in WIL.clr, not in WIL.clusr - even if there is no UDF=R,G,B def in the WIL.clr file at all...

After writing this out, I realize that probably there is just a bug with the WIL.clusr file not working at the moment.
( Testing with version 2024A )

td

As mentioned the purpose of the WIL.CLUSER file is to preserve the UDP coloration between WBS versions and nothing more. For that to work, you need to set the timestamp in both files as the wspopmenu.mnu code does.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

This is all super Tony, especially with the code.  Clever use of the timestamp. 
Thanks for this, I have ideas....
-K
The mind is everything; What you think, you become.