viewpoint-particle

Author Topic: Anyone Know a Good VSCode Colorizer for WinBatch  (Read 519 times)

NoelC

  • Newbie
  • *
  • Posts: 3
Anyone Know a Good VSCode Colorizer for WinBatch
« on: February 10, 2019, 08:19:53 am »
What's a good way to see WinBatch sources in VSCode with colorizing? 

Assigning it C language colorizing seems to get some of the way there, but semicolons trip it up.

Can we maybe use a C++ single line comment style in WinBatch?

There's probably a combo of tricks that gets one close.  I'm interested to hear what you've come up with.

-Noel

td

  • Tech Support
  • *****
  • Posts: 3073
    • WinBatch
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #1 on: February 10, 2019, 08:41:13 am »
Why not just use WinBatch Studio?
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

NoelC

  • Newbie
  • *
  • Posts: 3
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #2 on: February 10, 2019, 09:43:00 am »
Personal preference, mostly.  You tend to get used to the way an editor works when you use it for many hours a day and you look for ways to integrate the other things you do into it.

-Noel

JTaylor

  • Pundit
  • *****
  • Posts: 1030
    • Data & Stuff Inc.
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #3 on: February 10, 2019, 10:32:07 am »
Assuming I understand the question...maybe this will help???

    https://css-tricks.com/creating-a-vs-code-theme/

Jim

NoelC

  • Newbie
  • *
  • Posts: 3
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #4 on: February 14, 2019, 06:47:01 am »
Not really; I have a decent theme (i.e., dark background, code elements colored in certain ways, etc.), but I was curious whether anyone had come up with something that understands the wbt syntax - e.g., so comments, keywords, etc. are colored the way the user's theme sets them.

-Noel

td

  • Tech Support
  • *****
  • Posts: 3073
    • WinBatch
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #5 on: February 14, 2019, 08:17:12 am »
You could always role-your-own if it is important enough to you.  Not sure how much interest there is but maybe start a Github project to get contributions from others.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

  • Pundit
  • *****
  • Posts: 1030
    • Data & Stuff Inc.
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #6 on: February 14, 2019, 10:57:18 am »
Okay.   I thought what I posted showed you, as part of the theme, how to set the colorization for the text.    Just figured if you started with the C++ theme you are using you could tweak it to do what you wanted.   Must have misunderstood.  Sorry.

Jim

cssyphus

  • Newbie
  • *
  • Posts: 28
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #7 on: September 30, 2019, 10:46:01 am »
I am about to start down this road myself. As of this date, has anyone else been here before me, perhaps gotten a start on the job? I am interested in both VSCode and Notepad++ language files for WinBatch. If anyone's gotten started on the job, I am happy to assist with populating commands/functions/operators/etc.

Although WB has a great IDE, sometimes the additional features of the two most popular freeware editors are indispensable and impressively useful. For example, off the top of my head:

Reasons to use WB IDE over any other:
- context-sensitive help (Shift-F1), F12, hover-over-keyword
- run-in-debug-mode (step-through code)

Reasons to use VSCode over the WB IDE:
- split editor window (so can see different sections of the same script in two editor windows)
- diff/compare --- compare two versions of a script in side-by-side windows and show additions/subtractions
- multi-cursor editing (edit multiple lines at same time - for example, to tweak a varname or add same comment)
- intellisense (code completion, parameter info)
- code folding (shrink-up sections of your code)
- many useful keyboard shortcuts: duplicate line, comment-out selected lines, etc

For me, these are important reasons since my primary scripts are > 5K lines, sans comments.

