Community
    • Login

    Syntax highlight % and %% lines differently

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 4 Posters 339 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.
    • J
      jnbearon
      last edited by

      Hi
      I am creating a UDL using the GUI. I need to distinguish between lines starting with a single %, which marks a comment line, and those that start with %% which are quite different.
      How do I do that please?
      Thanks

      Mark OlsonM EkopalypseE 2 Replies Last reply Reply Quote 0
      • Mark OlsonM
        Mark Olson @jnbearon
        last edited by Mark Olson

        @jnbearon
        Off the top of my head, the best way to do this is probably to use EnhanceAnyLexer.

        ^%(?!%).*$ matches any line that begins with a single %
        ^%%.*$ matches any line that begins with %%

        1 Reply Last reply Reply Quote 2
        • EkopalypseE
          Ekopalypse @jnbearon
          last edited by

          @jnbearon

          In this case, you could use UDL’s own functionality by ensuring that you define two delimiters, with the %% defined first and both ending with the ((EOL)) marker.

          4c76f120-adb0-4093-a6d2-664eddafeede-image.png

          J 1 Reply Last reply Reply Quote 4
          • J
            jnbearon @Ekopalypse
            last edited by

            @Ekopalypse
            Thanks Ekopalypse, that method does work if both are defined in “Operators and Delimiters”. What does not seem to work is to have % set as the comment marker in “Comment and Number” and %% set in the “Operators and Delimiters”. If there are consecutive lines starting with %% then they get coloured in alternating colours - seems to be something to do with how the ((EOF)) is interpreted.

            I have a problem in that I am already short of Delimiter defs as the language definition form only allows 8 to be set. That then prompts 2 further questions:

            1. Can I define more than 8 delimiters - by editing the XML file?
            2. Can I assign more than 1 delimiter to a particular colour? (I would be quite happy to bundle a few of the less often used ones into a single colour, but have the more popular ones having their own specified coloured line.

            Thanks

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

              @jnbearon said in Syntax highlight % and %% lines differently:

              @Ekopalypse
              I have a problem in that I am already short of Delimiter defs as the language definition form only allows 8 to be set. That then prompts 2 further questions:

              1. Can I define more than 8 delimiters - by editing the XML file?

              No. The number of colors is compiled into the program, and cannot be changed by a config file.

              1. Can I assign more than 1 delimiter to a particular colour? (I would be quite happy to bundle a few of the less often used ones into a single colour, but have the more popular ones having their own specified coloured line.

              Yes. You can see an example of this in the “Markdown (preinstalled)” UDL that ships with Notepad++:

              080344fd-fb48-40e5-9ed4-c2a91c9deb6e-image.png

              Just put the space-separated list of open and the space-separated list of close in the same order

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