PageRenderTime 48ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-1-pre5/doc/users-guide/macro-index.xml

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