Note that IDE/Editor choice is not either/or.  I'll often have the same script open in both editors. When make a change in one and save the file, the other editor thoughtfully alerts that the file has changed outside itself and asks if I'd like to open the new version. (Of course, disaster ensues if you say No and then save the old version's file... which is why I also have another script running that backs up my source code every 5 mins...)

td

  • Tech Support
  • *****
  • Posts: 3073
    • WinBatch
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #8 on: September 30, 2019, 11:05:31 am »
WinBatch Studio has split window functionality to allow you to view different locations in the same script.  It also has  "IntelliSense" like functionality.  It can complete WIL and extender function names, display the parameters above the WIL and extender function name when you type an opening parenthesis after the function name.  It can also write the parameter list into your script for you by pressing f12 when the cursor is over a WIL function name.

There also a way to implement most of the quick-help stuff above for user-defined-functions and subroutines but it is a bit of a hack.

You can also use the context menu to insert WIL and extender functions into scripts.  You can find the entire list of functions under the "Insert Block" item of "Code Block" context menu.  This functionality has been superseded by the quick-help functionality but it remains for those that prefer the context menu.

Most of the rest of your list could be implemented using the user-modifiable context menu. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

cssyphus

  • Newbie
  • *
  • Posts: 28
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #9 on: October 01, 2019, 02:11:15 pm »
Ah ha!  I had totally forgotten about the split screen functionality. That will come in tellement helpful !  Thanks for that.

In the WB IDE, what is the essence of how to create for e.g. a {Ctrl}{d} keyboard shortcut to duplicate the current line (below) ?

Many thx Tony

td

  • Tech Support
  • *****
  • Posts: 3073
    • WinBatch
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #10 on: October 01, 2019, 02:33:05 pm »
First, I need to correct a statement I made above.  WIL functions can be inserted into a script form the context menu by using the appropriately named "Insert WIL Function..." item and not the "Code Blocks" menu item.  The latter has options for inserting dialog callbacks, structure blocks, and comment or uncommenting blocks of code.

The WBS WSP-USER.MNU file can be found in the WinBatch "System" directory.  The file is a standard WIL menu file that allows the user to modify the context menu in such a way that the changes will be preserved between installations of new versions of WinBatch.

Since it is a menu file, you can add hotkeys.  See the following in the Consolidated WIL Help file for more on menu hotkeys: Home->Windows Interface Language Reference->Menu Files->Menu Hotkeys.

To implement your copy and paste functionality you will need to use WinBatch Studio functions below your menu item in the menu file. You can find all of the WBS functions in, you guessed it, the Consolidated WIL Help file at  Home->WinBatch Studio->Commands. The wCopyLine function's example should be informative.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

jkavanagh58

  • Newbie
  • *
  • Posts: 1
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #11 on: October 30, 2019, 07:06:56 am »
What's a good way to see WinBatch sources in VSCode with colorizing? 

Assigning it C language colorizing seems to get some of the way there, but semicolons trip it up.

Can we maybe use a C++ single line comment style in WinBatch?

There's probably a combo of tricks that gets one close.  I'm interested to hear what you've come up with.

-Noel
Any answer to this? I get the loyalty to the WinBatch IDE but to ignore VSCode is short sighted. I would like to open WinBatch in something other than PlainText or Shell Script mode... why VSCode without bashing the OEM IDE... because I can stay in the same IDE for other languages like HTML, Python, YAML, PowerShell - all of the languages we need to be using these days.

td

  • Tech Support
  • *****
  • Posts: 3073
    • WinBatch
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #12 on: October 30, 2019, 08:31:09 am »
Not sure who you think is being short sited but if using only one IDE is so important to you, you can always create your own VSCode WIL theme for WIL syntax coloring and share it with others of like mind on this forum.  The Extension API seems to be well documented.

Of course, for many more advanced users, the most important part of any development environment (integrated or not) is a debugger.   In the case of Winbatch, integrating a debugger would likely require advanced programming knowledge and be a time-consuming process.   Not to mention dealing with some knotty licensing issues.     

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

td

  • Tech Support
  • *****
  • Posts: 3073
    • WinBatch
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #13 on: October 30, 2019, 09:43:23 am »
Not recommending it but if some form of syntax coloring, running, building, and a single IDE are the only criteria, WinBatch Studio could be configured to support just about any language. Admittedly the syntax coloring would be limited to the language elements listed in the Syntax Coloring dialog but it would require little or no programming and it would then be your one IDE.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

cssyphus

  • Newbie
  • *
  • Posts: 28
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #14 on: November 04, 2019, 11:57:36 am »
Reasons to use a secondary IDE: code folding (by itself worth the justification), multiple cursors, familiar keyboard shortcuts, just a different "look"

These days, switching between IDEs is a bit like skins on a favorite media player (at least for me). For the same python or node code base, I will switch between working in VSCode and Notepad++, depending on what I am doing. 

I have cobbled together a basic language pack for NPP, but it doesn't correctly handle single-line IF... THEN... statements, which messes up NPP's code folding. I intend to write another script that parses my current WBT files and converts all single-line IF---THENs into IF--ENDIF blocks. That should fix the code folding. Haven't done it yet.

Code: [Select]
Example:
This wrecks NPP code folding:
if bob > 10 then message("Hello", "Hi Bob")

This works with NPP code folding:
if bob > 10
     message("Hello", "Hi Bob")
endif

VSCode's language extension API is frankly beyond me. (Not all golfers can wear the gold jacket.) When working on WinBatch code in NPP, I do what I can in NPP and then switch back into WBS for its amazing debugger. Then again, my core WBT scripts are too advanced for the F11 runtime debugger and I use debugTrace - in which case, I don't need to use WBStudio. I work in NPP, run the script, read the debugTrace file, and tweak s'more in NPP.

Would *love* to have a WIL language extension for VSCode !  At the moment, I spend 90% of my coding life there -- so would see great value in remaining within VSCode's very familiar environment to work on WBT scripts also. NOT as a replacement, but as a "skin".  (It would take the load off the WinBatch programmers also: is it easier to create a VSCode extension, or to write code-folding/multi-cursors into WBS?)

---

I've attached my (work-in-progress) NPP user-defined-lang file. It is incomplete, but has most of the keywords. Consider it a good start, not a fait-a-complis. And caveat emptor re the code folding.

td

  • Tech Support
  • *****
  • Posts: 3073
    • WinBatch
Re: Anyone Know a Good VSCode Colorizer for WinBatch
« Reply #15 on: November 04, 2019, 02:08:36 pm »
Reasons to use a secondary IDE: code folding (by itself worth the justification), multiple cursors, familiar keyboard shortcuts, just a different "look"

Need is in the eye of the beholder. For some the need to use "code folding" is a sure sign of poorly written code.

Quote
 

Would *love* to have a WIL language extension for VSCode !  At the moment, I spend 90% of my coding life there -- so would see great value in remaining within VSCode's very familiar environment to work on WBT scripts also. NOT as a replacement, but as a "skin".  (It would take the load off the WinBatch programmers also: is it easier to create a VSCode extension, or to write code-folding/multi-cursors into WBS?)


If I understand correctly, VScode's API is just javascript.  It can't be all that hard for someone with familiarity with multiple programming languages.   If all you want is syntax coloring, I don't think you even have to deal with the API.  Based on the comments in previous posts in this thread, syntax coloring only requires adapting an existing theme. 

The syntax coloring used for WIL scripts on this forum is provided by a WinBatch user with some knowledge of PHP.  The example script context coloring used in the Consolidated WIL Help file and on the Tech Database is provided by a WinBatch script written by a WinBath user with some knowledge of HTML.  There are many more examples of work contributed by WinBatch users to the benefit of the WinBatch user community. 

FWIW, I can't say that I have ever encountered a script that is "too complex" for the WIL debugger.  The only limitation is speed. It takes about twice as long to run a script in the debugger.  That problem can be often be eliminated with good testing practices like unit testing.   
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade