Community
    • Login

    User-Defined Language | Problem with Code Folding

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 3 Posters 5.3k 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.
    • Lukas KieferL
      Lukas Kiefer
      last edited by

      Hi there!

      I set up a user defined language for maxscript and so far i have everything working except code folding.

      Code example:

      		--- loop each state
      		for thestate in allstates do
      		(
      			--- restores a scenestate by name
      			sceneStateMgr.RestoreAllParts thestate
      			
      			-- what values are saved in it?
      			statebitarray = sceneStateMgr.GetParts thestate
      			
      			--- set layer status to hidden or not
      			myLayer = LayerManager.getLayerFromName layername
      			myLayer.on = theswitch
      			
      			if updatenested then
      			(
      				-- handle children
      				layerRT = mylayer.layerAsRefTarg
      				for a=1 to layerRT.getNumChildren() do
      				(
      					childlayer = layerRT.getChild a
      					childlayer.on = mylayer.on
      				)
      			)
      			
      			-- save scene state with the same name
      			sceneStateMgr.Capture thestate statebitarray
      		)
      

      What i would like to achieve is code folding the nested brackets. If i set up the UDL for folding with
      Open: (
      Middle:
      Close: )
      the folding looks like this:
      image

      Is there a way to fix this?
      Folding by intendation would also be fine, although when researching it, it kinda seemed to me like that’s a python exclusive thing.

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Claudia FrankC
        Claudia Frank @Lukas Kiefer
        last edited by

        @Lukas-Kiefer

        Your example works for me.
        By any chance do you use non-windows eol?
        Recently one reported an issue when using unix eols.

        Yes, you are right, UDL cannot use indention for folding.

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 0
        • Lukas KieferL
          Lukas Kiefer
          last edited by

          Okay thank you. I tried changing the eol but it didn’t help.

          I figured it out by myself. Problem causing my issue was i set the Close on line comments to ((EOL)).
          Somehow that caused code folding on some line comments.

          Now that i have that working i have one more question.

          Functions are defined like this:
          fn updatelayertoscenestates layername mode:1 updatenested:true = (return true)

          Is it possible to style the optional parameters (The ones followed by “:”)?

          Cheers and thank you for helping me

          1 Reply Last reply Reply Quote 0
          • Claudia FrankC
            Claudia Frank
            last edited by

            I understand that, from your example, you want to have the 1 and the word true colored.
            No, I don’t think it is possible using the current udl version.

            Cheers
            Claudia

            1 Reply Last reply Reply Quote 0
            • Lukas KieferL
              Lukas Kiefer
              last edited by

              Hi, no that’s not what i mean.
              I’d like to have the “mode:” and “updatenested:” colored. Basically every word ending on “:”.

              Cheers
              Lukas

              Claudia FrankC 1 Reply Last reply Reply Quote 0
              • Claudia FrankC
                Claudia Frank @Lukas Kiefer
                last edited by

                @Lukas-Kiefer

                Quick update as I’m on the run, maybe using a delimiter
                Open fn
                Close =
                and allowing nesting?
                Assuming that function name function definition and parameters
                are part of keywords, numbers etc…

                Cheers
                Claudia

                1 Reply Last reply Reply Quote 0
                • WerwacKW
                  WerwacK
                  last edited by

                  Hi Lukas,

                  I am sharing a User Defined Language setup for Maxscript on my webpage if you want.
                  I found it on the web a long time ago and use it regularly. It is not perfect though, so I am currently asking for help in order to see the functions in the Functions Lister panel (another thread in this forum).

                  http://werwackfx.com/index.php/graphictools/maxscript-main/maxscript-articles/73-maxscriptinnotepadpp

                  I didn’t found how to set up the folding blocks eithers unfortunately.

                  Hope this helps,

                  Werwack

                  1 Reply Last reply Reply Quote 0
                  • WerwacKW
                    WerwacK
                    last edited by

                    Hi Lukas,

                    This thread about Maxscript may also interest you: https://notepad-plus-plus.org/community/topic/13443/need-help-to-make-maxscript-functions-recognized-by-function-list

                    Werwack

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