PageRenderTime 43ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre4/doc/users-guide/macro-index.xml

#
XML | 411 lines | 349 code | 57 blank | 5 comment | 0 complexity | 3895b0f5b91830de2320cd462d0382a7 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. <!-- jEdit 4.0 Macro Guide, (C) 2001 John Gellene -->
  2. <!-- jEdit buffer-local properties: -->
  3. <!-- :indentSize=1:noTabs=yes:maxLineLen=72:tabSize=2: -->
  4. <!-- :xml.root=users-guide.xml: -->
  5. <!-- covers index to installed macro set -->
  6. <appendix id="macro-index"><title>Macros Included With jEdit</title>
  7. <para>
  8. jEdit comes with a large number of sample macros that perform a variety
  9. of tasks. The following index provides short descriptions of each macro,
  10. in some cases accompanied by usage notes.
  11. </para>
  12. <para>
  13. In addition to the macros included with jEdit,
  14. a very large collection of user-contributed macros is available
  15. in the <quote>Downloads</quote> section of the
  16. <ulink url="http://community.jedit.org">community.jedit.org</ulink>
  17. web site. There are detailed descriptions for
  18. each macro as well as a search facility.
  19. </para>
  20. <sect1 id="macros-files"><title>File Management Macros</title>
  21. <para>
  22. These macros automate the opening and closing of files.
  23. </para>
  24. <itemizedlist>
  25. <listitem>
  26. <para><filename>Browse_Directory.bsh</filename></para>
  27. <abstract><para>
  28. Opens a directory supplied by the user in the file system
  29. browser.
  30. </para></abstract>
  31. </listitem>
  32. <listitem>
  33. <para><filename>Close_All_Except_Active.bsh</filename></para>
  34. <abstract><para>
  35. Closes all files except the current buffer.
  36. </para></abstract>
  37. <para>
  38. Prompts the user to save any buffer containing unsaved changes.
  39. </para>
  40. </listitem>
  41. <listitem>
  42. <para><filename>Open_Path.bsh</filename></para>
  43. <abstract><para>
  44. Opens the file supplied by the user in an input dialog.
  45. </para></abstract>
  46. </listitem>
  47. <listitem>
  48. <para><filename>Open_Selection.bsh</filename></para>
  49. <abstract><para>
  50. Opens the file named by the current buffer's selected text.
  51. </para></abstract>
  52. </listitem>
  53. </itemizedlist>
  54. </sect1>
  55. <sect1 id="macros-java"><title>Java Code Macros</title>
  56. <para>
  57. These macros handle text formatting and generation tasks that are
  58. particularly useful in writing Java code.
  59. </para>
  60. <itemizedlist>
  61. <listitem>
  62. <para><filename>Get_Class_Name.bsh</filename></para>
  63. <abstract><para>
  64. Inserts a Java class name based upon the buffer's file name.
  65. </para></abstract>
  66. </listitem>
  67. <listitem>
  68. <para><filename>Get_Package_Name.bsh</filename></para>
  69. <abstract><para>
  70. Inserts a plausible Java package name for the current buffer.
  71. </para></abstract>
  72. <para>
  73. The macro compares the buffer's path name with the elements of the
  74. classpath being used by the jEdit session. An error message will be
  75. displayed if no suitable package name is found. This macro will not
  76. work if jEdit is being run as a JAR file without specifying a
  77. classpath; in that case the classpath seen by the macro consists
  78. solely of the JAR file.
  79. </para>
  80. </listitem>
  81. <listitem>
  82. <para><filename>Make_Get_and_Set_Methods.bsh</filename></para>
  83. <abstract><para>
  84. Creates <function>getXXX()</function> or <function>setXXX()</function>
  85. methods that can be pasted into the buffer text.
  86. </para></abstract>
  87. <para>
  88. This macro presents a dialog that will <quote>grab</quote> the names
  89. of instance variables from the caret line of the current buffer
  90. and paste a corresponding <function>getXXX()</function> or
  91. <function>setXXX()</function> method to one of two text areas in the
  92. dialog. The text can be edited in the dialog and then pasted into the
  93. current buffer using the <guilabel>Insert...</guilabel> buttons. If
  94. the caret is set to a line containing something other than an instance
  95. variable, the text grabbing routine is likely to generate nonsense.
  96. </para>
  97. <para>
  98. As explained in the notes accompanying the source code, the macro
  99. uses a global variable which can be set to configure the macro to work
  100. with either Java or C++ code. When set for use with C++ code,
  101. the macro will also write (in commented text) definitions of
  102. <function>getXXX()</function> or <function>setXXX()</function>
  103. suitable for inclusion in a header file.
  104. </para>
  105. </listitem>
  106. <listitem>
  107. <para><filename>Preview_Javadoc_of_Buffer.bsh</filename></para>
  108. <abstract><para>
  109. Creates and displays javadoc for current buffer.
  110. </para></abstract>
  111. <para>
  112. The macro includes configuration variables for using
  113. different doclets for generating javadocs and for generating
  114. javadocs of the package of which the current buffer is a part.
  115. Details for use are included in the note accompanying the macro's
  116. source code.
  117. </para>
  118. </listitem>
  119. </itemizedlist>
  120. </sect1>
  121. <sect1 id="macros-properties"><title>Macros for Listing Properties</title>
  122. <para>
  123. These macros produce lists or tables containing properties
  124. used by the Java platform or jEdit itself.
  125. </para>
  126. <itemizedlist>
  127. <listitem>
  128. <para><filename>jEdit_Properties.bsh</filename></para>
  129. <abstract><para>
  130. Writes an unsorted list of jEdit properties in a new buffer.
  131. </para></abstract>
  132. </listitem>
  133. <listitem>
  134. <para><filename>System_Properties.bsh</filename></para>
  135. <abstract><para>
  136. Writes an unsorted list of all Java system properties in a new
  137. buffer.
  138. </para></abstract>
  139. </listitem>
  140. <listitem>
  141. <para><filename>Look_and_Feel_Properties.bsh</filename></para>
  142. <abstract><para>
  143. Writes an unsorted list of the names of Java Look and Feel
  144. properties in a new buffer.
  145. </para></abstract>
  146. </listitem>
  147. </itemizedlist>
  148. </sect1>
  149. <sect1 id="macros-misc"><title>Miscellaneous Macros</title>
  150. <para>
  151. While these macros do not fit easily into the other categories, they all provide
  152. interesting and useful functions.
  153. </para>
  154. <itemizedlist>
  155. <listitem>
  156. <para><filename>Cascade_jEdit_Windows.bsh</filename></para>
  157. <abstract><para>
  158. Rearranges view and floating plugin windows.
  159. </para></abstract>
  160. <para>
  161. The windows are arranged in an overlapping <quote>cascade</quote>
  162. pattern beginning near the upper left corner of the display.
  163. </para>
  164. </listitem>
  165. <listitem>
  166. <para><filename>Display_Abbreviations.bsh</filename></para>
  167. <abstract><para>
  168. Displays the abbreviations registered for each of jEdit's
  169. editing modes.
  170. </para></abstract>
  171. <para>
  172. The macro provides a read-only view of the abbreviations
  173. contained in the <quote>Abbreviations</quote> option pane. Pressing
  174. a letter key will scroll the table to the first entry beginning with
  175. that letter. A further option is provided to write a selected mode's
  176. abbreviations or all abbreviations in a text buffer for printing as a
  177. reference. Notes in the source code listing point out some display options
  178. that are configured by modifying global variables.
  179. </para>
  180. </listitem>
  181. <listitem>
  182. <para><filename>Display_Shortcuts.bsh</filename></para>
  183. <abstract><para>
  184. Displays a sorted list of the keyboard shortcuts currently in effect.
  185. </para></abstract>
  186. <para>
  187. The macro provides a combined read-only view of command, macro
  188. and plugin shortcuts. Pressing a letter key will
  189. scroll the table to the first entry beginning with that letter.
  190. A further option is provided to write the shortcut assignments in a
  191. text buffer for printing as a reference. Notes in the source code
  192. listing point out some display options that are configured by
  193. modifying global variables.
  194. </para>
  195. </listitem>
  196. <listitem>
  197. <para><filename>Evaluate_Buffer_in_BeanShell.bsh</filename></para>
  198. <abstract><para>
  199. Evaluates contents of current buffer as a BeanShell script,
  200. and opens a new
  201. buffer to receive any text output.
  202. </para></abstract>
  203. <para>
  204. This is a quick way to test a macro script even before its text
  205. is saved to a file. Opening a new buffer for output is a precaution
  206. to prevent the macro from inadvertently erasing or overwriting
  207. itself. BeanShell scripts that operate on the contents of the
  208. current buffer will not work meaningfully when tested using this
  209. macro.
  210. </para>
  211. </listitem>
  212. <listitem>
  213. <para><filename>Hex_Convert.bsh</filename></para>
  214. <abstract><para>
  215. Converts byte characters to their hex equivalent, and vice versa.
  216. </para></abstract>
  217. </listitem>
  218. <listitem>
  219. <para><filename>Include_Guard.bsh</filename></para>
  220. <abstract><para>
  221. Intended for C/C++ header files, this macro inserts a preprocessor
  222. directive in the current buffer to ensure that the header is
  223. included only once per compilation unit.
  224. </para></abstract>
  225. <para>
  226. To use the macro, first place the caret at the beginning of the
  227. header file before any uncommented text. The macro will return to
  228. this position upon completion. The defined term that triggers the
  229. <quote>include guard</quote> is taken from the buffer's name.
  230. </para>
  231. </listitem>
  232. <listitem>
  233. <para><filename>Make_Bug_Report.bsh</filename></para>
  234. <abstract><para>
  235. Creates a new buffer with installation and error information
  236. extracted from the activity log.
  237. </para></abstract>
  238. <para>
  239. The macro extracts initial messages written to the activity log
  240. describing the user's operating system, JDK, jEdit version and
  241. installed plugins. It then appends the last set of error messages
  242. written to the activity log. The new text buffer can be saved and
  243. attached to an email message or a bug report made on SourceForge.
  244. </para>
  245. </listitem>
  246. <listitem>
  247. <para><filename>Run_Script.bsh</filename></para>
  248. <abstract><para>
  249. Runs script using interpreter based upon buffer's editing mode
  250. (by default, determined using file extension). You must have the
  251. appropriate interpreter (such as Perl, Python, or Windows Script Host)
  252. installed on your system.
  253. </para></abstract>
  254. </listitem>
  255. <listitem>
  256. <para><filename>Show_Threads.bsh</filename></para>
  257. <abstract><para>
  258. Displays in a tree format all running Java threads of the current
  259. Java Virtual Machine.
  260. </para></abstract>
  261. </listitem>
  262. <listitem>
  263. <para><filename>Write_HyperSearch_Results.bsh</filename></para>
  264. <abstract><para>
  265. This macro writes the contents of the <quote>HyperSearch
  266. Results</quote> window to a new buffer in
  267. a simple text report format.
  268. </para></abstract>
  269. </listitem>
  270. </itemizedlist>
  271. </sect1>
  272. <sect1 id="macros-text"><title>Text Macros</title>
  273. <para>
  274. These macros generate various forms of formatted text.
  275. </para>
  276. <itemizedlist>
  277. <listitem>
  278. <para><filename>Add_Prefix_and_Suffix.bsh</filename></para>
  279. <abstract><para>
  280. Adds user-supplied <quote>prefix</quote> and <quote>suffix</quote>
  281. text to each line in a group of selected lines.
  282. </para></abstract>
  283. <para>
  284. Text is added after leading whitespace and before trailing whitespace.
  285. A dialog window receives input and <quote>remembers</quote> past entries.
  286. </para>
  287. </listitem>
  288. <listitem>
  289. <para><filename>Color_Picker.bsh</filename></para>
  290. <abstract><para>
  291. Displays a color picker and inserts the selected color in
  292. hexadecimal format, prefixed with a <quote>#</quote>.
  293. </para></abstract>
  294. </listitem>
  295. <listitem>
  296. <para><filename>Duplicate_Line.bsh</filename></para>
  297. <abstract><para>
  298. Duplicates the line on which the caret lies immediately
  299. beneath it and moves the caret to the new line.
  300. </para></abstract>
  301. </listitem>
  302. <listitem>
  303. <para><filename>Insert_Date.bsh</filename></para>
  304. <abstract><para>
  305. Inserts the current date and time in the current buffer.
  306. </para></abstract>
  307. <para>
  308. The inserted text includes a representation of the time in the
  309. <quote>Internet Time</quote> format.
  310. </para>
  311. </listitem>
  312. <listitem>
  313. <para><filename>Insert_Tag.bsh</filename></para>
  314. <abstract><para>
  315. Inserts a balanced pair of HTML/SGML/XML markup tags as supplied
  316. in a input dialog. The tags will surround any selected text.
  317. </para></abstract>
  318. </listitem>
  319. <listitem>
  320. <para><filename>Next_Char.bsh</filename></para>
  321. <abstract><para>
  322. Finds next occurrence of character on current line.
  323. </para></abstract>
  324. <para>
  325. The macro takes the next character typed after macro execution
  326. as the character being searched. That character is not
  327. displayed. If the character does not appear in the balance of
  328. the current line, no action occurs.
  329. </para>
  330. <para>
  331. This macro illustrates the use of
  332. <function>InputHandler.readNextChar()</function> as a means of
  333. obtaining user input. See <xref linkend="macro-tips-single-char"
  334. />.
  335. </para>
  336. </listitem>
  337. <listitem>
  338. <para><filename>Toggle_Line_Comment.bsh</filename></para>
  339. <abstract><para>
  340. Toggles line comments, alternately inserting and deleting them
  341. at the beginning of each selected line. If there is no selection,
  342. the macro operates on the current line.
  343. </para></abstract>
  344. <para>
  345. A <quote>line comment</quote> is a token that designates the entire
  346. contents of a line as commented text; it does not use or require
  347. a closing token. If the editing mode does not provide for line
  348. comments (for example, text or XML modes), the macro will
  349. display an error message.
  350. </para>
  351. </listitem>
  352. </itemizedlist>
  353. </sect1>
  354. </appendix>