Community
    • Login

    User Defined Language doesn't exclude sign in front of numbers

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 217 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.
    • Michael GoldsworthM
      Michael Goldsworth
      last edited by Michael Goldsworth

      I’m trying to finish a user defined language for OCL files, but the Operators 1 section that allows for numbers without spaces isn’t excluding the sign when directly in front of numbers. Is there a way around this?

      From the example you can see it works fine for <num><sign><num>, <num><sign><text>, and <text><sign><text>, but the style seems to assume + or - constitute a number sign for this specific whether it is wanted or not - and in this case it is never wanted.

      notepad++_ocl_signed_numbers.png

      These are customer files, so I don’t get to modify them. Is there a workaround for this that will provide what is needed? I tried to accomplish this with Keywords Lists, but it doesn’t seem to treat non-alpha text as valid, at least not in a way that seems to work here, so even when I remove all operators, it isn’t allowing me to use special cases like “)+”, etc.

      I haven’t done a lot of this before, so I could easily be missing something and it would be great to know.

      Thanks,
      Mickey

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

        @Michael-Goldsworth ,

        UDL has its limitations. + or - prefixing a number with no intervening space will always be treated as part of the number.

        If you add the EnhanceAnyLexer plugin using Plugins Admin, you can use that plugin to have a regular expression apply foreground coloring:

        0xFFFF00 = [+-](?=\d)
        ; for UDL, need to remove 3 from excluded styles if you want
        ; this new color to override the number styling
        excluded_styles = 1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,22,23
        

        I used cyan in my example (0xGGBBRR=0xFFFF00) to make it obvious:

        with EnhanceAnyLexer:
        9b1912d0-f936-49fa-90b3-0f5ef693657c-image.png

        without EnhanceAnyLexer (or with the definition commented out):
        d7d7e7a5-634b-492c-843a-dabdcc130da8-image.png

        The 24 style numbers are defined in the Notepad++ UDL source code (a similar link is present in the default EnhanceAnyLexerConfig.ini, if anyone reads the comments there…)

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