Community
    • Login

    User Defined Language: highlight up until colon

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 2 Posters 998 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sseeringS
      sseering
      last edited by sseering

      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)

      notepad_highlight.jpeg

      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?

      PeterJonesP 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @sseering
        last edited by

        @sseering ,

        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
        9d6501b0-0ee3-4521-8d7b-e1633dcedf69-image.png

        sseeringS 1 Reply Last reply Reply Quote 0
        • PeterJonesP
          PeterJones @sseering
          last edited by PeterJones

          @sseering ,

          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

          1. Set UDL > Folder & Default > Default Styler = black-on-cyan,
          2. Set Comment Line to ; and grey text
          3. 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)
          4. Operators & Delimiters > Delimeter #: open=:, close=((EOL)), Styler=black foreground on white background

          That will give the following, even without the EnhanceAnyLexer plugin:
          d7dfda64-cedb-4c34-bfaf-043cd0017111-image.png

          (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)

          sseeringS 1 Reply Last reply Reply Quote 0
          • sseeringS
            sseering @PeterJones
            last edited by

            @PeterJones

            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.

            1 Reply Last reply Reply Quote 0
            • sseeringS
              sseering @PeterJones
              last edited by

              @PeterJones

              Thank you. I’ll try this solution as well.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors