Community
    • Login

    New UserDefinedLang - code fold must begin at margin

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    udl folding
    4 Posts 2 Posters 365 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.
    • gibberishbcG
      gibberishbc
      last edited by PeterJones

      NPP version: 7.7.1
      UDL ver 2.1.0.12

      I am creating a user-defined-language and am having trouble with the code-folding definitions. Most of the UDL is working great, but it would be great to get the subroutines folding, since I have over a hundred of them.

      In this language, subroutines are defined as in this example:

      :MySubTitle
      code line here
      code line here
      code line here
      Return

      I wish to fold between the : and the word Return (the subroutine’s title could be any string of chars). Problem: the concat character is also a colon (:) – and these can be found anywhere in the code. Also, the word Return could be found at other places within a subroutine. If either of these cases is true, the code folding goes completely bonkers – for example if a colon ( : ) character is encountered anywhere inside a subroutine (and since the colon is the concat character, this happens a lot). So basically, I cannot code fold the subroutines – see the screenshot at end of this message).

      In this language, note that subroutine :Label / Return are always at the left margin (or indented one tab). In fact, it would be just fine if code-folding required the subroutine start/end to be found at the beginning of the line (not indented at all).

      So, is it possible to tell NPP that the code-fold triggers are ONLY valid if found at the beginning of the line (or after some whitespace) ? If not, can this be made into a feature request? Note that I do not have a “Prefix Mode” checkbox anywhere in the “Folding in code N style” groups (“Folder & Default” tab) - see below screenshot.

      screenshot

      Again, my version info is:
      NPP version: 7.7.1
      UDL ver 2.1.0.12
      —
      moderator fixed the image link so the image was embedded

      1 Reply Last reply Reply Quote 1
      • EkopalypseE
        Ekopalypse
        last edited by

        @gibberishbc said in New UserDefinedLang - code fold must begin at margin:

        :MySubTitle
        code line here
        code line here
        code line here
        Return

        Afaik, jein, you can, if this is possible on your side, create multiple opens,
        to be exact - for each letter an open folder tag like :A :B :C … and fake the
        return statement with an added comment tag. This might work.

        To address feature requests, see here.

        gibberishbcG 1 Reply Last reply Reply Quote 1
        • gibberishbcG
          gibberishbc @Ekopalypse
          last edited by gibberishbc

          @Ekopalypse
          Thanks - good suggestion.

          I don’t understand the closing suggestion, though. What do you mean “fake the
          return statement with an added comment tag” ? What would that look like, or can you link me to another post that explains?

          Many thx !

          PS - This question was created/posted yesterday, but I see it is timestamped Oct 7, 2019. Any idea what might have happened? ALSO, I responded (and am now editing) using the Brave browser - and it is working correctly (I see the SUBMIT button so it should save correctly). Ignore my comment from yesterday on my other post (will update)

          EkopalypseE 1 Reply Last reply Reply Quote 0
          • EkopalypseE
            Ekopalypse @gibberishbc
            last edited by

            @gibberishbc

            This is indeed an older thread, your recent threads are others.

            As for the fake return statement, assuming a language doesn’t have start and end tokens like if and endif but does have comments, which is the case in most programming languages, you could use the start token if and a end token like #endif, where # is actually a comment.
            This way, the language itself is still happy when it is executed, and npp (or UDL) knows where to break.

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