Inserting dividers in function list

Inserting dividers in function list

2
NewbieNewbie
2

    Jan 16, 2010#1

    Hello,

    Can anybody help me with setting up a regular expression in the worldfile to enable putting dividers in the function list that match PHP comments. For example, I'd like a regular expression to match the "------" in:

    //------

    That way we can divide functions in long php files using the above string and have the dividers show up in the function list.

    I can't for the life of me figure out how to setup an appropriate regular expression!

    Thanks so much in advance.

    David

    6,602548
    Grand MasterGrand Master
    6,602548

      Jan 17, 2010#2

      Open Advanced - Configuration - Editor Display - Syntax Highlighting, select Language PHP and press button Open. Close the configuration dialog with button Cancel.

      Insert below the line /Function String 3 = "%[^t ]++protected[^t ]++function[^t ]+^([a-z0-9_&]+^)" following line:

      /Function String 4 = "%[^t ]++//[^t ]++^(---+^)"

      or more simple

      /Function String 4 = "//[^t ]++^(---+^)"

      or extremly simplified

      /Function String 4 = "//^(---+^)"

      The first one means: Find a string starting at beginning of a line % which can contain 0 or more occurrences of spaces/tabs [^t ]++, 2 forward slashes //, again 0 or more occurrences of spaces/tabs [^t ]++ and 3 or more hyphens ---+. The hyphens should be displayed in the function list ^(^).

      Save the wordfile and switch focus to a PHP file. You should see now the deviders in the function list. But that makes only sense when you right click into the function list and uncheck option Sort List.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Jan 19, 2010#3

        Thanks so much!! That worked! What a huge help!

        2
        NewbieNewbie
        2

          Jul 21, 2010#4

          I have a very similar problem/request.

          The regular expression above works fine for JavaScript as well.
          However, I was wondering what I would need to do, if I want to have that divider as an empty line?

          For example I used to use this expression with UltraEdit 13: //#^([a-zA-Z_0-9_\' ^t/]++^)
          So that every line with "//#" will be displayed in the function list, even if "//#" is only followed by spaces. (which I use as dividers between functions)

          Now, our company has moved on to UltraEdit 16, and here it does not work any more if the "//#" is only followed by spaces.

          Is there a way around it?

          Many Thanks!

          6,602548
          Grand MasterGrand Master
          6,602548

            Jul 21, 2010#5

            I have not tested it, but what happens when you use //#^([a-z0-9_\' ^t/]+^) because ++ means 0 or more and when no further search criteria follows, matching nothing is valid for this part of the expression. But nothing matched by the tagged expression means nothing to display in the function list and the line is ignored. BTW: A-Z_ in your expression is useless because the underscore is than twice in the list and the find command is always executed not case sensitive and therefore A-Z is equal a-z.

            Update on 2010-07-22:

            I tested the expression now and it looks like UE uses now CString.TrimRight() on every found string. And when the resulting string is empty, the line is ignored for the function list view. So lines starting with //# and only containing spaces and tabs are now always ignored. A possible solution would be to use the non breaking space in the files (and also in the regular expression). The non breaking space has decimal code 160 (hex. 0xA0) and you can insert it for example using View - Views/Lists - ASCII Table. Of course that requires that you run an UltraEdit regular expression replace in files searching for //#[ ^t]+$ and replacing it with //#nbsp with nbsp copied from the document window.

            Then you can use as regular expression string in the wordfile "//#[ ^t]++^(*^)$".
            Best regards from an UC/UE/UES for Windows user from Austria

            2
            NewbieNewbie
            2

              Jul 22, 2010#6

              Thank you Mofi!
              This worked just fine.


              It's a shame though, that one has to change now every script...
              I suppose this is nothing that would change in later versions, simply because not many people would empty lines a deciders in their function list...

              Anyhow, thanks again!

              6,602548
              Grand MasterGrand Master
              6,602548

                Jul 22, 2010#7

                I'm quite sure that most users use function list view option Sort List and devider lines make no sense with this option enabled. Also I'm quite sure that trimming trailing spaces on found strings and eliminating empty strings was implemented on behalf of requests by users which perhaps used not good expressions and therefore see unwanted trailing spaces and empty lines in the function list. Also it is nowadays possible with using the Perl regular expression engine to build the displayed string in the function list from several parts of the found string, see for example Perl regexp function list for C#. And finally since UE v16.00 it is possible to group function strings and the number of regular expressions is unlimited.
                Best regards from an UC/UE/UES for Windows user from Austria