User Defined Language: highlight up until colon
-
Hi, I want to make a highlighter for a minor internal text file format used for text translations.
Notepad Version 8.4.2
Example:
TextAssetVersion:202 ; @ModuleChoiceScene ; Some comment viaLogin:(über Login) ;when you change button text and size, prove in program environment if text fits! Theme Choice Button:Themen-\nAuswahl Speech Setup Button:Sprach-\nausgabe Message Panel Buy Button:Weiter Message Panel Button Manager:Lizenz verwalten Voices Dropdown Label:Stimmen:
I want to highlight (change text or background colour or underline):
- comments starting with ; (easy, already figured out)
- text markers that go up to the first : (the hard part)
I read both the Notepad++ docs and the extra UDL docs but couldn’t find a solution.
Can anyone help me please? I tried to figure it out for about a day and couldn’t find a solution with the UDL Designer.
Even a works-in-80%-of-cases soultion would be good enough. I don’t need a perfect syntax definition for every edge case.
I think I have done this already in the past. However, I couldn’t figure it out this time. Maybe my old solution was before UDL 2.0?
-
I’m not sure how you ever would have done it. UDL 2.0 has been around for years at this point, so it would’ve had to be ancient (and I think earlier UDL had fewer features, not more). Maybe you just used YAML or something that already has recognition that would work similarly enough to that, I think.
The UDL has “prefix” mode for keywords, but not “suffix mode”.
I would suggest the Enhance Any Lexer plugin, but unfortunately that plugin only allows changing the foreground color, not the background color; if that’s sufficient – for example, you want to make the text foreground cyan instead – then if you have a UDL named TextAssert, and ran Plugins > Enhance Any Lexer > Enhance current language:
[TextAssert] 0xC0C000 = ^\h*\K[^:\r\n]+:
should do close to what you want
-
If you don’t have any “normal” text in your language – ie, everything is either a comment or one of the @-lines or a
name:value
pair, then- Set UDL > Folder & Default > Default Styler = black-on-cyan,
- Set Comment Line to
;
and grey text - Set @-prefixed as you did before (not sure whether you made it an alternate comment, or used keyword=
@
in prefix mode, or made a delimiter Open=@
Close=((EOL))
– all three would work) - Operators & Delimiters > Delimeter #: open=
:
, close=((EOL))
, Styler=black foreground on white background
That will give the following, even without the EnhanceAnyLexer plugin:
(My xxx on the final line shows why you wouldn’t want any “normal” text in this format if you are using this pure-UDL version)
-
Thank you very much, that will work for me.
I’m not sure how you ever would have done it. UDL 2.0 has been around for years at this point, so it would’ve had to be ancient (and I think earlier UDL had fewer features, not more). Maybe you just used YAML or something that already has recognition that would work similarly enough to that, I think.
You are propably correct. I just remember getting something like this to work in the past. But it was quite a while ago and likely a slightly different text format that was better suited to the UDL designer.
-
Thank you. I’ll try this solution as well.