INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Syntax Highlighting for JRiver Expression Language  (Read 4308 times)

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Syntax Highlighting for JRiver Expression Language
« on: May 01, 2020, 06:24:38 pm »

The MC Expression Language has lots of parenthesis, brackets, and other punctuation, so sometimes it's nice to have a little help in keeping things straight.

So following up on my previous release...  I'm pleased to announce the availability of
Version 2 of the Syntax Highlighter for JRiver Expression Language!

This new version represents a whole new approach compared to version 1, and is a dramatic improvement in all areas.

It lets you transform your Expression Language editing experience...




Major Features and Enhancements
  • Draws a box around the currently selected expression, making it easy for you to see where it begins and ends.
  • All Functions and Database fields are highlighted. Database field names are validated and colored based on if they are recognized/spelled correctly.
  • Database fields are highlighted correctly even when inside expressions or directly adjacent to other text.
  • Database fields are highlighted correctly even when used with optional modes.
  • HTML tags are colorized
  • Variable names are colorized when prefixed with v_
  • Escaped delimiters are respected
  • Quoted strings and numeric constants are highlighted

Requirements
The Syntax Highlighting is an add-in for the Notepad++ Editor, also known as NPP. If you have not used NPP, you should.  It's an excellent, free, highly configurable, and very powerful text editor.  You can read more about it and download it here:  https://notepad-plus-plus.org/

In order to enable the advanced features in this new version, the Syntax Highlighting leverages the open-source PythonScript plugin for NPP.  Python allows me to override and work around the limitations in the built-in NPP lexer, so a lot of the functionality of this version is through Python code. This allows me to use Regular Expressions to identify and colorize text, to draw the animated outline box, and to do more sophisticated delimiter parsing than NPP is capable of. Installation instructions for the PythonScript plugin are included in the archive.

Both components can be installed in a lightweight, portable manner without making registry modifications or changing and system defaults.
---------------

A Note on Colors:
I come from the old school, where editors should display text (preferably green) on a black background, like in the good old days.  If you grew up in the age of Microsoft Word and black-on-white text, you just feel free to change all the colors however you like.  This can be done through the various "Styler" buttons in the Define Your Language dialog in NPP.  NPP also has a Style Configuration dialog on the Settings menu where you can configure default colors.  Learning how to use NPP I leave as an exercise for the reader. If you want to change the color of database fields or HTML tags, you would have to edit the Python code.

To see the colors to best effect, the easier but not as good way is to use the "Black board" theme from Settings->Style Configurator.  But better is to go to Settings->Style Configurator and edit the default style: make the background color BLACK and the foreground color whatever you prefer (but real men prefer green).  You can also set your default font in this dialog. Your default font settings will be respected by the Syntax Highlighter, only colors are altered. You can obviously change other defaults in this dialog as well.



Full installation instructions are included in the archive. Just look at the README files.

Download link is below. Enjoy!

-Will

------------
13-May-2020: Release of version 2.0
13-May-2020: Quick patch to v2.1; only necessary to replace JRiverUDLEnhancer.py
22-May-2020: v2.2 bug fix to prevent Boxer from improperly activating. Only necessary to replace BracketBoxes.py
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Syntax Highlighting for JRiver Expression Language
« Reply #1 on: May 01, 2020, 07:13:24 pm »

Thanks Will. Much appreciated.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Syntax Highlighting for JRiver Expression Language
« Reply #2 on: May 01, 2020, 07:37:15 pm »

Oooo, Green on Black was a bit harsh for me. I switched to Black on White.  ;D

Under the "Keywords List" tab there are eight groups of items, of which you have used four. At first look it seemed there was logic to which group a Keyword was in, but then I saw the logic break down.

Is there some logic to the grouping?

It should affect functionality I suspect, but having a consistent convention might help in understanding. Maybe it is just my limited understanding of the details in the User Defined Language functionality.

PS: Just feedback. Glynor and I never did this despite having it on out To-Do list, so Kudos to you!
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

greynolds

  • Citizen of the Universe
  • *****
  • Posts: 558
Re: Syntax Highlighting for JRiver Expression Language
« Reply #3 on: May 01, 2020, 07:53:42 pm »

Green on black is my kind of color combo, so perfect! :)
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #4 on: May 01, 2020, 07:57:53 pm »

Quote
I switched to Black on White.
Weakling!   :P

There's not much logic.  There should be, but there's not. Some I inherited and I put a bunch of user defined fields in a separate group.

