/plugins/ConfigurableFoldHandler/tags/release-0-6-1/configurablefolding.html
# · HTML · 108 lines · 108 code · 0 blank · 0 comment · 0 complexity · 5def5462c8deeb4b38be001e529c8096 MD5 · raw file
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <title>Configurable Fold Handler</title>
- </head>
- <body>
- <h2>Configurable Fold Handler</h2>
- <p>
- <b>Chris Kent</b>
- (<a href="mailto:ckent@espeed.co.uk">ckent@espeed.co.uk</a>)
- </p>
- <p>
- <h4>Introduction</h4>
- This plugin adds a fold handler that allows the user to specify the
- strings that define the start and end of a fold.
- </p>
- <p>
- <h4>Enabling Configurable Folding</h4>
- To enable configurable folding the folding mode must be set to
- "custom". This is done from the folding mode drop downs
- in the buffer options dialog or by setting the default folding mode
- in global options->editing or global options->mode-specific options
- panes.
- </p>
- <p>
- <h4>Fold Strings</h4>
- Different fold strings can be specified for each edit mode and for
- individual buffers. Fold settings work in the same way as for other
- buffer settings. Global and mode-specific options are retained
- between jEdit sessions but buffer-specific fold strings are only
- retained as long as the buffer remains open.
- </p>
- <p>
- Defaults fold strings for each mode are set in the Configurable Folding
- section of the Plugin Options dialog. Fold strings are set for each buffer
- individually using Plugins->Configurable Fold Handler->Buffer Fold
- Strings.
- </p>
- <p>
- Fold strings cannot be blank. If invalid strings are entered in the Plugin
- Options dialog then an error message is displayed and folding is disabled
- for the selected mode. The Buffer Fold Strings dialog will not allow
- invalid strings to be entered.
- </p>
- <p>
- <h4>Regular Expressions</h4>
- If the "Use Regular Expressions" checkbox is selected then the fold
- handler will treat the strings as regular expressions and use them
- to match the start and end of folds. Under Java 1.3 the
- <code>gnu.regexp</code> package is used for matching. Under Java 1.4 the
- <code>java.util.regex</code> package is used which supports a wider range
- of regular expression syntax.
- </p>
- <p>
- <h4>Multiple Fold Strings</h4>
- In order to match on multiple strings the "Use Regular Expressions"
- option should be enabled and the list of strings separated with the
- | (pipe) character. For example <code>public|private|if|switch
- </code>. If there are any regular expression special characters in
- the start or end strings then they'll need to be preceeded with a
- backslash ('\') character otherwise the folding won't work as
- anticipated. These characters include the following:
- <pre>
- * . \ ? + | [ ] ( ) ^</pre>
- </p>
- <p>
- <h4>Some Example Regular Expressions</h4>
- For folding XML files with no indent the following start and end
- strings can be used:
- <pre>
- <[^!/\?].*?[^/-]>
- </.*?></pre>
- These only work properly if tags aren't broken across multiple lines.
- <p>
- For Java, C and C++ code the following are useful to fold on
- both brackets and range comments:
- <pre>
- {|/\*
- }|\*/</pre>
- (Java 1.3)
- <pre>
- \{|/\*
- \}|\*/</pre>
- (Java 1.4)
- </p>
- <p>
- If the start or end fold string is a substring of the other then
- normal folding will not work correctly. This can sometimes be
- worked around using regualar expressions. For example to match
- the strings <code>Function</code>, <code>End Function</code> the
- following regular expressions would work (under Java 1.4):
- <pre>
- (?<!End )Function
- End Function</pre>
- </p>
- <p>
- The following versions are slightly more complete as they specify that the strings must be preceeded and followed by a word break (\b).
- <pre>
- (?<!End )\bFunction\b
- \bEnd Function\b</pre>
- <p>
- If anyone has any other useful regular expressions or any default fold
- strings for any jEdit mode then please let me know and I'll include
- them.
- </p>
- </p>
- </body>
- </html>