Community
    • Login

    Style words depending the end character

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 336 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.
    • Txote LuscoT
      Txote Lusco
      last edited by

      Hi, I have a question about user defined language. I would like to mark Words from the end to the begining.
      For example anthing before “:” I would like to give an special style. (until the begining of line)
      e.x
      _END:

      I can define always in fordward direction, But I tried many times this…and never find the solution.

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

        @Txote-Lusco said in Style words depending the end character:

        But I tried many times this…and never find the solution.

        That’s because the User Defined Language (UDL) definition just has a simple set of rules that it can make use of, and fancy rules that you described are not possible with UDL alone.

        However, using the EnhanceAnyLexer plugin, you can add a regex-based rule in addition to the normal UDL-based highlighting:

        1. Install EnhanceAnyLexer ((use Plugins > Plugins Admin to install that plugin)
        2. Open a file that’s using your UDL
        3. Plugins > EnhanceAnyLexer > Enhance Current Language, which will open EnhanceAnyLexerConfig.ini and create a section in the INI file that matches the name of your lexer. (Example: if your UDL were called “TxoteLanguage”, then the section in the INI would be [TxoteLanguage])
        4. To change the foreground color for anything before a : on a line, you define a regex which matches from the beginning of the line up-to-the-: … For example, to make it red:
          [TxoteLanguage]
          0x000000FF = ^.*?:
          
          If you don’t want the : to be red, but just the text before it, use a fancier regex, which requires a colon after but doesn’t include the colon in the match:
          [TxoteLanguage]
          0x000000FF = ^.*?(?=:)
          

        The INI file includes comments which explain how to set the colors (0xBBGGRR)

        1 Reply Last reply Reply Quote 1
        • Txote LuscoT
          Txote Lusco
          last edited by PeterJones

          defined language enhancedanylexer local variables

          It is posible to create a regex espresion ,save the results, and use it for a new search? let me explain. I would like to color the local variables on CNC programs. like this.
          Program
          …
          DEF REAL DIAM
          …
          DIAM =25

          local variables have to be defined at the beginig of the program by DEF REAL/INT/… SOMETHING

          I can search for the words declared as local by:
          (?<=def\sreal\s)\w+
          But this one only mark DIAM. I will like to use the match DIAM to be the next search…
          its posible?
          Regards¡

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

            @Txote-Lusco ,

            Sorry, the EnhancedAnyLexer plugin doesn’t work that way. It cannot take the matching word from a pattern on one line, and highlight that same text even in different circumstances later.

            You seem to want more features than UDL alone, or UDL-plus-EnhanceAnyLexer, can give you. At that point, the remaining option is to write a custom lexer for your language: but that’s a complicated task, and we’re not going to do that for you; you will either have to write your own lexer, or hire someone to do it for you. (And no, there’s no “request for hire” section in this forum; if someone is interested, they could private-message you using the chat feature in the forum, but this isn’t a “jobs board”.)

            [Also, you originally posted your second message as a separate Topic, but since it was about syntax highlighting in the same UDL, I merged it together, so that people can get the full conversation without having to click links to other discussions.]

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