The only functionality it affects is the highlighting.  You can set the highlight effects separately for each group.  By putting things in groups according to categories, you can have different highlighting per function, as I mentioned before.  If they're all in the same group they'll all look the same.

I started to regroup them but then didn't, as it's a lot of work in the editor to go back and re-do.

It's easy go go overboard on the coloring.  Some of the things that make sense in an IDE like compiler directives, headers, comments, etc we don't have in the Expression language.  There's really only 4 things: keywords, fields/variables, punctuation/delimiters, and text. 

NPP uses strict patter matching for highlighting.  It's smart enough to recognize keywords and such, but it's not contextually aware, so it can't differentiate that a 1 is text over here, but a 1 is an operand over there because of how it's positioned.

I'm open to a standardized grouping if someone wants to propose one.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #5 on: May 01, 2020, 07:59:20 pm »

Green on black is my kind of color combo, so perfect! :)

That's right!  There's a real man for ya!   8)
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Syntax Highlighting for JRiver Expression Language
« Reply #6 on: May 01, 2020, 08:10:52 pm »

Actually my problem was mostly that the text was given the foreground and black background, but the background around the text remained white. That is probably a Notepad++ setting somewhere and not part of the Language definition.

So it looked like the attached image. Harsh!
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Syntax Highlighting for JRiver Expression Language
« Reply #7 on: May 01, 2020, 08:15:12 pm »

Much better with a black background.   ;D

Top Menu > Settings > Style Configurator > Select theme > Black Board

Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

MikeO3

  • World Citizen
  • ***
  • Posts: 101
Re: Syntax Highlighting for JRiver Expression Language
« Reply #8 on: May 01, 2020, 08:37:44 pm »

Thanks for this! NPP has been my default editor for years because of all the syntax highlighters. I'll stick with your colours for now because I am old green screen material as well and need to reminisce to VT100 and VT220 days! :)

Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #9 on: May 01, 2020, 08:43:55 pm »

Much better with a black background.   ;D

I don't mess with themes much, so I can't say for sure how that will interact.

However, in that same dialog where you found the themes, you'll see that you can do global overrides for colors and fonts.  Those are supposed to supersede language definitions.    In that same dialog you can also modify colors individually for all the different styles and built-in languages.

There are a lot of controls, but you can run into the issue where you're wondering "Hmm, now THIS color is set exactly where?"  There's definitely more than one place...

Good luck!
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Syntax Highlighting for JRiver Expression Language
« Reply #10 on: May 01, 2020, 10:38:39 pm »

Unfortunately there doesn't seem to be a way to define a Theme for a User Defined Language, so I can't automatically use a black background for the JRiver Expression Language and white as the Global Default background for text files I edit. It is strange that the Langauge "Default Style" Styler Background Colour doesn't apply to the whole background, rather than just the font background. I might need to dig deeper.

Also Will, you need to add "( " to the "Folding Code 1 Style" so that unrecognised functions such as "Sign" in my example above don't muck up the bracket open/close matching Notepad++ does.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #11 on: May 01, 2020, 10:51:36 pm »

Also Will, you need to add "( " to the "Folding Code 1 Style" so that unrecognised functions such as "Sign" in my example above don't muck up the bracket open/close matching Notepad++ does.

Hmm, I'll take a look.  I don't use the folding with MC so that hasn't been tested at all.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #12 on: May 01, 2020, 11:12:45 pm »

That wasn't in the original language definition.  Remember the Expression Language doesn't use parens consistently.  Sometimes they are just meaningless text, like in Album Artist (auto)

I'm concerned there could be ramifications with things like that...

Besides, unrecognized functions should be added, not ignored.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Syntax Highlighting for JRiver Expression Language
« Reply #13 on: May 01, 2020, 11:19:05 pm »

Besides, unrecognized functions should be added, not ignored.

True, but a spelling error for a function could send someone down a rabbit hole chasing bracket matching, which has been the biggest issue I have with expressions, when they should be noting the function isn't recognised.

Up to you, but I found it worked fine in the stolen piece of code used in my example above, which includes field names with brackets in them. i.e. [Volume Level (R128)]
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #14 on: May 02, 2020, 02:37:09 am »

I've uploaded a new language file. See the download link in the original post.

I found a lot of functions I missed, so I might actually have them all now.  Also I improved the syntax highlighting to better handle quoted text and html tags.

