#534 PHP+Javascript folding update

Completed
closed
Scintilla (358)
3
2009-04-28
2008-10-02
Jason Oster
No

Attached patch (+ full file) adds support for folding:

* PHP multi-line comments (ref: #2130579)
* PHP HEREDOC/NOWDOC strings (ref: #1945003)
* Javascript multi-line comments

I'm not sure it's a good idea to modify levelCurrent after the folding code near the beginning of the colourise loop (which only triggers on line breaks). But in my tests, the patch has not caused any problems.

Discussion

  • Jason Oster

    Jason Oster - 2008-10-02

    Patch v1

     
  • Neil Hodgson

    Neil Hodgson - 2008-10-05
    • labels: --> Scintilla
    • priority: 5 --> 3
    • assigned_to: nobody --> nyamatongwe
     
  • Neil Hodgson

    Neil Hodgson - 2008-10-05

    The C++ lexer has a fold.comment setting. Are you sure that every PHP/Javascript user is going to want their heredocs and comments to fold?

     
  • Jason Oster

    Jason Oster - 2008-10-05

    Not at all certain, but I have considered making it optional.

     
  • Jason Oster

    Jason Oster - 2008-10-06

    Patch v2

     
  • Jason Oster

    Jason Oster - 2008-10-06

    Patch v2 uses the "global" fold.comment pref, like the C++ lexer, and adds a new fold.heredoc pref, which other lexers (Bash, Perl...?) can use, too. Both prefs default to off.
    File Added: php_js_folding.zip

     
  • Neil Hodgson

    Neil Hodgson - 2008-10-08

    A couple of years back I defined a convention for new fold/lexer properties so that they could be automatically found by scripts. The convention should be in the documentation but looks like it was only ever posted on the mailing list. To match, these should be called something like fold.hypertext.comment and fold.hypertext.heredoc since the lexer name is 'hypertext'.

     
  • Jason Oster

    Jason Oster - 2008-10-08

    Unfortunately, I cannot find any reference to the property naming conventions. Could you point me to the mailing list post which explains? Or if no archive exists online, forward it to the current Scintilla-Interest group, where I am already subscribed.

    Thanks!

     
  • Jason Oster

    Jason Oster - 2008-10-09

    Patch v3

     
  • Jason Oster

    Jason Oster - 2008-10-09

    Thanks. I take it you don't want the HTML lexer re-using the fold.comment property that the C++ lexer already uses. In that case, fold.hypertext.comment and fold.hypertext.heredoc work fine. Updated patch with new pref names. (trivial)
    File Added: LexHTML.cxx.patch

     
  • Neil Hodgson

    Neil Hodgson - 2008-10-09

    OK, I'm happy with that. I wasn't sure whether that was the best naming or whether it should be more specific like lexer.hypertext.php.heredoc. People often want more control over the hypertext lexer and its more likely to be used in conjunction with another language. For example, having C++ and Pascal share a variable may not be a problem since they are less likely to be used in a single project but its common to have Java and HTML in a single project and a user may want different options for the two languages.

     
  • Jason Oster

    Jason Oster - 2008-10-09

    That's a good point; comment folding in the patch applies to both JS and PHP, and heredoc folding only to PHP. I can't state for certain that any of the other languages in the HTML lexer don't have heredoc syntax, but it would surprise me if they did. To be quite honest, the pref names do not matter to me ... as long as I can set them, anything will work.

     
  • Neil Hodgson

    Neil Hodgson - 2008-10-14

    Committed.

     
  • Neil Hodgson

    Neil Hodgson - 2009-04-28

    Released in 1.78.

     
  • Neil Hodgson

    Neil Hodgson - 2009-04-28
    • milestone: --> Completed
    • status: open --> closed
     

Log in to post a comment.