XYS syntax highlighting for Notepad++

Discuss and share scripts and script files...
Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

XYS syntax highlighting for Notepad++

Post by Filehero »

Hi,

I would like to share my definitions as well.

Notepad++ supports themes. As far as I understood they provide global color defaults as well as specific settings for the in-build supported languages. However, those settings appear to be somehow linked to the internal lexer (e.g., you can define keywords but no operators or delimiters). Fortunately there are User Defined Languages, which build upon any theme and offer great detail for customization. Attached you will find my current definition. I'm sure it can be tweaked/optimized much further, but it fits my needs so far quite well.

Downloads
NP++_XYS.zip
(13.9 KiB) Downloaded 501 times
Install
You should close any running Notepad++ instance before going ahead.

Unzip, and
1. Either put UserDefineLang.xml simply into the $Notepad++_home folder, or if you already have created some own language definitions just copy the XY section over into the existing UserDefineLang.xml.
Note: I left in two further definitions for Batch and Powershell files. Just remove or don't copy them if not needed.

2. Put the theme file myDark.xml into $Notepad++_home\themes

3. Start Notepad++ and load the theme via Settings>Style Configurator, make sure global override for background color is checked.
NP++_StyleConfigurator.png
NP++_StyleConfigurator.png (39.24 KiB) Viewed 7145 times
4. Now the "XYS"-entry should be available in the User section (below the separator) of the Language menu.


Expected Outcome
Notepad++.png
Notepad++.png (122.67 KiB) Viewed 7145 times
Enjoy!

Cheers,
Filehero

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: XYS syntax highlighting for Notepad++

Post by binocular222 »

Impressive :appl:
But you still need to highlight variables/Numeric inside quotes. That's the hard part
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: XYS syntax highlighting for Notepad++

Post by PeterH »

binocular222 wrote:Impressive :appl:
But you still need to highlight variables/Numeric inside quotes. That's the hard part
But variables only inside double quotes, I think :biggrin:
Inside single quotes they are just text :whistle:

No question: numbers are always numbers :ugeek:
W7(x64) SP1 German
( +WXP SP3 )

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: XYS syntax highlighting for Notepad++

Post by Filehero »

PeterH wrote:
binocular222 wrote:Impressive :appl:
But you still need to highlight variables/Numeric inside quotes. That's the hard part
But variables only inside double quotes, I think :biggrin:
Like this?
NP++_quoting.png
NP++_quoting.png (20.21 KiB) Viewed 7086 times
PeterH wrote:Inside single quotes they are just text :whistle:
Look at output of String_2. :wink:
At String_2 output the lexer seems to "fail" so far.


Cheers,
Filehero
Last edited by Filehero on 16 Jun 2013 15:47, edited 1 time in total.

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: XYS syntax highlighting for Notepad++

Post by klownboy »

Hi FileHero,
How are you? Doesn't your msg line have String_3 twice and no String_2 in the NP++_quoting.png capture?
Ken
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: XYS syntax highlighting for Notepad++

Post by Filehero »

Hi Ken,

I'm fine. Just came back from a 4 hour trekking tour, it was quite hot and sweaty. How are you?
klownboy wrote:Doesn't your msg line have String_3 twice and no String_2 in the NP++_quoting.png capture?
Ken
Bingo! You have become a real XY coder, haven't you? :appl:
I have updated the image. Thanks for the pointer. :D

Now off for a long shower.


Cheers,
Filehero

PeterH
Posts: 2776
Joined: 21 Nov 2005 20:39
Location: Germany

Re: XYS syntax highlighting for Notepad++

Post by PeterH »

Filehero wrote:
PeterH wrote:
binocular222 wrote:Impressive :appl:
But you still need to highlight variables/Numeric inside quotes. That's the hard part
But variables only inside double quotes, I think :biggrin:
Like this?
NP++_quoting.png
PeterH wrote:Inside single quotes they are just text :whistle:
Look at output of String_2. :wink:
At String_2 output the lexer seems to "fail" so far.


Cheers,
Filehero
It seems you changed something here, in between the time?
As on the left side the msg() shows $string_3 instead of $string_2, but the right side shows the corrected output for $string_2?

When the 1st $string_3 in msg() would be changed to _2, I think everything looks very correct; colors as well as values! Very good indeed! :appl: :appl: :appl:
W7(x64) SP1 German
( +WXP SP3 )

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: XYS syntax highlighting for Notepad++

Post by Filehero »

PeterH wrote:When the 1st $string_3 in msg() would be changed to _2, I think everything looks very correct; colors as well as values! Very good indeed! :appl: :appl: :appl:
Thanks for checking, I'm happy with it, too. :D

This was the code I actually ran for the popup shot (actually the highlighting example is from an existing file where I - lazy me - just put in the lines):

