Difference between revisions of "Function lists"

From EditPlus Wiki
Jump to: navigation, search
(Syntax & Highlighting)
m
 
(25 intermediate revisions by 20 users not shown)
Line 1: Line 1:
==Interface==
+
==JavaScript==
===Close with middle-click===
+
  
You can close a file by middle-clicking (i.e. clicking the wheel on your mouse) on the "document selector" for that file. The document selector is the row of tabs at the bottom (or top if you've customised EditPlus) with all the currently open documents.
+
Both function pattern regular expressions support partial display using the first tagged expression in the Function Pattern dialog.
  
This functionality is not enabled by default. To enable:
+
^[ \t]*function[ \t](.*\(.*\)).*$
 +
^[ \t]*([^:=]+[:=] function ?\(.*\)).*
  
# Right-click on the document selector bar and select Options
+
These expressions will find functions of the following forms in your file:
# Enable "Close document with middle mouse button"
+
# Click OK
+
  
 +
function foobarspaz(arg1, arg2) {}
 +
foobarspaz: function(arg1, arg2) {}
 +
foobarspaz = function(arg1, arg2) {}
  
==Syntax & Highlighting==
+
==PHP5==
===CSS Function List===
+
When using classes in PHP5 the function keyword can be preceded by "public", "private" or "protected".  The following updated regex takes account of this change from PHP4.  If you don't know why you might need this, then you probably don't.
  
EditPlus provides the ability to list the functions in a file by using Search -> Function List. Though this works for C++, Perl and similar programming languages out of the box, it's not hard to add the same functionality for CSS files to list selectors.
+
^[ \t]*(public[ \t]|protected[ \t]|private[ \t]|)[ \t]*function[ \t].*\([^;]*$
  
There is one catch however, since CSS doesn't have a "function" keyword we need to find a way to identify lines containing selector. I've chosen to use the most common method; selectors start at the beginning of the line with an alphanumeric character, all other lines (properties, comments) must be indented (or generally start with a non-alphanumeric character). Example:
+
To also show classes in the function list use the following:
 
+
  ^[ \t]*((public[ \t]|protected[ \t]|private[ \t]|)[ \t]*function[ \t].*\()|(class[ \t].*\{)[^;]*$
  /*
+
  Example of a comment
+
*/
+
td.test
+
{
+
  background-color:  #ffffff;
+
  color:              #000000;
+
  padding:            2px;
+
}
+
 
+
Now for the EditPlus part:
+
 
+
#go to Tools -> Preferences
+
#find the Settings & Syntax option under the Files section
+
#select CSS from the File Types list
+
#in the Function Pattern box, enter: ^[a-zA-Z0-9]
+
 
+
If you are unfamiliar with [[Regular Expressions]]: the ^ matches the beginning of the line, so that's where our search will start. After that, match a single character in the range of a-z, it's capital equivelant or 0-9, also known as alphanumeric. Since we indicated this character must be directly after the beginning of the line, any line with a leading space or tab will be ignored, as will the {} lines.
+
 
+
If you open up the Function List again, you'll get a list of all selectors; just be careful on how you format the CSS.
+
 
+
You can also develop more advanced, more general, stricter patterns like
+
^([@:\.#]?[A-z][A-z0-9_-]*)([ \t]*[,+> ][ \t]*([:\.#]?[A-z][A-z0-9_-]*))*[ \t]*{?
+
This particular pattern still lacks support for some complexer selectors, e.g. 'a[hreflang|="en"]', 'html:lang("en")' or multiline ones, and chokes on comments.
+
 
+
===HTML Function List===
+
Of course HTML does not have functions, but especially in longer documents it is convenient to be able to jump to headings. You can either regex-search for "<h[1-6]" and select ''Set Marker'' or you use the function list (Ctrl-F11) with a pattern like this in Settings & Syntax > Files > HTML > Function Pattern
+
 
+
<(h[1-6]|caption)
+

Latest revision as of 21:24, 25 March 2010

JavaScript

Both function pattern regular expressions support partial display using the first tagged expression in the Function Pattern dialog.

^[ \t]*function[ \t](.*\(.*\)).*$
^[ \t]*([^:=]+[:=] function ?\(.*\)).*

These expressions will find functions of the following forms in your file:

function foobarspaz(arg1, arg2) {}
foobarspaz: function(arg1, arg2) {}
foobarspaz = function(arg1, arg2) {}

PHP5

When using classes in PHP5 the function keyword can be preceded by "public", "private" or "protected". The following updated regex takes account of this change from PHP4. If you don't know why you might need this, then you probably don't.

^[ \t]*(public[ \t]|protected[ \t]|private[ \t]|)[ \t]*function[ \t].*\([^;]*$

To also show classes in the function list use the following:

^[ \t]*((public[ \t]|protected[ \t]|private[ \t]|)[ \t]*function[ \t].*\()|(class[ \t].*\{)[^;]*$