/plugins/ConfigurableFoldHandler/tags/release-0-6-1/configurablefolding.html

# · HTML · 108 lines · 108 code · 0 blank · 0 comment · 0 complexity · 5def5462c8deeb4b38be001e529c8096 MD5 · raw file

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Configurable Fold Handler</title>
  5. </head>
  6. <body>
  7. <h2>Configurable Fold Handler</h2>
  8. <p>
  9. <b>Chris Kent</b>
  10. (<a href="mailto:ckent@espeed.co.uk">ckent@espeed.co.uk</a>)
  11. </p>
  12. <p>
  13. <h4>Introduction</h4>
  14. This plugin adds a fold handler that allows the user to specify the
  15. strings that define the start and end of a fold.
  16. </p>
  17. <p>
  18. <h4>Enabling Configurable Folding</h4>
  19. To enable configurable folding the folding mode must be set to
  20. &quot;custom&quot;. This is done from the folding mode drop downs
  21. in the buffer options dialog or by setting the default folding mode
  22. in global options->editing or global options->mode-specific options
  23. panes.
  24. </p>
  25. <p>
  26. <h4>Fold Strings</h4>
  27. Different fold strings can be specified for each edit mode and for
  28. individual buffers. Fold settings work in the same way as for other
  29. buffer settings. Global and mode-specific options are retained
  30. between jEdit sessions but buffer-specific fold strings are only
  31. retained as long as the buffer remains open.
  32. </p>
  33. <p>
  34. Defaults fold strings for each mode are set in the Configurable Folding
  35. section of the Plugin Options dialog. Fold strings are set for each buffer
  36. individually using Plugins->Configurable Fold Handler->Buffer Fold
  37. Strings.
  38. </p>
  39. <p>
  40. Fold strings cannot be blank. If invalid strings are entered in the Plugin
  41. Options dialog then an error message is displayed and folding is disabled
  42. for the selected mode. The Buffer Fold Strings dialog will not allow
  43. invalid strings to be entered.
  44. </p>
  45. <p>
  46. <h4>Regular Expressions</h4>
  47. If the "Use Regular Expressions" checkbox is selected then the fold
  48. handler will treat the strings as regular expressions and use them
  49. to match the start and end of folds. Under Java 1.3 the
  50. <code>gnu.regexp</code> package is used for matching. Under Java 1.4 the
  51. <code>java.util.regex</code> package is used which supports a wider range
  52. of regular expression syntax.
  53. </p>
  54. <p>
  55. <h4>Multiple Fold Strings</h4>
  56. In order to match on multiple strings the "Use Regular Expressions"
  57. option should be enabled and the list of strings separated with the
  58. | (pipe) character. For example <code>public|private|if|switch
  59. </code>. If there are any regular expression special characters in
  60. the start or end strings then they'll need to be preceeded with a
  61. backslash ('\') character otherwise the folding won't work as
  62. anticipated. These characters include the following:
  63. <pre>
  64. * . \ ? + | [ ] ( ) ^</pre>
  65. </p>
  66. <p>
  67. <h4>Some Example Regular Expressions</h4>
  68. For folding XML files with no indent the following start and end
  69. strings can be used:
  70. <pre>
  71. &lt;[^!/\?].*?[^/-]&gt;
  72. &lt;/.*?&gt;</pre>
  73. These only work properly if tags aren't broken across multiple lines.
  74. <p>
  75. For Java, C and C++ code the following are useful to fold on
  76. both brackets and range comments:
  77. <pre>
  78. {|/\*
  79. }|\*/</pre>
  80. (Java 1.3)
  81. <pre>
  82. \{|/\*
  83. \}|\*/</pre>
  84. (Java 1.4)
  85. </p>
  86. <p>
  87. If the start or end fold string is a substring of the other then
  88. normal folding will not work correctly. This can sometimes be
  89. worked around using regualar expressions. For example to match
  90. the strings <code>Function</code>, <code>End Function</code> the
  91. following regular expressions would work (under Java 1.4):
  92. <pre>
  93. (?&lt;!End )Function
  94. End Function</pre>
  95. </p>
  96. <p>
  97. The following versions are slightly more complete as they specify that the strings must be preceeded and followed by a word break (\b).
  98. <pre>
  99. (?&lt;!End )\bFunction\b
  100. \bEnd Function\b</pre>
  101. <p>
  102. If anyone has any other useful regular expressions or any default fold
  103. strings for any jEdit mode then please let me know and I'll include
  104. them.
  105. </p>
  106. </p>
  107. </body>
  108. </html>