Menu

regex code-folding criteria

TodWulff
2008-06-01
2012-11-13
  • TodWulff

    TodWulff - 2008-06-01

    Is there a means to have code folding key on Regular Expressions?

    i.e. in the language that I use NPP for, the IF/THEN/ELSEIF/ELSE/ENDIF statements can come in a number of flavors.  A couple example constructs follow:

    First construct:

        IF conditional THEN
           statements
        [ELSEIF conditional THEN
           other statements]
        [ELSE
           more statements]
        ENDIF

    Second construct:

        IF conditional THEN statement

    Obviously, the folding of the 2nd construct's form is invalid as it is a single-line statement, but if I configure the GUI to fold based on the first flavor of the construct, then the folding logic get's confused when it comes to an iteration of the 2nd flavor of the construct.

    If we were able to construct folding criteria based upon Regular Expressions, I think that this would go a long way in giving NPP a lot more leveragability for the code-folding feature set.

    Is this do-able in NPP currently?  If so, please point me to the guidance to facilitate same.  If not, does the under-lying frameworks facilitate a means to implement this type of programmatic code-folding based on RegEx expressions?  If so, can this be added to the list of requested features?

    It seems that this is a generic enough enhancement that, if do-able, would be able to be used by most all users of NPP, regardless of the language that they are coding in.

    Just a thought.

    Thanks.

    -Tod Wulff

     
    • Harry

      Harry - 2008-06-03

      You can currently not do any folding based on Regexp, at least not directly.
      The closest thing you have is writing a lexer with code folding support, which you could base off regexp. The built-in regexp of Scintilla is quite limited so folding isn't really an option, you need to use another regexp engine to do so, probably.
      I don't think regexp is the ideal solution for folding support, since you can have any keyword at any time (user is typing), so you need to search for all of them on the same location at the same time, and then possibly through the rest of the document. Current lexer can handle this much better imo.

       
    • TodWulff

      TodWulff - 2008-06-05

      Thanks, Harry.  Your input is greatly appreciated.

      While I don't pretend to know much about lexers, I appreciate what you are stating.

      I'll continue to work around it by sticking to the non-single-line flavors of the constructs.

      Again, thanks!

      -t

      p.s. when is v5 coming out?  I understand that you are working on some pretty nifty enhancements (i.e. pseudo-intellisense).  I am excited about that.!.  Let us know, when able.  Take care.  -t

       
      • Harry

        Harry - 2008-06-05

        Don and I are planning to do an RC next weekend. There are still bugs popping up now and then which cause delay, but I think we got most of em.
        The pseudo intellisense actually requires some effort of the community or atleast some time since the autocomplete files for it remain to be generated :)

         
        • Greg Williams

          Greg Williams - 2008-06-22

          Don and Harry,

          I am willing to provide some support, either programming, config file generation or testing. This will be a very valuable feature to have.