PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
XML | 733 lines | 623 code | 105 blank | 5 comment | 0 complexity | 9b620a86d9649ea8d20a90d03204b8d3 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-clipboard"><title>Clipboard Macros</title>
  21. <para>
  22. These macros copy or cut text to the clipboard.
  23. </para>
  24. <itemizedlist>
  25. <listitem>
  26. <para><filename>Copy_Lines_Containing.bsh</filename></para>
  27. <para>
  28. Copies all lines from the current buffer, containing a
  29. user-supplied string, to the clipboard.
  30. </para>
  31. </listitem>
  32. <listitem>
  33. <para><filename>Cut_Lines_Containing.bsh</filename></para>
  34. <para>
  35. Cuts all lines from the current buffer, containing a
  36. user-supplied string, to the clipboard.
  37. </para>
  38. </listitem>
  39. <listitem>
  40. <para><filename>Copy_Selection_or_Line.bsh</filename></para>
  41. <para>
  42. If no text is selected, the current line is copied to
  43. the clipboard, otherwise the selected text is copied
  44. to the clipboard. Some editors have this has the default copy behavior. To achieve the same effect in jEdit, bind this macro to <keycap>C+c</keycap> in the <guibutton>Shortcuts</guibutton> pane of the <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem> dialog box.
  45. </para>
  46. </listitem>
  47. <listitem>
  48. <para><filename>Cut_Selection_or_Line.bsh</filename></para>
  49. <para>
  50. If no text is selected, the current line is cut to the clipboard,
  51. otherwise the selected text is cut to the clipboard. Some editors have this has the default cut behavior. To achieve the same effect in jEdit, bind this macro to <keycap>C+x</keycap> in the <guibutton>Shortcuts</guibutton> pane of the <guimenu>Utilities</guimenu>&gt;<guimenuitem>Global Options</guimenuitem> dialog box.
  52. </para>
  53. </listitem>
  54. <listitem>
  55. <para><filename>Copy_Visible_Lines.bsh</filename></para>
  56. <para>Copies the visible lines from the current
  57. buffer to the Clipboard. Lines that are not visible
  58. becuase they are folded are not copied.
  59. </para>
  60. </listitem>
  61. </itemizedlist>
  62. </sect1>
  63. <sect1 id="macros-editing"><title>Editing Macros</title>
  64. <para>
  65. These macros automate various text editing tasks.
  66. </para>
  67. <itemizedlist>
  68. <listitem>
  69. <para><filename>Emacs_Next_Line.bsh</filename></para>
  70. <para>
  71. Moves the cursor to the next line, centering
  72. the current line in the middle of the text area
  73. if the cursor is at the bottom of the text area.
  74. </para>
  75. </listitem>
  76. <listitem>
  77. <para><filename>Emacs_Previous_Line.bsh</filename></para>
  78. <para>
  79. Moves the cursor to the previous line, centering
  80. the current line in the middle of the text area
  81. if the cursor is at the top of the text area.
  82. </para>
  83. </listitem>
  84. <listitem>
  85. <para><filename>Go_to_Column.bsh</filename></para>
  86. <para>
  87. Prompts the user for a column position on the
  88. current line, then moves the caret there.
  89. </para>
  90. </listitem>
  91. <listitem>
  92. <para><filename>Greedy_Backspace.bsh</filename></para>
  93. <para>
  94. If buffer is using soft tabs, this macro will backspace
  95. to the previous tab stop, if all characters between the
  96. caret and the tab stop are spaces. In all other cases a
  97. single character is removed.
  98. </para>
  99. </listitem>
  100. <listitem>
  101. <para><filename>Greedy_Delete.bsh</filename></para>
  102. <para>
  103. If a buffer is using soft tabs, this macro will
  104. delete tabSize number of spaces, if all the characters
  105. between the caret and the next tab stop are spaces. In
  106. all other cases a single character is deleted.
  107. </para>
  108. </listitem>
  109. <listitem>
  110. <para><filename>Greedy_Left.bsh</filename></para>
  111. <para>
  112. If a buffer is using soft tabs, this macro
  113. will move the caret tabSize spaces to the left,
  114. if all the characters between the caret and the previous
  115. tab stop are all spaces. In all other cases, the caret
  116. is moved a single character to the left.
  117. </para>
  118. </listitem>
  119. <listitem>
  120. <para><filename>Greedy_Right.bsh</filename></para>
  121. <para>
  122. If a buffer is using soft tabs, this macro will
  123. move the caret tabSize spaces to the right,
  124. if all the characters between the caret and the next
  125. tab stop are all spaces. In all other cases, the caret
  126. is moved a single character to the right.
  127. </para>
  128. </listitem>
  129. <listitem>
  130. <para><filename>Keywords_to_Upper_Case.bsh</filename></para>
  131. <para>
  132. Converts all keywords in the current buffer to upper case.
  133. </para>
  134. </listitem>
  135. <listitem>
  136. <para><filename>Mode_Switcher.bsh</filename></para>
  137. <para>
  138. Displays a modal dialog with the current buffer's mode in a text field,
  139. allowing one to change the mode by typing in its name.
  140. </para>
  141. <para>
  142. <keycap>ENTER</keycap> selects the current mode; if the text is not a
  143. valid mode, the dialog still dismisses, but a warning is logged to the
  144. activity log.
  145. <keycap>ESACPE</keycap> closes the dialog with no further action.
  146. <keycap>TAB</keycap> attempts to auto-complete the mode name. Pressing
  147. <keycap>TAB</keycap> repeatedly cycles through the possible completions.
  148. <keycap>SHIFT-TAB</keycap> cycles through the completions in reverse.
  149. </para>
  150. </listitem>
  151. <listitem>
  152. <para><filename>Move_Line_Down.bsh</filename></para>
  153. <para>Moves the current line down one, with automatic
  154. indentation.</para>
  155. </listitem>
  156. <listitem>
  157. <para><filename>Move_Line_Up.bsh</filename></para>
  158. <para>Moves the current line up one, with automatic
  159. indentation.</para>
  160. </listitem>
  161. </itemizedlist>
  162. </sect1>
  163. <sect1 id="macros-files"><title>File Management Macros</title>
  164. <para>
  165. These macros automate the opening and closing of files.
  166. </para>
  167. <itemizedlist>
  168. <listitem>
  169. <para><filename>Browse_Directory.bsh</filename></para>
  170. <para>
  171. Opens a directory supplied by the user in the file system
  172. browser.
  173. </para>
  174. </listitem>
  175. <listitem>
  176. <para><filename>Buffer_Switcher.bsh</filename></para>
  177. <para>
  178. Displays a modal dialog listing all open buffers,
  179. allowing one to switch to and/or close buffers.
  180. <keycap>ENTER</keycap> switches to a buffer and closes the dialog,
  181. <keycap>DELETE</keycap> closes a buffer, <keycap>SPACE</keycap>
  182. switches to a buffer but does not close the dialog.
  183. </para>
  184. </listitem>
  185. <listitem>
  186. <para><filename>Close_All_Except_Active.bsh</filename></para>
  187. <para>
  188. Closes all files except the current buffer.
  189. </para>
  190. <para>
  191. Prompts the user to save any buffer containing unsaved changes.
  192. </para>
  193. </listitem>
  194. <listitem>
  195. <para><filename>Copy_Path_to_Clipboad.bsh</filename></para>
  196. <para>Copies the current buffer's path
  197. to the clipboard.
  198. </para>
  199. </listitem>
  200. <listitem>
  201. <para><filename>Copy_Name_to_Clipboad.bsh</filename></para>
  202. <para>Copies the current buffer's filename
  203. to the clipboard.
  204. </para>
  205. </listitem>
  206. <listitem>
  207. <para><filename>Delete_Current.bsh</filename></para>
  208. <para>
  209. Deletes the current buffer's file on disk, but
  210. doesn't close the buffer.
  211. </para>
  212. </listitem>
  213. <listitem>
  214. <para><filename>Glob_Close.bsh</filename></para>
  215. <para>
  216. Closes all open buffers matching a given glob pattern.
  217. </para>
  218. </listitem>
  219. <listitem>
  220. <para><filename>Insert_Selection.bsh</filename></para>
  221. <para>Assumes the current selection is
  222. file path and tries replaces the selection with the
  223. contents of the file. Does nothing if no text is
  224. selected or the selection spans multiple lines.
  225. </para>
  226. </listitem>
  227. <listitem>
  228. <para><filename>Next_Dirty_Buffer.bsh</filename></para>
  229. <para>Switches to the next dirty buffer, if there is one.</para>
  230. </listitem>
  231. <listitem>
  232. <para><filename>Open_Path.bsh</filename></para>
  233. <para>
  234. Opens the file supplied by the user in an input dialog.
  235. </para>
  236. </listitem>
  237. <listitem>
  238. <para><filename>Open_Selection.bsh</filename></para>
  239. <para>
  240. Opens the file named by the current buffer's selected text.
  241. </para>
  242. </listitem>
  243. <listitem>
  244. <para><filename>Toggle_ReadOnly.bsh</filename></para>
  245. <para>
  246. Toggles a local file's read-only flag. Uses platform-specific commands, so it only works on Windows, Unix and MacOS X.
  247. </para>
  248. </listitem>
  249. </itemizedlist>
  250. </sect1>
  251. <sect1 id="macros-interface"><title>User Interface Macros</title>
  252. <para>
  253. Description.
  254. </para>
  255. <itemizedlist>
  256. <listitem>
  257. <para><filename>Decrease_Font_Size.bsh</filename></para>
  258. <para>
  259. Decreases the font size in the gutter and text area by 1 point.
  260. </para>
  261. </listitem>
  262. <listitem>
  263. <para><filename>Increase_Font_Size.bsh</filename></para>
  264. <para>
  265. Increases the font size in the gutter and text area by 1 point.
  266. </para>
  267. </listitem>
  268. <listitem>
  269. <para><filename>Open_Context_Menu.bsh</filename></para>
  270. <para>
  271. Opens the text area context menu just below and to
  272. the right of the caret.
  273. </para>
  274. </listitem>
  275. <listitem>
  276. <para><filename>Toggle_Bottom_Docking_Area.bsh</filename></para>
  277. <para>
  278. Expands or collapses the bottom docking area,
  279. depending on it's current state.
  280. </para>
  281. </listitem>
  282. <listitem>
  283. <para><filename>Toggle_Left_Docking_Area.bsh</filename></para>
  284. <para>
  285. Expands or collapses the left docking area,
  286. depending on it's current state.
  287. </para>
  288. </listitem>
  289. <listitem>
  290. <para><filename>Toggle_Right_Docking_Area.bsh</filename></para>
  291. <para>
  292. Expands or collapses the right docking area,
  293. depending on it's current state.
  294. </para>
  295. </listitem>
  296. <listitem>
  297. <para><filename>Toggle_Top_Docking_Area.bsh</filename></para>
  298. <para>
  299. Expands or collapses the top docking area,
  300. depending on it's current state.
  301. </para>
  302. </listitem>
  303. </itemizedlist>
  304. </sect1>
  305. <sect1 id="macros-java"><title>Java Code Macros</title>
  306. <para>
  307. These macros handle text formatting and generation tasks that are
  308. particularly useful in writing Java code.
  309. </para>
  310. <itemizedlist>
  311. <listitem>
  312. <para><filename>Create_Constructor.bsh</filename></para>
  313. <para>
  314. Inserts constructor for the class at the current caret position.
  315. </para>
  316. </listitem>
  317. <listitem>
  318. <para><filename>Get_Class_Name.bsh</filename></para>
  319. <para>
  320. Inserts a Java class name based upon the buffer's file name.
  321. </para>
  322. </listitem>
  323. <listitem>
  324. <para><filename>Get_Package_Name.bsh</filename></para>
  325. <para>
  326. Inserts a plausible Java package name for the current buffer.
  327. </para>
  328. <para>
  329. The macro compares the buffer's path name with the elements of the
  330. classpath being used by the jEdit session. An error message will be
  331. displayed if no suitable package name is found. This macro will not
  332. work if jEdit is being run as a JAR file without specifying a
  333. classpath; in that case the classpath seen by the macro consists
  334. solely of the JAR file.
  335. </para>
  336. </listitem>
  337. <listitem>
  338. <para><filename>Java_File_Save.bsh</filename></para>
  339. <abstract><para>Acts as a wrapper script to the Save As action. If the buffer
  340. is a new file, it scans the first 250 lines for a Java class or interface
  341. declaration. On finding one, it extracts the appropriate filename to be
  342. used in the Save As dialog.</para></abstract>
  343. </listitem>
  344. <listitem>
  345. <para><filename>Make_Get_and_Set_Methods.bsh</filename></para>
  346. <para>
  347. Creates <function>getXXX()</function> or <function>setXXX()</function>
  348. methods that can be pasted into the buffer text.
  349. </para>
  350. <para>
  351. This macro presents a dialog that will <quote>grab</quote> the names
  352. of instance variables from the caret line of the current buffer
  353. and paste a corresponding <function>getXXX()</function> or
  354. <function>setXXX()</function> method to one of two text areas in the
  355. dialog. The text can be edited in the dialog and then pasted into the
  356. current buffer using the <guilabel>Insert...</guilabel> buttons. If
  357. the caret is set to a line containing something other than an instance
  358. variable, the text grabbing routine is likely to generate nonsense.
  359. </para>
  360. <para>
  361. As explained in the notes accompanying the source code, the macro
  362. uses a global variable which can be set to configure the macro to work
  363. with either Java or C++ code. When set for use with C++ code,
  364. the macro will also write (in commented text) definitions of
  365. <function>getXXX()</function> or <function>setXXX()</function>
  366. suitable for inclusion in a header file.
  367. </para>
  368. </listitem>
  369. <listitem>
  370. <para><filename>Preview_Javadoc_of_Buffer.bsh</filename></para>
  371. <para>
  372. Create and display API documentation for the current buffer.
  373. </para>
  374. <para>
  375. The macro includes various configuration variables you can change; see the comment at the beginning of the macro source for details.
  376. </para>
  377. </listitem>
  378. </itemizedlist>
  379. </sect1>
  380. <sect1 id="macros-misc"><title>Miscellaneous Macros</title>
  381. <para>
  382. While these macros do not fit easily into the other categories, they all provide
  383. interesting and useful functions.
  384. </para>
  385. <itemizedlist>
  386. <listitem>
  387. <para><filename>Display_Abbreviations.bsh</filename></para>
  388. <para>
  389. Displays the abbreviations registered for each of jEdit's
  390. editing modes.
  391. </para>
  392. <para>
  393. The macro provides a read-only view of the abbreviations
  394. contained in the <quote>Abbreviations</quote> option pane. Pressing
  395. a letter key will scroll the table to the first entry beginning with
  396. that letter. A further option is provided to write a selected mode's
  397. abbreviations or all abbreviations in a text buffer for printing as a
  398. reference. Notes in the source code listing point out some display options
  399. that are configured by modifying global variables.
  400. </para>
  401. </listitem>
  402. <listitem>
  403. <para><filename>Display_Actions.bsh</filename></para>
  404. <para>
  405. Displays a list of all the actions known to jEdit categorised by
  406. their action set.
  407. </para>
  408. <para>
  409. This macro can be a useful reference if you want to use the jEdit 4.2 action bar.
  410. </para>
  411. </listitem>
  412. <listitem>
  413. <para><filename>Display_Character_Code.bsh</filename></para>
  414. <para>
  415. Display int and hex values for the character at the caret,
  416. in the status bar.
  417. </para>
  418. </listitem>
  419. <listitem>
  420. <para><filename>Display_Shortcuts.bsh</filename></para>
  421. <para>
  422. Displays a sorted list of the keyboard shortcuts currently in effect.
  423. </para>
  424. <para>
  425. The macro provides a combined read-only view of command, macro
  426. and plugin shortcuts. Pressing a letter key will
  427. scroll the table to the first entry beginning with that letter.
  428. A further option is provided to write the shortcut assignments in a
  429. text buffer for printing as a reference. Notes in the source code
  430. listing point out some display options that are configured by
  431. modifying global variables.
  432. </para>
  433. </listitem>
  434. <listitem>
  435. <para><filename>Evaluate_Buffer_in_BeanShell.bsh</filename></para>
  436. <para>
  437. Evaluates contents of current buffer as a BeanShell script,
  438. and opens a new
  439. buffer to receive any text output.
  440. </para>
  441. <para>
  442. This is a quick way to test a macro script even before its text
  443. is saved to a file. Opening a new buffer for output is a precaution
  444. to prevent the macro from inadvertently erasing or overwriting
  445. itself. BeanShell scripts that operate on the contents of the
  446. current buffer will not work meaningfully when tested using this
  447. macro.
  448. </para>
  449. </listitem>
  450. <listitem>
  451. <para><filename>Hex_Convert.bsh</filename></para>
  452. <para>
  453. Converts byte characters to their hex equivalent, and vice versa.
  454. </para>
  455. </listitem>
  456. <listitem>
  457. <para><filename>HyperSearch_Results_to_Buffer.bsh</filename></para>
  458. <para>
  459. Writes HyperSeach results to a new buffer.
  460. </para>
  461. </listitem>
  462. <listitem>
  463. <para><filename>Include_Guard.bsh</filename></para>
  464. <para>
  465. Intended for C/C++ header files, this macro inserts a preprocessor
  466. directive in the current buffer to ensure that the header is
  467. included only once per compilation unit.
  468. </para>
  469. <para>
  470. To use the macro, first place the caret at the beginning of the
  471. header file before any uncommented text. The macro will return to
  472. this position upon completion. The defined term that triggers the
  473. <quote>include guard</quote> is taken from the buffer's name.
  474. </para>
  475. </listitem>
  476. <listitem>
  477. <para><filename>Make_Bug_Report.bsh</filename></para>
  478. <para>
  479. Creates a new buffer with installation and error information
  480. extracted from the activity log.
  481. </para>
  482. <para>
  483. The macro extracts initial messages written to the activity log
  484. describing the user's operating system, JDK, jEdit version and
  485. installed plugins. It then appends the last set of error messages
  486. written to the activity log. The new text buffer can be saved and
  487. attached to an email message or a bug report made on SourceForge.
  488. </para>
  489. </listitem>
  490. <listitem>
  491. <para><filename>Run_Script.bsh</filename></para>
  492. <para>
  493. Runs script using interpreter based upon buffer's editing mode
  494. (by default, determined using file extension). You must have the
  495. appropriate interpreter (such as Perl, Python, or Windows Script Host)
  496. installed on your system.
  497. </para>
  498. </listitem>
  499. <listitem>
  500. <para><filename>Show_Threads.bsh</filename></para>
  501. <para>
  502. Displays in a tree format all running Java threads of the current
  503. Java Virtual Machine.
  504. </para>
  505. </listitem>
  506. </itemizedlist>
  507. </sect1>
  508. <sect1 id="macros-properties"><title>Property Macros</title>
  509. <para>
  510. These macros produce lists or tables containing properties
  511. used by the Java platform or jEdit itself.
  512. </para>
  513. <itemizedlist>
  514. <listitem>
  515. <para><filename>Insert_Buffer_Properties.bsh</filename></para>
  516. <para>
  517. Inserts buffer-local properties into the current buffer.
  518. </para>
  519. <para>
  520. If the buffer's
  521. mode has a line comment defined, or comment start and end
  522. defined, the inserted properties will be commented out.
  523. </para>
  524. </listitem>
  525. <listitem>
  526. <para><filename>jEdit_Properties.bsh</filename></para>
  527. <para>
  528. Writes an unsorted list of jEdit properties in a new buffer.
  529. </para>
  530. </listitem>
  531. <listitem>
  532. <para><filename>Look_and_Feel_Properties.bsh</filename></para>
  533. <para>
  534. Writes an unsorted list of the names of Java Look and Feel
  535. properties in a new buffer.
  536. </para>
  537. </listitem>
  538. <listitem>
  539. <para><filename>System_Properties.bsh</filename></para>
  540. <para>
  541. Writes an unsorted list of all Java system properties in a new
  542. buffer.
  543. </para>
  544. </listitem>
  545. </itemizedlist>
  546. </sect1>
  547. <sect1 id="macros-text"><title>Text Macros</title>
  548. <para>
  549. These macros generate various forms of formatted text.
  550. </para>
  551. <itemizedlist>
  552. <listitem>
  553. <para><filename>Add_Prefix_and_Suffix.bsh</filename></para>
  554. <para>
  555. Adds user-supplied <quote>prefix</quote> and <quote>suffix</quote>
  556. text to each line in a group of selected lines.
  557. </para>
  558. <para>
  559. Text is added after leading whitespace and before trailing whitespace.
  560. A dialog window receives input and <quote>remembers</quote> past entries.
  561. </para>
  562. </listitem>
  563. <listitem>
  564. <para><filename>Color_Picker.bsh</filename></para>
  565. <para>
  566. Displays a color picker and inserts the selected color in
  567. hexadecimal format, prefixed with a <quote>#</quote>.
  568. </para>
  569. </listitem>
  570. <listitem>
  571. <para><filename>Duplicate_Line.bsh</filename></para>
  572. <para>
  573. Duplicates the line on which the caret lies immediately
  574. beneath it and moves the caret to the new line.
  575. </para>
  576. </listitem>
  577. <listitem>
  578. <para><filename>Insert_Date.bsh</filename></para>
  579. <para>
  580. Inserts the current date and time in the current buffer.
  581. </para>
  582. <para>
  583. The inserted text includes a representation of the time in the
  584. <quote>Internet Time</quote> format.
  585. </para>
  586. </listitem>
  587. <listitem>
  588. <para><filename>Insert_Tag.bsh</filename></para>
  589. <para>
  590. Inserts a balanced pair of HTML/SGML/XML markup tags as supplied
  591. in an input dialog. The tags will surround any selected text.
  592. </para>
  593. </listitem>
  594. <listitem>
  595. <para><filename>Next_Char.bsh</filename></para>
  596. <para>
  597. Finds next occurrence of character on current line.
  598. </para>
  599. <para>
  600. The macro takes the next character typed after macro execution
  601. as the character being searched. That character is not
  602. displayed. If the character does not appear in the balance of
  603. the current line, no action occurs.
  604. </para>
  605. <para>
  606. This macro illustrates the use of
  607. <function>InputHandler.readNextChar()</function> as a means of
  608. obtaining user input. See <xref linkend="macro-tips-single-char"
  609. />.
  610. </para>
  611. </listitem>
  612. <listitem>
  613. <para><filename>Reverse_Lines.bsh</filename></para>
  614. <para>
  615. Reverses the selected lines or the entire buffer if no
  616. lines are selected. Does not support Rectangular
  617. Selections.
  618. </para>
  619. </listitem>
  620. <listitem>
  621. <para><filename>Single_Space_Buffer.bsh</filename></para>
  622. <para>
  623. Removes every second line, if they are all blank.
  624. </para>
  625. </listitem>
  626. </itemizedlist>
  627. </sect1>
  628. </appendix>