Code: Select all

  $VarSingleQuote = "SingleQuoted"; 
  $VarDoubleQuote = "DoubleQuoted"; 
  $String_1 = '$VarDoubleQuote\$VarSingleQuote 1 2 3 4 5';
  $String_2 = '$VarDoubleQuote\"$VarSingleQuote" 1 2 3 4 5'; 
  $String_3 = "$VarDoubleQuote\$VarSingleQuote 1 2 3 4 5";
  $String_4 = "$VarDoubleQuote\'$VarSingleQuote' 1 2 3 4 5";
  msg($String_1<br>$String_2<br>$String_3<br>$String_4);
So, no more number confusion. :oops:

And here's the updated UserDefineLang.xml:
userDefineLang.zip
(6.69 KiB) Downloaded 285 times
Cheers,
Filehero

mithrin
Posts: 15
Joined: 15 Jan 2012 01:56

Re: XYS syntax highlighting for Notepad++

Post by mithrin »

If anyone is interested this is my Syntax Highlighting files that I've been using for years. I see the interest, so I'm offering my files scrutiny.
Attachments
xys_LexerType.zip
1. userDefineLang XML
2. LexerType XML addin to stylers.xml
stylers.model.xml
(2.18 KiB) Downloaded 259 times

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: XYS syntax highlighting for Notepad++

Post by Enternal »

So, I took quite a bit of time to make another UDL theme for Notepad++ but make more use of the features that UDL 2.0 have to offer.

It supports XYplorer's variables (<curitems>), special items ({Fullname}), system and XYplorer's own system variables (%osbitness%), Xyplorer's variables within strings ("This is a $String"), and other things.

Still not the best I think but of an improvement. Hope you like it! I probably will work on it more later but for now, I think it's quite usable. Also, it works best with dark themes. In the example pictures, I'm using the Twilight theme.
2013-11-22_153945.png
2013-11-22_153945.png (26.46 KiB) Viewed 6725 times
2013-11-22_154051.png
2013-11-22_154051.png (37.4 KiB) Viewed 6725 times
Attachments
XYplorer UDL.zip
(1.6 KiB) Downloaded 259 times

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: XYS syntax highlighting for Notepad++

Post by Enternal »

Working on this for days and so far everything work except literal strings and heredoc. Literal strings generally work but when you start using words like "Don't" "Won't" "It's" and more, it will fail. Here doc can't be done at the moment due to limitations of the current lexer engine for NP++. Loreia2, the developer for the lexer enginer said the next major version should have even more support for complex scenarios.

Anyway, I extracted all those variables for <variable> and %variable% and {variable} from the help manual and then modified and finally implemented them into the user defined language file. I know my color choices suck but for the moment I'm still testing them to make sure if it works well enough. Can you guys test them and give me comments? Try to break it so that I can see if I can hopefully fix it.

As I said before, literal strings and heredoc don't work so I already know that's "broken" (removed them). Thank you!
Attachments
XYplorer_UDL_2nd_Test.zip
(1.77 KiB) Downloaded 283 times

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: XYS syntax highlighting for Notepad++

Post by Filehero »

Hi Enternal,

thanks for keeping this thread alive and your recent UDL theme. Don't know wether I like it better, but I will use it to check your "implementation". :wink:


Cheers,
Filehero

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: XYS syntax highlighting for Notepad++

Post by Enternal »

Haha you want to "steal" my implementation?! :lol: Anyway, what do you think of it so far? Working well for most cases? Also what do you think about this color choices:
Image 1.jpg
Image 1.jpg (278.52 KiB) Viewed 6607 times
EDIT: Uhh... I think that was a horrible joke I made. This UDL thing is already free to do whatever you want with it so the "steal" is bad taste of a joke. Sorry for that.
Last edited by Enternal on 27 Nov 2013 21:52, edited 2 times in total.

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: XYS syntax highlighting for Notepad++

Post by Filehero »

Enternal wrote:Haha you want to "steal" my implementation?! :lol:
No - it's about understanding "only".

Cheers,
Filehero

Enternal
Posts: 1174
Joined: 10 Jan 2012 18:26

Re: XYS syntax highlighting for Notepad++

Post by Enternal »

Filehero wrote:
Enternal wrote:Haha you want to "steal" my implementation?! :lol:
No - it's about understanding "only".

Cheers,
Filehero
Haha. I was hoping there would be more UDL around that is similar to the XYScripting language but not really. As a result, there's also a lot of trial and error. Also the documentation is a bit lacking since I did saw some really funky way of doing things with UDL which I don't think it was meant to support but it did work... or maybe it was supposed to do that... I don't know.

But were you able to break it with certain script?

Post Reply