Community
    • Login

    UDL - combining C++ folding and Nasal highlighting

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 2 Posters 53 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.
    • Joe WiltonJ
      Joe Wilton
      last edited by

      I have a UDL for Nasal (language used by FlightGear). It works. But there is no folding. If I select C++ as the language I get folding. I want to combine both effects at the same time. I have tried using Define Your Language … multiple times. I have tried specifying {} in both the code 1 and code 2 sections. They never work like folding in C++. C++ folds using {}. Am I tripping over a bug? Is there some way to specify folding in the nasal.xml file that does the highlighting? Am I just not using the dialog correctly? I used the Import function to setup the Nasal language from github (nasal-npp-master maintained by slaiyer).

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

        @Joe-Wilton ,

        UDL code folding with OPEN = { and CLOSE = } works perfectly, for me:

        ead59376-05ec-4efc-9588-c27d09c4fcf2-image.png

        06f8231d-9bbb-487f-b07a-cc11eb313290-image.png

        9b600dd3-7d6f-4d35-88d3-70829538a4f6-image.png

        If you cannot replicate my results, you will have to show your User Defined Language dialog on the Folder & Default page, along with code that shows it not working (both in your screenshot, and using the </> button and pasting it over the code_text that the button inputs)

        UDL code folding
        {
            works fine
            {
                nested
            }
        }
        
        1 Reply Last reply Reply Quote 0
        • Joe WiltonJ
          Joe Wilton
          last edited by

          Thank you for your reply. I did some more experimenting and generated a udl from scratch with the gui … and it works. The nasal udl i downloaded appears to have been created 11 years ago. Using it folding doesn’t work. I have examined the definition for it that I found in userDefineLang.xml. It does have Keywords entries for Folders in Code 1 and Folders in Code 2. I have compared the one I created to this one to see if I can see what is different with regards to folding but haven’t found anything. For the time being I will use my manually generated one and ignore the downloaded one. So much for trying to no reinvent the wheel. I will investigate more when I have time. Thanks again.

          1 Reply Last reply Reply Quote 1
          • Joe WiltonJ
            Joe Wilton
            last edited by PeterJones

            I investigated some more. I found that the Operators 1 was :

            - ! ( ) * / % : ? ^ { } ~ + < = > [ ] . , ;
            

            After deleting the {} , it worked. Obviously there is some interaction between the characters in the Operators 1 list and the Folding in Code 1 and 2 styles.

            PeterJonesP 1 Reply Last reply Reply Quote 1
            • PeterJonesP
              PeterJones @Joe Wilton
              last edited by

              @Joe-Wilton,

              Obviously there is some interaction between the characters in the Operators 1 list and the Folding in Code 1 and 2 styles.

              The intention for UDL is that no given token (symbol or word) is found in two separate fields: they are supposed to be unique, because you cannot style a token both as an Operator and as a Folding-In-Code, as the two are mutually exclusive. There is an internal order they are processed, but that order is not guaranteed (a few versions back, Notepad++ actually changed the order of a couple of the fields, which broke some UDL that were relying on the old order of processing to handle conflicts in their definitions). If you make the UDL without conflicts, you won’t have problems if Notepad++ changes the internals again.

              (By “no given token … is found”, I mean “is found alone”. For example, you could have a fold-open2 of { and an operator of {{ – if it finds double-brace, it will render it as an operator, but a single-brace will be a fold-open2.)

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