How to setup UDL keyword style overwrites?
-
Hello
I am creating a UDL for a niche script, and trying to highlight ‘Parent’ as a keyword in such a way that it will only be highlighted if followed immediately by a ‘(’ , or following immediately after a '= ’ :DATA { type = CelestialBody targetBody1 = HomeWorld().Parent() } DATA { type = Parent }
but not when it’s on its own:
DATA { synopsis = Place a relay on a Parent celestial body. }
It doesn’t seem as though I can override it using another keywords group or with the Folding in Code/Comment styles.
Is there any way to do this? With delimiters perhaps? -
welcome to the notepad++ community, @Adam-Shipway
i won’t say impossible, but this one is gonna be tricky 😉
i’ve played around a bit using delimiters instead of keywords, as they were suggested by @Eko-palypse a couple of weeks ago, but in your case, i’m a bit stuck on a few things that might be ugly (as seen at the screenshot below):
-
i get
parent
to correctly highlight if succeeded by a ( or preceeded by a =, but only if there’s no space in between prefix/suffix and the wordparent
-
one thing that i couldn’t get fixed, is that the highlighting of
parent(void)
also highlights everything within the () brackets.
anyways, here’s the screenshot in hope that you can use any of those settings for some of your needs.
please keep us informed of any success you had, as well as any further problems you might encounter.
ps: @PeterJones “exhumed” this old but very good udl documentation for us, just in case you don’t have it yet:
https://ivan-radic.github.io/udl-documentation/comments/ -
-
Thanks for the effort to help. It’s disappointing that languages requiring spaces sometimes don’t work well with the UDL system.
I’m wondering if, since comments ignore spaces in their styling, they could be incorporated. I’m also wondering if nesting can be used to have anything inside the brackets be styled differently.
---- I did some messing around and I was able to get this result, where I believe the only problem is that the ‘=’ sign isn’t highlighted properly:
https://i.imgur.com/H5nGnZ2.jpg (Edit: look at that quality from the new Win10 Snip tool! Eugh!)Using these settings (which I’ve listed, as screenshots would take an excessive amount of room):
Keyword Group 1 (Blue, Prefix Off): Parent Random LAN
Comment style (Black, Not Line):
Open: =
Close: ((EOL))
Nesting: Delimiter 1, All KW Groups, Comment Line, All Operators, NumbersDelimiter 1 (Blue):
Open: Random( Parent( LAN(
Close: ) ((EOL)) ((EOL)) ((EOL))
Nesting: All KW Groups, Comment & Comment Line, All Operators, NumbersDelimiter 2 (Black):
Open: Random Parent LAN
Close: ((EOL)) ((EOL)) ((EOL))
Nesting: NumbersThe entire UDL .xml file as it is currently (I have only ported 3 keywords to use the setup as of now): https://www.dropbox.com/s/od8sku0wkpceh79/contractcfg.xml?dl=0
A file for use with the language (tests at bottom): https://www.dropbox.com/s/mi1caxm5hsnvg9q/wd_lKard.cfg?dl=0Any help with getting ‘=’ to highlight differently, as well as any ways to clean up my messy UDL setup, would be greatly appreciated.
-
Updated link for results in case the previous one fails or is unclear: https://i.imgur.com/DMPUBmH.png
-
@Adam-Shipway
nice work, thanks for exporting and sharing. 👍
Any help with getting ‘=’ to highlight differently, as well as any ways to clean up my messy UDL setup, would be greatly appreciated.
i’ve made one single modification that delivers following result with caveats:
changes:
i’ve removed the=
to((EOL))
of the nesting comment line and added=
to operators 1pro:
HomeWorld()
is highlighted correctly as keyword (before, with the nesting=
comment style, it was black)con: at
test = LAN
LAN does not get highlighted anymore due to the space. -
Thank you for the information :)
I added the rest of the keywords to the .xml and uploaded it (same link as before). This fixes HomeWorld() because it wasn’t part of the list before. They’re now separated into two delimiters (1&2, former 2 has now moved to 3) as one of the keyword groups I wanted to apply this to is a different colour. I also checked D2’s nesting in the comment style options to support this separation.
It did break highlighting for numbers inside brackets, but checking D1 and D2 nesting inside of D3’s options seems to fix it.
The ‘=’ situation is a little complicated however. I originally put it in the comment style as it would allow it to ignore any spaces after it, hence why when moved to Operators 1 it won’t highlight keywords after a ‘=’ anymore (such as the case you found with LAN). I guess this is personal preference, but I kept it in comments, even if the equal sign stays black.
-
I’ve realised that some of the { } brackets aren’t coloured properly anymore, but only after instances of DATA or PARAMETER, and for some reason // comments after instances of PARAMETER don’t highlight either. Well, this is perplexing.