To update your language file in NPP:
1. Select Language->Define your language
2. Select the "JRiver Media Center 2020" from the User Language drop-down at the top of the dialog.
3. Click Remove, then Yes to "Are you sure?"
4. Import the new definition file by clicking the Import button.
5. Exit and restart NPP.  That's it.

If you've customized language colors, you'll have to redo that after importing the new language file.
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72439
  • Where did I put my teeth?
Re: Syntax Highlighting for JRiver Expression Language
« Reply #15 on: May 02, 2020, 07:25:18 am »

Thank you!
Logged

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3119
Re: Syntax Highlighting for JRiver Expression Language
« Reply #16 on: May 02, 2020, 08:37:05 am »

Thanks for this! NPP has been my default editor for years because of all the syntax highlighters. I'll stick with your colours for now because I am old green screen material as well and need to reminisce to VT100 and VT220 days! :)

The VT100 was such a huge improvement over the VT52 !
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Syntax Highlighting for JRiver Expression Language
« Reply #17 on: May 02, 2020, 06:36:16 pm »

The VT100 was such a huge improvement over the VT52 !

Oh goodness. That reminds me of using VT100's and a VT100 emulator on a Novell network. Sooo long ago.

Yes, I do remember the improved functionality the VT100 gave us. Wow.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3119
Re: Syntax Highlighting for JRiver Expression Language
« Reply #18 on: May 02, 2020, 06:58:47 pm »

I did my first graphics programming for a Tectronix 4006/4010, but went over to the DEC VK100, aka Gigi, with ReGIS graphics when it was introduced. So much of what we take for granted today was just being introduced in those days.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Syntax Highlighting for JRiver Expression Language
« Reply #19 on: May 03, 2020, 12:59:33 pm »

Thanks wer, I've been trying to be up to date with my npp-template but this one is better. (I did change that screaming red though)
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Syntax Highlighting for JRiver Expression Language
« Reply #20 on: May 03, 2020, 01:45:25 pm »

Thank you for this Wer!
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #21 on: May 04, 2020, 03:45:31 am »

I'm glad you guys like it.

I wasn't totally happy with it. In my view it wasn't working as well as I'd like... There are just too many limitations with the UDL lexer in Notepad++ to deal with a language with syntax as "loose" as this.

So I'm actually working on a whole new version of this.  I've abandoned everything 221bBS did and I'm taking a whole new approach.  It will do a lot more, be much more accurate, and be way cooler.  8)

Stay tuned...

-Will
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #22 on: May 06, 2020, 08:49:16 pm »

I've learned that NPP has had an acknowledged but ignored bug for over a year that corrupts font properties when you import a UDL (User Defined Language) XML file.

Since they can't be bothered to fix it, instead of using the import function, it is preferable to put the language file in NPP's "userDefineLangs" folder.  That folder is located in AppData\Roaming\Notepad++ (if you used the installer) or as a subdirectory of the folder holding the Notepad++.exe file if you're using the portable version.

https://community.notepad-plus-plus.org/topic/17698/user-defined-language-font-settings-are-not-imported-correctly-anymore/3
https://github.com/notepad-plus-plus/notepad-plus-plus/issues/5630
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Syntax Highlighting for JRiver Expression Language
« Reply #23 on: May 06, 2020, 09:47:48 pm »

I noted that when I looked at the changelog while upgrading the other day, then forgot.

I am now using the recommended method, although I haven't noticed any differences yet.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #24 on: May 13, 2020, 03:29:37 am »

Hi everybody...   I just released version 2, and updated the top post.

I put a lot of work into improving it and making it really useful and helpful.  It's a huge advance over what existed before.

The colorizing and parsing is much better and more accurate, and I've implemented an expression boxer, that draws a box around the expression your cursor is currently in.  It makes it super easy to see where the expression starts and ends.  HTML tags are fully supported now, and there are many other improvements.

Give it a try, I think you'll like it.

-Will
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Syntax Highlighting for JRiver Expression Language
« Reply #25 on: May 13, 2020, 09:28:54 am »

Got it working. Only problem what I have found with coloring is the Compare function which can have < or > operators.
Thanks Will!
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #26 on: May 13, 2020, 12:26:54 pm »

That was tested. Can you provide a screenshot and code sample?
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Syntax Highlighting for JRiver Expression Language
« Reply #27 on: May 13, 2020, 12:36:53 pm »

That was tested. Can you provide a screenshot and code sample?
This is some cleaning helper in which the RemoveRight get determined as user field? Ah is it actually that "[" which is breaking highlighting... Don't review the expression. Don't remember whether it works or not ;D

=If(Compare(ListCount([Comment],/[),>,1),RemoveRight(ListItem([Comment],Math(ListCount([Comment],[)-1),/[),1),)
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #28 on: May 13, 2020, 12:50:39 pm »

It has nothing to do with the > which is detected correctly. It's the [

I wasn't anticipating anyone using [ in such a way.

The issue is that the / character, like many others, is overloaded.  In addition to an escape, it's also a mathematical operator.  So if I made allowances for what you're doing, it would affect things like:
Math([field1]/[field2])
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Syntax Highlighting for JRiver Expression Language
« Reply #29 on: May 13, 2020, 12:53:53 pm »

It has nothing to do with the > which is detected correctly. It's the [

I wasn't anticipating anyone using [ in such a way.

The issue is that the / character, like many others, is overloaded.  In addition to an escape, it's also a mathematical operator.  So if I made allowances for what you're doing, it would affect things like:
Math([field1]/[field2])
I think I was cleaning something like "Song Name [Bonus track]" so comment field would only have "Bonus track" afterwards.
No big deal for me
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #30 on: May 13, 2020, 01:14:00 pm »

I could implement a partial fix for this, but your expression would still have problems because it contains another unescaped [ in the last Listcount expression. I'm guessing that was a typo?
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #31 on: May 13, 2020, 01:52:13 pm »

I've updated this to v2.1. You just need to grab the JRiverUDLEnhancer.py file from the archive.

Unrecognized or misspelled field names immediately following a / will no longer be colored grey; they will be left green.  In the Math() function, this limitation can be avoided by surrounding your / operator with spaces.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Syntax Highlighting for JRiver Expression Language
« Reply #32 on: May 13, 2020, 01:53:52 pm »

I could implement a partial fix for this, but your expression would still have problems because it contains another unescaped [ in the last Listcount expression. I'm guessing that was a typo?
Yes, should be typo I think. And that python scripts works also currently so not a biggie. "[]" are used probably mostly in album names to separate version so there could be some cases where user wants to find it and therefore use it in expression

Many thanks again for doing the highlighting improvement
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #33 on: May 13, 2020, 02:01:29 pm »

Many thanks again for doing the highlighting improvement

Well I was never really happy with the previous one. It was a bit crude, but those were the limitations of the built-in UDL lexer.

How do you like the Boxer?
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Syntax Highlighting for JRiver Expression Language
« Reply #34 on: May 13, 2020, 02:14:52 pm »

Well I was ordered to enjoy my screens so hasn't been expressing myself lately ;D
...but I can see it could be useful for some long chains to visualize quickly what's what
Logged

MikeO3

  • World Citizen
  • ***
  • Posts: 101
Re: Syntax Highlighting for JRiver Expression Language
« Reply #35 on: May 13, 2020, 02:25:04 pm »

Thanks for the update. Looks good on some of the SmartLists I have open. Much easier to follow.

Quote from: wer
How do you like the Boxer?
Doesn't seem to be working for me on any of the 3 colour themes I have tried (Black Board, Deep Black and vim Blue). Which theme is best to validate your new 2.0? :)

Cursor is at the location red circled.


In the case of regex, the close but not the open is red. Is that by design?
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Syntax Highlighting for JRiver Expression Language
« Reply #36 on: May 13, 2020, 02:38:53 pm »

Boxer works fine for me using those themes. Did you set Python scripts to be executed at startup?

I suspect that regex function breaks because of escape character before end ) so that is a bug
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #37 on: May 13, 2020, 02:52:39 pm »

I know the Boxer works my friend, I meant do you like it?  :)

If you followed the instructions during the Pythonscript install, the scripts will run when NPP starts up.  This is necessary, because otherwise you would have to manually run each script every time you tried to use the MC language.

The scripts only take action when the MC language is used, however.

On startup, when the scripts run, they register with the NPP event handler.  This allows them to receive a trigger when the "Language" setting in NPP is changed.  The user might change the language manually through the menu, or the language could be auto-detected by NPP.

If the JRiver language is activated, the scripts run and perform their function.  If the JRiver language is not activated, they do nothing.  In this way, they do not interfere with normal NPP operation.

Using Python was necessary because NPP's built-in UDL lexer is incapable of dealing with the MC expression language properly.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #38 on: May 13, 2020, 03:00:32 pm »

Mike please post the text of the actual code as well. I can't copy/paste the code from screenshots.

I can tell you that the paren highlighting is handled directly by NPP, and that NPP can be confused in that regard when escaped delimiters are present.

You have an escaped delimiter: /)

If you don't allow escaped delimiters, some things will break.  If you DO allow escaped delimiters, other things will break. You're welcome to play with those settings in NPP's User Defined Language "Define your language" dialog and see the results for yourself.

You will have to appeal to the NPP developers to fix their paren matching when escaped delimiters are present.

If the Boxer is not working for you, you need to check if you have the correct language specified and if you followed the installation instructions accurately.

I suspect you're not using the correct language, because your field names in the top row are not highlighted.

Perhaps you have leftovers from the previous version. You should consider removing your existing UDL definitions and trying the installation again.
Logged

MikeO3

  • World Citizen
  • ***
  • Posts: 101
Re: Syntax Highlighting for JRiver Expression Language
« Reply #39 on: May 13, 2020, 03:13:51 pm »

Here are some setting snaps.



Without language

With language


Code snippets I was displaying. Please note these are just retypes of your sample and small file path cleanup.
Code: [Select]
FirstNotEmpty([GroupSet, 1],[Grouping, 1],[Album,1])
math(RemoveCharacters(GroupSummary(Rating), avg) * 2)

PadNumber([Track #], 2) [Name]
regex([filename (name)], /#^(\d+)-#/)

Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #40 on: May 13, 2020, 03:21:42 pm »

The screenshots have been resized so small they're illegible, even when downloading the original image from the link.

See my previous comments about using the wrong language.  Check your language menu to ensure you don't have the previous version in there.  The new one says v2.

Additionally, if you didn't overwrite the default startup.py as per the instructions, things won't work properly.

Finally, regarding your regex function, put a space before the closing ) on the expression. That will allow NPP to recognize it.
Logged

MikeO3

  • World Citizen
  • ***
  • Posts: 101
Re: Syntax Highlighting for JRiver Expression Language
« Reply #41 on: May 13, 2020, 03:34:20 pm »

Sorry about that... I reposted them larger.

Snip from the startup.py file to validate I have the right one:
Quote
#This line activates the enhancements to the JRiver Expression Language lexer
import JRiverUDLEnhancer

Here is the Language drop-down configming v2 is loaded.

Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #42 on: May 13, 2020, 04:01:56 pm »

Sorry about that... I reposted them larger.
Two of them are still illegible.  Is that you or does that service just resize everything you give it?  Kindly test the links after posting using that service.

Try running the BracketBoxes script manually using the Plugins->PythonScript menu/dialog on a file where you have the language activated. Does it work then?  If yes, it's not executing at startup: check your installation.  If it doesn't work even then, please start a new thread for the issue.  I don't want this thread to get further cluttered with so many posts and screenshots for a single issue.  Thanks.

Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Syntax Highlighting for JRiver Expression Language
« Reply #43 on: May 13, 2020, 04:38:04 pm »

I'm still on the Beta version, but that shows your code correctly Mike03, after I add a space before the last ).

We have to learn to use a little whitespace in some code so that the lexer can work correctly, because the MC Expression Language is just a bit loose in many ways. There are also some compromises with text and unknown field highlighting in certain situations, but it is about 1,000,000 better than then NPP only based Language lexer, and about a 1,000,000,000 times better than no MC Expression Language lexer at all.

Thanks Will !!!  I'll be using it from now on... must upgrade to the release version though.  ;D
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #44 on: May 15, 2020, 05:25:53 pm »

Thanks, I'm glad you like it.  Hopefully it will help people.

I have some ideas for further enhancements that would make another big improvement, but a little cooperation from JRiver would be helpful.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #45 on: May 22, 2020, 01:45:53 am »

I've posted version 2.2, which is a bug fix for the Boxer, which was sometimes activating when it shouldn't.

It's only necessary for you to replace your BracketBoxes.py file.

The top post has the new download...

Enjoy!
Logged

Doof

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5908
  • Farm Animal Stupid
Re: Syntax Highlighting for JRiver Expression Language
« Reply #46 on: May 22, 2020, 07:48:19 pm »

This has been a huge help. Thanks for putting this together. One tip I'm not sure was mentioned before, if you set an extension in the Ext field of the Language defined, you can save files with that extension and when you open them, Notepad++ will automatically apply this syntax to it. I used .jexp and now as soon as I save a file of that type it'll auto-apply the correct syntax.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Syntax Highlighting for JRiver Expression Language
« Reply #47 on: May 28, 2020, 12:21:43 am »

I'm glad you like it.  :)
Logged
Pages: [1]   Go Up