Community
    • Login

    Style words depending the end character

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 686 Views 2 Watching
    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 Offline
      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 Online
        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 Offline
          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 Online
            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

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors