PageRenderTime 34ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

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

#
XML | 2353 lines | 2081 code | 264 blank | 8 comment | 0 complexity | 1c4327a1562dcbbc47f96f141e5a7b52 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 3.2 Macro Guide, (C) 2001 John Gellene -->
  2. <!-- Thu Jun 21 23:49:14 EDT 2001 @200 /Internet Time/ -->
  3. <!-- -->
  4. <!-- jEdit buffer-local properties: -->
  5. <!-- :indentSize=1:noTabs=yes:maxLineLen=72:tabSize=2: -->
  6. <!-- -->
  7. <!-- This file contains the jEdit API Quick Reference -->
  8. <chapter id="api-guide"><title>General jEdit Classes</title>
  9. <sect1 id="class-jedit"><title>Class jEdit</title>
  10. <para>
  11. This is the main class of the application. All the methods in this
  12. class are static methods, so
  13. they are called with the following syntax, from both macros and
  14. plugins:
  15. </para>
  16. <programlisting>jEdit.<replaceable>method</replaceable>(<replaceable>parameters</replaceable>)
  17. </programlisting>
  18. <para>
  19. Here are a few key methods:
  20. </para>
  21. <itemizedlist>
  22. <listitem>
  23. <funcsynopsis>
  24. <funcprototype>
  25. <funcdef>public static Buffer <function>openFile</function></funcdef>
  26. <paramdef>View <parameter>view</parameter></paramdef>
  27. <paramdef>String <parameter>path</parameter></paramdef>
  28. </funcprototype>
  29. </funcsynopsis>
  30. <para>
  31. Opens the file named <varname>path</varname> in the given
  32. <classname>View</classname>. To open a file in the current view, use the
  33. predefined variable <varname>view</varname> for the first parameter.
  34. </para>
  35. </listitem>
  36. <listitem>
  37. <funcsynopsis>
  38. <funcprototype>
  39. <funcdef>public static Buffer <function>newFile</function></funcdef>
  40. <paramdef>View <parameter>view</parameter></paramdef>
  41. </funcprototype>
  42. </funcsynopsis>
  43. <para>
  44. This creates a new buffer captioned
  45. <guimenu>Untitled-&lt;n&gt;</guimenu>in the given
  46. <classname>View</classname>.
  47. </para>
  48. </listitem>
  49. <listitem>
  50. <funcsynopsis>
  51. <funcprototype>
  52. <funcdef>public static boolean <function>closeBuffer</function></funcdef>
  53. <paramdef>View <parameter>view</parameter></paramdef>
  54. <paramdef>Buffer <parameter>buffer</parameter></paramdef>
  55. </funcprototype>
  56. </funcsynopsis>
  57. <para>
  58. Closes the buffer named <varname>buffer</varname> in the view named
  59. <varname>view</varname>. The user will be prompted to save the buffer
  60. before closing if there are unsaved changes.
  61. </para>
  62. </listitem>
  63. <listitem>
  64. <funcsynopsis>
  65. <funcprototype>
  66. <funcdef>public static void <function>saveAllBuffers</function></funcdef>
  67. <paramdef>View <parameter>view</parameter></paramdef>
  68. <paramdef>boolean <parameter>confirm</parameter></paramdef>
  69. </funcprototype>
  70. </funcsynopsis>
  71. <para>
  72. This saves all open buffers with unsaved changes in the given
  73. <classname>View</classname>. The parameter <parameter>confirm</parameter>
  74. determines whether jEdit initially asks for confirmation of the save
  75. operation.
  76. </para>
  77. </listitem>
  78. <listitem>
  79. <funcsynopsis>
  80. <funcprototype>
  81. <funcdef>public static boolean <function>closeAllBuffers</function></funcdef>
  82. <paramdef>View <parameter>view</parameter></paramdef>
  83. </funcprototype>
  84. </funcsynopsis>
  85. <para>
  86. Closes all buffers in the given <classname>View</classname>. A dialog
  87. window will be displayed for any buffers with unsaved changes to
  88. obtain user instructions.
  89. </para>
  90. </listitem>
  91. <listitem>
  92. <funcsynopsis>
  93. <funcprototype>
  94. <funcdef>public static void <function>exit</function></funcdef>
  95. <paramdef>View <parameter>view</parameter></paramdef>
  96. <paramdef>boolean <parameter>reallyExit</parameter></paramdef>
  97. </funcprototype>
  98. </funcsynopsis>
  99. <para>
  100. This method causes jEdit to exit. If <parameter>reallyExit</parameter> is
  101. false and jEdit is running in background mode, the application will simply
  102. close all buffers and views and remain in background mode.
  103. </para>
  104. </listitem>
  105. <listitem>
  106. <funcsynopsis>
  107. <funcprototype>
  108. <funcdef>public static String <function>getProperty</function></funcdef>
  109. <paramdef>String <parameter>name</parameter></paramdef>
  110. </funcprototype>
  111. </funcsynopsis>
  112. <para>
  113. Returns the value of the property named by <varname>name</varname>, or
  114. <constant>null</constant> if the property is undefined.
  115. </para>
  116. </listitem>
  117. <listitem>
  118. <funcsynopsis>
  119. <funcprototype>
  120. <funcdef>public static void <function>setProperty</function></funcdef>
  121. <paramdef>String <parameter>name</parameter></paramdef>
  122. <paramdef>String <parameter>property</parameter></paramdef>
  123. </funcprototype>
  124. </funcsynopsis>
  125. <para>
  126. Sets the property named by <varname>name</varname> with the value
  127. <varname>property</varname>. An existing property is overwritten.
  128. </para>
  129. </listitem>
  130. <listitem>
  131. <funcsynopsis>
  132. <funcprototype>
  133. <funcdef>public static boolean <function>getBooleanProperty</function></funcdef>
  134. <paramdef>String <parameter>name</parameter></paramdef>
  135. </funcprototype>
  136. </funcsynopsis>
  137. <para>
  138. Returns a <classname>boolean</classname> value of <constant>true</constant> or
  139. <constant>false</constant> for the property named by <varname>name</varname> by
  140. examining the contents of the property; returns
  141. <constant>false</constant> if the property cannot be found.
  142. </para>
  143. </listitem>
  144. <listitem>
  145. <funcsynopsis>
  146. <funcprototype>
  147. <funcdef>public static void <function>setBooleanProperty</function></funcdef>
  148. <paramdef>String <parameter>name</parameter></paramdef>
  149. <paramdef>boolean <parameter>value</parameter></paramdef>
  150. </funcprototype>
  151. </funcsynopsis>
  152. <para>
  153. Sets the property named by <varname>name</varname> to
  154. <varname>value</varname>. The boolean value is stored internally as the
  155. string <quote>true</quote> or <quote>false</quote>.
  156. </para>
  157. </listitem>
  158. <listitem>
  159. <funcsynopsis>
  160. <funcprototype>
  161. <funcdef>public static int <function>getIntegerProperty</function></funcdef>
  162. <paramdef>String <parameter>name</parameter></paramdef>
  163. <paramdef>int <parameter>defaultValue</parameter></paramdef>
  164. </funcprototype>
  165. </funcsynopsis>
  166. <para>
  167. Returns the integer value of the property named by
  168. <varname>name</varname>. If the property value is not a valid
  169. numeric string, returns <varname>defaultValue</varname> instead.
  170. </para>
  171. </listitem>
  172. <listitem>
  173. <funcsynopsis>
  174. <funcprototype>
  175. <funcdef>public static void <function>setIntegerProperty</function></funcdef>
  176. <paramdef>String <parameter>name</parameter></paramdef>
  177. <paramdef>int <parameter>value</parameter></paramdef>
  178. </funcprototype>
  179. </funcsynopsis>
  180. <para>
  181. Sets the property named by <varname>name</varname> to
  182. <varname>value</varname>.
  183. </para>
  184. </listitem>
  185. <listitem>
  186. <funcsynopsis>
  187. <funcprototype>
  188. <funcdef>public static Color <function>getColorProperty</function></funcdef>
  189. <paramdef>String <parameter>name</parameter></paramdef>
  190. </funcprototype>
  191. </funcsynopsis>
  192. <para>
  193. Returns the value of the specified property as a
  194. <classname>java.awt.Color</classname> instance, or <constant>null</constant>
  195. if the color value cannot be parsed.
  196. </para>
  197. </listitem>
  198. <listitem>
  199. <funcsynopsis>
  200. <funcprototype>
  201. <funcdef>public static void <function>setColorProperty</function></funcdef>
  202. <paramdef>String <parameter>name</parameter></paramdef>
  203. <paramdef>Color <parameter>value</parameter></paramdef>
  204. </funcprototype>
  205. </funcsynopsis>
  206. <para>
  207. Sets the property named by <varname>name</varname> to
  208. the textual representation of the color instance named by
  209. <varname>value</varname>.
  210. </para>
  211. </listitem>
  212. <listitem>
  213. <funcsynopsis>
  214. <funcprototype>
  215. <funcdef>public static Font <function>getFontProperty</function></funcdef>
  216. <paramdef>String <parameter>name</parameter></paramdef>
  217. </funcprototype>
  218. </funcsynopsis>
  219. <para>
  220. Returns the value of the specified property as a
  221. <classname>java.awt.Font</classname> instance, or <constant>null</constant>
  222. if the font specification cannot be parsed.
  223. </para>
  224. </listitem>
  225. <listitem>
  226. <funcsynopsis>
  227. <funcprototype>
  228. <funcdef>public static void <function>setFontProperty</function></funcdef>
  229. <paramdef>String <parameter>name</parameter></paramdef>
  230. <paramdef>Font <parameter>value</parameter></paramdef>
  231. </funcprototype>
  232. </funcsynopsis>
  233. <para>
  234. Sets the property named by <varname>name</varname> to
  235. the textual representation of the font instance stored in
  236. <varname>value</varname>.
  237. </para>
  238. </listitem>
  239. <listitem>
  240. <funcsynopsis>
  241. <funcprototype>
  242. <funcdef>public static void <function>setTemporaryProperty</function></funcdef>
  243. <paramdef>String <parameter>name</parameter></paramdef>
  244. <paramdef>String <parameter>property</parameter></paramdef>
  245. </funcprototype>
  246. </funcsynopsis>
  247. <para>
  248. This sets a property that will be stored during the current
  249. jEdit session only. This method is useful for storing a value
  250. obtained by one macro for use by another macro, because it does not
  251. clutter up the user properties file on disk.
  252. </para>
  253. </listitem>
  254. <listitem>
  255. <funcsynopsis>
  256. <funcprototype>
  257. <funcdef>public static String <function>getJEditHome</function></funcdef>
  258. <void/>
  259. </funcprototype>
  260. </funcsynopsis>
  261. <para>
  262. Returns the path of the directory containing the jEdit executable file.
  263. </para>
  264. </listitem>
  265. <listitem>
  266. <funcsynopsis>
  267. <funcprototype>
  268. <funcdef>public static String <function>getSettingsDirectory</function></funcdef>
  269. <void/>
  270. </funcprototype>
  271. </funcsynopsis>
  272. <para>
  273. Returns the path of the directory in which user-specific settings
  274. are stored. This will be <constant>null</constant> if jEdit was
  275. started with the
  276. <command>-nosettings</command> command-line switch; so do not
  277. blindly use this method without checking for a null return value
  278. first.
  279. </para>
  280. </listitem>
  281. </itemizedlist>
  282. <para>The jEdit object also maintains a number of collections which
  283. are useful in some situations. They include the following:</para>
  284. <itemizedlist>
  285. <listitem>
  286. <funcsynopsis>
  287. <funcprototype>
  288. <funcdef>public static EditAction[] <function>getActions</function></funcdef>
  289. <void/>
  290. </funcprototype>
  291. </funcsynopsis>
  292. <para>
  293. Returns an array of <quote>actions</quote> or short routines maintained and used
  294. by the editor.
  295. </para>
  296. </listitem>
  297. <listitem>
  298. <funcsynopsis>
  299. <funcprototype>
  300. <funcdef>public static EditAction <function>getAction</function></funcdef>
  301. <paramdef>String <parameter>action</parameter></paramdef>
  302. </funcprototype>
  303. </funcsynopsis>
  304. <para>
  305. Returns the action named <varname>action</varname>, or
  306. <constant>null</constant> if it does not exist.
  307. </para>
  308. </listitem>
  309. <listitem>
  310. <funcsynopsis>
  311. <funcprototype>
  312. <funcdef>public static Properties <function>getProperties</function></funcdef>
  313. <void/>
  314. </funcprototype>
  315. </funcsynopsis>
  316. <para>
  317. Returns a Java <classname>Properties</classname> object (a class derived from
  318. <classname>Hashtable</classname>) holding all properties
  319. currently used by the program. The constituent properties fall into three
  320. categories: application properties, <quote>site</quote> properties, and
  321. <quote>user</quote> properties. Site properties take precedence over application
  322. properties with the same <quote>key</quote> or name, and user properties take
  323. precedence over both application and site properties. User settings are
  324. written to a file named <filename>properties</filename> in the user settings
  325. directory upon program exit or whenever <function>jEdit.saveSettings()</function>
  326. is called.
  327. </para>
  328. </listitem>
  329. <listitem>
  330. <funcsynopsis>
  331. <funcprototype>
  332. <funcdef>public static Buffer[] <function>getBuffers</function></funcdef>
  333. <void/>
  334. </funcprototype>
  335. </funcsynopsis>
  336. <para>
  337. Returns an array of open buffers.
  338. </para>
  339. </listitem>
  340. <listitem>
  341. <funcsynopsis>
  342. <funcprototype>
  343. <funcdef>public static int <function>getBufferCount</function></funcdef>
  344. <void/>
  345. </funcprototype>
  346. </funcsynopsis>
  347. <para>
  348. Returns the number of open buffers.
  349. </para>
  350. </listitem>
  351. <listitem>
  352. <funcsynopsis>
  353. <funcprototype>
  354. <funcdef>public static Buffer <function>getBuffer</function></funcdef>
  355. <paramdef>String <parameter>path</parameter></paramdef>
  356. </funcprototype>
  357. </funcsynopsis>
  358. <para>
  359. Returns the <classname>Buffer</classname> object containing the file named
  360. <varname>path</varname>. or <constant>null</constant> if the buffer does not exist.
  361. </para>
  362. </listitem>
  363. <listitem>
  364. <funcsynopsis>
  365. <funcprototype>
  366. <funcdef>public static Mode[] <function>getModes</function></funcdef>
  367. <void/>
  368. </funcprototype>
  369. </funcsynopsis>
  370. <para>
  371. Returns an array containing all editing modes used by jEdit.
  372. </para>
  373. </listitem>
  374. <listitem>
  375. <funcsynopsis>
  376. <funcprototype>
  377. <funcdef>public static Mode <function>getMode</function></funcdef>
  378. <paramdef>String <parameter>name</parameter></paramdef>
  379. </funcprototype>
  380. </funcsynopsis>
  381. <para>
  382. Returns the editing mode named by <varname>name</varname>, or
  383. <constant>null</constant> if such a mode does not exist.
  384. </para>
  385. </listitem>
  386. <listitem>
  387. <funcsynopsis>
  388. <funcprototype>
  389. <funcdef>public static EditPlugin[] <function>getPlugins</function></funcdef>
  390. <void/>
  391. </funcprototype>
  392. </funcsynopsis>
  393. <para>
  394. Returns an array containing all loaded plugins.
  395. </para>
  396. </listitem>
  397. <listitem>
  398. <funcsynopsis>
  399. <funcprototype>
  400. <funcdef>plugin static EditPlugin <function>getPlugin</function></funcdef>
  401. <paramdef>String <parameter>name</parameter></paramdef>
  402. </funcprototype>
  403. </funcsynopsis>
  404. <para>
  405. Returns the plugin named by <varname>name</varname>, or
  406. <constant>null</constant> if such a plugin does not exist.
  407. </para>
  408. </listitem>
  409. </itemizedlist>
  410. </sect1>
  411. <sect1 id="class-view"><title>Class View</title>
  412. <para>
  413. This class represents the <quote>parent</quote> or top-level frame window
  414. in which the editing occurs. It contains the various visible
  415. components of the program, including the editing pane, menu bar,
  416. toolbar, and any docked windows.
  417. </para>
  418. <para>
  419. Some useful methods from this class include the following:
  420. </para>
  421. <itemizedlist>
  422. <listitem>
  423. <funcsynopsis>
  424. <funcprototype>
  425. <funcdef>public void <function>splitHorizontally</function></funcdef>
  426. <void/>
  427. </funcprototype>
  428. </funcsynopsis>
  429. <para>
  430. Splits the view horizontally.
  431. </para>
  432. </listitem>
  433. <listitem>
  434. <funcsynopsis>
  435. <funcprototype>
  436. <funcdef>public void <function>splitVertically</function></funcdef>
  437. <void/>
  438. </funcprototype>
  439. </funcsynopsis>
  440. <para>
  441. Splits the view vertically.
  442. </para>
  443. </listitem>
  444. <listitem>
  445. <funcsynopsis>
  446. <funcprototype>
  447. <funcdef>public void <function>unsplit</function></funcdef>
  448. <void/>
  449. </funcprototype>
  450. </funcsynopsis>
  451. <para>
  452. Unsplits the view.
  453. </para>
  454. </listitem>
  455. <listitem>
  456. <funcsynopsis>
  457. <funcprototype>
  458. <funcdef>public synchronized void <function>showWaitCursor</function></funcdef>
  459. <void/>
  460. </funcprototype>
  461. </funcsynopsis>
  462. <para>
  463. Shows a <quote>waiting</quote> cursor (typically, an hourglass).
  464. </para>
  465. </listitem>
  466. <listitem>
  467. <funcsynopsis>
  468. <funcprototype>
  469. <funcdef>public synchronized void <function>hideWaitCursor</function></funcdef>
  470. <void/>
  471. </funcprototype>
  472. </funcsynopsis>
  473. <para>
  474. Removes the <quote>waiting</quote> cursor. This method and
  475. <function>showWaitCursor()</function> are implemented using a reference
  476. count of requests for wait cursors, so that nested calls work
  477. correctly; however, you should
  478. be careful to use these methods in tandem.
  479. </para>
  480. </listitem>
  481. <listitem>
  482. <funcsynopsis>
  483. <funcprototype>
  484. <funcdef>public StatusBar <function>getStatus</function></funcdef>
  485. <void/>
  486. </funcprototype>
  487. </funcsynopsis>
  488. <para>
  489. Each <classname>View</classname> displays a
  490. <classname>StatusBar</classname> at its bottom edge. It shows the
  491. current cursor position, the editing mode of the current buffer and
  492. other information. The method <function>setMessage(String
  493. message)</function> can be called on the return value of
  494. <function>getStatus()</function> to display reminders or updates.
  495. The message remains until the method is called
  496. again. To display a temporary message in the status bar, call
  497. <function>setMessageAndClear(String message)</function>, which will
  498. erase the message automatically after ten seconds.
  499. </para>
  500. </listitem>
  501. <listitem>
  502. <funcsynopsis>
  503. <funcprototype>
  504. <funcdef>public DockableWindowManager <function>getDockableWindowManager</function></funcdef>
  505. <void/>
  506. </funcprototype>
  507. </funcsynopsis>
  508. <para>
  509. The object returned by this method keeps track of all dockable
  510. windows. See <xref linkend="class-dockablewindowmanager" />.
  511. </para>
  512. </listitem>
  513. </itemizedlist>
  514. </sect1>
  515. <sect1 id="class-jedittextarea"><title>Class JEditTextArea</title>
  516. <para>
  517. This class is the visible component that displays the file
  518. being edited. It is derived from Java's
  519. <classname>JComponent</classname> class.
  520. </para>
  521. <para>
  522. Methods in this class that deal with selecting text
  523. rely upon classes derived from jEdit's
  524. <classname>Selection</classname> class. The
  525. <quote>Selection API</quote> permits selection and concurrent manipulation
  526. of multiple, non-contiguous regions of text. After describing the
  527. selection classes, we will outline the selection methods
  528. of <classname>JEditTextArea</classname>, followed by a listing of
  529. other methods in this class that are useful in writing macros.
  530. </para>
  531. <sect2 id="class-selection"><title>Class Selection</title>
  532. <para>
  533. This is an <glossterm>abstract class</glossterm> which holds data
  534. on a region of selected text. As an abstract class, it cannot be used
  535. directly, but instead serves as a parent class for specific types
  536. of selection structures. The definition of
  537. <classname>Selection</classname> contains two child classes used by the
  538. Selection API:
  539. </para>
  540. <itemizedlist>
  541. <listitem>
  542. <para>
  543. <classname>Selection.Range</classname> - representing an ordinary
  544. range of selected text
  545. </para>
  546. </listitem>
  547. <listitem>
  548. <para>
  549. <classname>Selection.Rect</classname> - representing a rectangular
  550. selection region
  551. </para>
  552. </listitem>
  553. </itemizedlist>
  554. <para>
  555. A new instance of either type of <classname>Selection</classname>
  556. can be created by specifying its starting and ending caret positions:
  557. </para>
  558. <informalexample><programlisting>selRange = new Selection.Range(start, end);
  559. setRect = new Selection.Rect(start, end);</programlisting></informalexample>
  560. <para>
  561. Both classes inherit or implement the following methods of the parent
  562. <classname>Selection</classname> class:
  563. </para>
  564. <itemizedlist>
  565. <listitem>
  566. <funcsynopsis>
  567. <funcprototype>
  568. <funcdef>public int <function>getStart</function></funcdef>
  569. <void/>
  570. </funcprototype>
  571. </funcsynopsis>
  572. </listitem>
  573. <listitem>
  574. <funcsynopsis>
  575. <funcprototype>
  576. <funcdef>public int <function>getEnd</function></funcdef>
  577. <void/>
  578. </funcprototype>
  579. </funcsynopsis>
  580. <para>
  581. Retrieves the buffer position representing the start or end
  582. of the selection.
  583. </para>
  584. </listitem>
  585. <listitem>
  586. <funcsynopsis>
  587. <funcprototype>
  588. <funcdef>public int <function>getStartLine</function></funcdef>
  589. <void/>
  590. </funcprototype>
  591. </funcsynopsis>
  592. </listitem>
  593. <listitem>
  594. <funcsynopsis>
  595. <funcprototype>
  596. <funcdef>public int <function>getEndLine</function></funcdef>
  597. <void/>
  598. </funcprototype>
  599. </funcsynopsis>
  600. <para>
  601. Retrieves the zero-based index number representing the line
  602. on which the selection starts or ends.
  603. </para>
  604. </listitem>
  605. <listitem>
  606. <funcsynopsis>
  607. <funcprototype>
  608. <funcdef>public int <function>getStart</function></funcdef>
  609. <paramdef>Buffer <parameter>buffer</parameter></paramdef>
  610. <paramdef>int <parameter>line</parameter></paramdef>
  611. </funcprototype>
  612. </funcsynopsis>
  613. </listitem>
  614. <listitem>
  615. <funcsynopsis>
  616. <funcprototype>
  617. <funcdef>public int <function>getEnd</function></funcdef>
  618. <paramdef>Buffer <parameter>buffer</parameter></paramdef>
  619. <paramdef>int <parameter>line</parameter></paramdef>
  620. </funcprototype>
  621. </funcsynopsis>
  622. <para>
  623. These two methods return the position of the beginning or end of
  624. that portion of the selection falling on the line referenced by
  625. the <parameter>line</parameter> parameter. The parameter
  626. <parameter>buffer</parameter> is required because a
  627. <classname>Selection</classname> object is a lightweight structure
  628. that does not contain a reference to the
  629. <classname>Buffer</classname> object to which it relates.
  630. </para>
  631. <para>
  632. These methods do not check whether the <parameter>line</parameter>
  633. parameter is within the range of lines actually covered by the
  634. selection. They would typically be used within a
  635. loop defined by the <function>getStartLine()</function> and
  636. <function>getEndLine()</function> methods to manipulate
  637. selection text on a line-by-line basis. Using them without range
  638. checking could cause unintended behavior.
  639. </para>
  640. </listitem>
  641. </itemizedlist>
  642. </sect2>
  643. <sect2 id="class-jedittextarea-selection"><title>Selection methods in
  644. JEditTextArea</title>
  645. <para>
  646. A <classname>JEditTextArea</classname> object maintains an
  647. <classname>Vector</classname> of current <classname>Selection</classname>
  648. objects. When a selection is added, the <classname>JEditTextArea</classname>
  649. attempts to merge the new selection with any existing selection whose range
  650. contains or overlaps with the new item. When selections are added or
  651. removed using by these methods, the editing display is updated to show
  652. the change in selection status.
  653. </para>
  654. <para>
  655. Here are the principal methods of <classname>JEditTextArea</classname>
  656. dealing with <classname>Selection</classname> objects:
  657. </para>
  658. <sect3 id="class-jedittextarea-selection-add-remove">
  659. <title>Adding and removing selections</title>
  660. <itemizedlist>
  661. <listitem>
  662. <funcsynopsis>
  663. <funcprototype>
  664. <funcdef>public void <function>setMultipleSelectionEnabled</function></funcdef>
  665. <paramdef>boolean <parameter>multi</parameter></paramdef>
  666. </funcprototype>
  667. </funcsynopsis>
  668. <para>
  669. Set multiple selection on or off according to the value of
  670. <parameter>multi</parameter>. This only affects the ability to
  671. make multiple selections in the user interface; macros and plugins
  672. can manipulate them regardless of the setting of this flag. In fact,
  673. in most cases, calling this method should not be necessary.
  674. </para>
  675. </listitem>
  676. <listitem>
  677. <funcsynopsis>
  678. <funcprototype>
  679. <funcdef>public Selection[] <function>getSelection</function></funcdef>
  680. <void/>
  681. </funcprototype>
  682. </funcsynopsis>
  683. <para>
  684. Returns an array containing a copy of the current selections.
  685. </para>
  686. </listitem>
  687. <listitem>
  688. <funcsynopsis>
  689. <funcprototype>
  690. <funcdef>public int <function>getSelectionCount</function></funcdef>
  691. <void/>
  692. </funcprototype>
  693. </funcsynopsis>
  694. <para>
  695. Returns the current number of selections. This can be used to test
  696. for the existence of selections.
  697. </para>
  698. </listitem>
  699. <listitem>
  700. <funcsynopsis>
  701. <funcprototype>
  702. <funcdef>public Selection <function>getSelectionAtOffset</function></funcdef>
  703. <paramdef>int <parameter>offset</parameter></paramdef>
  704. </funcprototype>
  705. </funcsynopsis>
  706. <para>
  707. Returns the <classname>Selection</classname> containing the specific offset,
  708. or <constant>null</constant> if there is no selection at that offset.
  709. </para>
  710. </listitem>
  711. <listitem>
  712. <funcsynopsis>
  713. <funcprototype>
  714. <funcdef>public void <function>addToSelection</function></funcdef>
  715. <paramdef>Selection <parameter>selection</parameter></paramdef>
  716. </funcprototype>
  717. </funcsynopsis>
  718. </listitem>
  719. <listitem>
  720. <funcsynopsis>
  721. <funcprototype>
  722. <funcdef>public void <function>addToSelection</function></funcdef>
  723. <paramdef>Selection[] <parameter>selection</parameter></paramdef>
  724. </funcprototype>
  725. </funcsynopsis>
  726. <para>
  727. Adds a single <classname>Selection</classname> or an array of
  728. <classname>Selection</classname> objects to the existing collection
  729. maintained by the <classname>JEditTextArea</classname>. Nested or
  730. overlapping selections will be merged where possible.
  731. </para>
  732. </listitem>
  733. <listitem>
  734. <funcsynopsis>
  735. <funcprototype>
  736. <funcdef>public void <function>extendSelection</function></funcdef>
  737. <paramdef>int <parameter>offset</parameter></paramdef>
  738. <paramdef>int <parameter>end</parameter></paramdef>
  739. </funcprototype>
  740. </funcsynopsis>
  741. <para>
  742. Extends the existing selection containing the position at
  743. <parameter>offset</parameter> to the position represented by
  744. <parameter>end</parameter>. If there is no selection containing
  745. <parameter>offset</parameter> the method creates a new
  746. <classname>Selection.Range</classname> extending from
  747. <parameter>offset</parameter> to <parameter>end</parameter> and
  748. adds it to the current collection.
  749. </para>
  750. </listitem>
  751. <listitem>
  752. <funcsynopsis>
  753. <funcprototype>
  754. <funcdef>public void <function>removeFromSelection</function></funcdef>
  755. <paramdef>Selection <parameter>sel</parameter></paramdef>
  756. </funcprototype>
  757. </funcsynopsis>
  758. </listitem>
  759. <listitem>
  760. <funcsynopsis>
  761. <funcprototype>
  762. <funcdef>public void <function>removeFromSelection</function></funcdef>
  763. <paramdef>int <parameter>offset</parameter></paramdef>
  764. </funcprototype>
  765. </funcsynopsis>
  766. <para>
  767. These methods remove a selection from the current collection. The
  768. second version removes any selection that contains the position at
  769. <parameter>offset</parameter>, and has no effect if no such
  770. selection exists.
  771. </para>
  772. </listitem>
  773. </itemizedlist>
  774. </sect3>
  775. <sect3 id="class-jedittextarea-selection-text">
  776. <title>Getting and setting selected text</title>
  777. <itemizedlist>
  778. <listitem>
  779. <funcsynopsis>
  780. <funcprototype>
  781. <funcdef>public String <function>getSelectedText</function></funcdef>
  782. <paramdef>Selection <parameter>s</parameter></paramdef>
  783. </funcprototype>
  784. </funcsynopsis>
  785. </listitem>
  786. <listitem>
  787. <funcsynopsis>
  788. <funcprototype>
  789. <funcdef>public String <function>getSelectedText</function></funcdef>
  790. <paramdef>String <parameter>separator</parameter></paramdef>
  791. </funcprototype>
  792. </funcsynopsis>
  793. </listitem>
  794. <listitem>
  795. <funcsynopsis>
  796. <funcprototype>
  797. <funcdef>public String <function>getSelectedText</function></funcdef>
  798. <void/>
  799. </funcprototype>
  800. </funcsynopsis>
  801. <para>
  802. These three methods return a <classname>String</classname> containing
  803. text corresponding to the current selections. The first version returns
  804. the text corresponding to a particular selection named as the parameter,
  805. allowing for iteration through the collection or focus on a specific
  806. selection (such as a selection containing the current caret position).
  807. The second version combines all selection text in a single
  808. <classname>String</classname>, separated by the
  809. <classname>String</classname> given as the
  810. <parameter>separator</parameter>. The final version operates like the
  811. second version, separating individual selections with newline characters.
  812. </para>
  813. </listitem>
  814. <listitem>
  815. <funcsynopsis>
  816. <funcprototype>
  817. <funcdef>public void <function>setSelectedText</function></funcdef>
  818. <paramdef>Selection <parameter>s</parameter></paramdef>
  819. <paramdef>String <parameter>selectedText</parameter></paramdef>
  820. </funcprototype>
  821. </funcsynopsis>
  822. </listitem>
  823. <listitem>
  824. <funcsynopsis>
  825. <funcprototype>
  826. <funcdef>public void <function>setSelectedText</function></funcdef>
  827. <paramdef>String <parameter>selectedText</parameter></paramdef>
  828. </funcprototype>
  829. </funcsynopsis>
  830. <para>
  831. The first version changes the text of the selection represented
  832. by <parameter>s</parameter> to
  833. <parameter>selectedText</parameter>. The second version sets the
  834. text of all active selections; if there are no selections, the
  835. text will be inserted at the current caret position.
  836. </para>
  837. <para>
  838. The second version of <function>setSelectedText()</function> is
  839. the method that will typically be used in macro scripts to insert
  840. text.
  841. </para>
  842. </listitem>
  843. <listitem>
  844. <funcsynopsis>
  845. <funcprototype>
  846. <funcdef>public int[] <function>getSelectedLines</function></funcdef>
  847. <void/>
  848. </funcprototype>
  849. </funcsynopsis>
  850. <para>
  851. Returns a sorted array of line numbers on which a selection or selections
  852. are present.
  853. </para>
  854. <para>
  855. This method is the most convenient way to iterate through selected lines
  856. in a buffer. The line numbers in the array returned by this method can
  857. be passed as a parameter to such methods as
  858. <function>Buffer.getLineText()</function> (see
  859. <xref linkend="class-buffer-editing"/>).
  860. </para>
  861. </listitem>
  862. </itemizedlist>
  863. </sect3>
  864. <sect3 id="class-jedittextarea-selection-other">
  865. <title>Other selection methods</title>
  866. <para>
  867. The following methods perform selection operations without using
  868. <classname>Selection</classname> objects as parameters or return
  869. values. These methods should only be used in macros.
  870. </para>
  871. <itemizedlist>
  872. <listitem>
  873. <funcsynopsis>
  874. <funcprototype>
  875. <funcdef>public void <function>selectBlock</function></funcdef>
  876. <void/>
  877. </funcprototype>
  878. </funcsynopsis>
  879. <para>
  880. Selects the code block surrounding the caret.
  881. </para>
  882. </listitem>
  883. <listitem>
  884. <funcsynopsis>
  885. <funcprototype>
  886. <funcdef>public void <function>selectWord</function></funcdef>
  887. <void/>
  888. </funcprototype>
  889. </funcsynopsis>
  890. </listitem>
  891. <listitem>
  892. <funcsynopsis>
  893. <funcprototype>
  894. <funcdef>public void <function>selectLine</function></funcdef>
  895. <void/>
  896. </funcprototype>
  897. </funcsynopsis>
  898. </listitem>
  899. <listitem>
  900. <funcsynopsis>
  901. <funcprototype>
  902. <funcdef>public void <function>selectParagraph</function></funcdef>
  903. <void/>
  904. </funcprototype>
  905. </funcsynopsis>
  906. </listitem>
  907. <listitem>
  908. <funcsynopsis>
  909. <funcprototype>
  910. <funcdef>public void <function>selectFold</function></funcdef>
  911. <void/>
  912. </funcprototype>
  913. </funcsynopsis>
  914. <para>
  915. Selects the <quote>fold</quote> (a portion of text sharing a given
  916. indentation level) that contains the line where the editing caret
  917. is positioned.
  918. </para>
  919. </listitem>
  920. <listitem>
  921. <funcsynopsis>
  922. <funcprototype>
  923. <funcdef>public void <function>selectFoldAt</function></funcdef>
  924. <paramdef>int <parameter>line</parameter></paramdef>
  925. </funcprototype>
  926. </funcsynopsis>
  927. <para>
  928. Selects the fold containing the line referenced by
  929. <parameter>line</parameter>.
  930. </para>
  931. </listitem>
  932. <listitem>
  933. <funcsynopsis>
  934. <funcprototype>
  935. <funcdef>public void <function>selectAll</function></funcdef>
  936. <void/>
  937. </funcprototype>
  938. </funcsynopsis>
  939. </listitem>
  940. <listitem>
  941. <funcsynopsis>
  942. <funcprototype>
  943. <funcdef>public void <function>selectNone</function></funcdef>
  944. <void/>
  945. </funcprototype>
  946. </funcsynopsis>
  947. </listitem>
  948. <listitem>
  949. <funcsynopsis>
  950. <funcprototype>
  951. <funcdef>public void <function>indentSelectedLines</function></funcdef>
  952. <void/>
  953. </funcprototype>
  954. </funcsynopsis>
  955. </listitem>
  956. </itemizedlist>
  957. </sect3>
  958. </sect2>
  959. <sect2 id="class-jedittextarea-caret">
  960. <title>Editing caret methods</title>
  961. <para>
  962. These methods are used to get, set and move the position of the
  963. editing caret:
  964. </para>
  965. <itemizedlist>
  966. <listitem>
  967. <funcsynopsis>
  968. <funcprototype>
  969. <funcdef>public int <function>getCaretPosition</function></funcdef>
  970. <void/>
  971. </funcprototype>
  972. </funcsynopsis>
  973. <para>
  974. Returns a zero-based index of the caret position in the existing buffer.
  975. </para>
  976. </listitem>
  977. <listitem>
  978. <funcsynopsis>
  979. <funcprototype>
  980. <funcdef>public void <function>setCaretPosition</function></funcdef>
  981. <paramdef>int <parameter>caret</parameter></paramdef>
  982. </funcprototype>
  983. </funcsynopsis>
  984. <para>
  985. Sets the caret position at <parameter>caret</parameter> and deactivates
  986. any selection of text.
  987. </para>
  988. </listitem>
  989. <listitem>
  990. <funcsynopsis>
  991. <funcprototype>
  992. <funcdef>public void <function>moveCaretPosition</function></funcdef>
  993. <paramdef>int <parameter>caret</parameter></paramdef>
  994. </funcprototype>
  995. </funcsynopsis>
  996. <para>
  997. This moves the caret to the position represented by
  998. <parameter>caret</parameter> without affecting any selection of
  999. text.
  1000. </para>
  1001. </listitem>
  1002. <listitem>
  1003. <funcsynopsis>
  1004. <funcprototype>
  1005. <funcdef>public int <function>getCaretLine</function></funcdef>
  1006. <void/>
  1007. </funcprototype>
  1008. </funcsynopsis>
  1009. <para>
  1010. Returns the line on which the caret is positioned.
  1011. </para>
  1012. </listitem>
  1013. </itemizedlist>
  1014. <para>
  1015. Each of the following shortcut methods moves the caret. If the
  1016. <parameter>select</parameter> parameter is set to
  1017. <constant>true</constant>, the intervening text will be selected
  1018. as well.
  1019. </para>
  1020. <itemizedlist>
  1021. <listitem>
  1022. <funcsynopsis>
  1023. <funcprototype>
  1024. <funcdef>public void <function>goToStartOfLine</function></funcdef>
  1025. <paramdef>boolean <parameter>select</parameter></paramdef>
  1026. </funcprototype>
  1027. </funcsynopsis>
  1028. </listitem>
  1029. <listitem>
  1030. <funcsynopsis>
  1031. <funcprototype>
  1032. <funcdef>public void <function>goToEndOfLine</function></funcdef>
  1033. <paramdef>boolean <parameter>select</parameter></paramdef>
  1034. </funcprototype>
  1035. </funcsynopsis>
  1036. </listitem>
  1037. <listitem>
  1038. <funcsynopsis>
  1039. <funcprototype>
  1040. <funcdef>public void <function>goToStartOfWhiteSpace</function></funcdef>
  1041. <paramdef>boolean <parameter>select</parameter></paramdef>
  1042. </funcprototype>
  1043. </funcsynopsis>
  1044. </listitem>
  1045. <listitem>
  1046. <funcsynopsis>
  1047. <funcprototype>
  1048. <funcdef>public void <function>goToEndOfWhiteSpace</function></funcdef>
  1049. <paramdef>boolean <parameter>select</parameter></paramdef>
  1050. </funcprototype>
  1051. </funcsynopsis>
  1052. </listitem>
  1053. <listitem>
  1054. <funcsynopsis>
  1055. <funcprototype>
  1056. <funcdef>public void <function>goToFirstVisibleLine</function></funcdef>
  1057. <paramdef>boolean <parameter>select</parameter></paramdef>
  1058. </funcprototype>
  1059. </funcsynopsis>
  1060. </listitem>
  1061. <listitem>
  1062. <funcsynopsis>
  1063. <funcprototype>
  1064. <funcdef>public void <function>goToLastVisibleLine</function></funcdef>
  1065. <paramdef>boolean <parameter>select</parameter></paramdef>
  1066. </funcprototype>
  1067. </funcsynopsis>
  1068. </listitem>
  1069. <listitem>
  1070. <funcsynopsis>
  1071. <funcprototype>
  1072. <funcdef>public void <function>goToNextCharacter</function></funcdef>
  1073. <paramdef>boolean <parameter>select</parameter></paramdef>
  1074. </funcprototype>
  1075. </funcsynopsis>
  1076. </listitem>
  1077. <listitem>
  1078. <funcsynopsis>
  1079. <funcprototype>
  1080. <funcdef>public void <function>goToPrevCharacter</function></funcdef>
  1081. <paramdef>boolean <parameter>select</parameter></paramdef>
  1082. </funcprototype>
  1083. </funcsynopsis>
  1084. </listitem>
  1085. <listitem>
  1086. <funcsynopsis>
  1087. <funcprototype>
  1088. <funcdef>public void <function>goToNextWord</function></funcdef>
  1089. <paramdef>boolean <parameter>select</parameter></paramdef>
  1090. </funcprototype>
  1091. </funcsynopsis>
  1092. </listitem>
  1093. <listitem>
  1094. <funcsynopsis>
  1095. <funcprototype>
  1096. <funcdef>public void <function>goToPrevWord</function></funcdef>
  1097. <paramdef>boolean <parameter>select</parameter></paramdef>
  1098. </funcprototype>
  1099. </funcsynopsis>
  1100. </listitem>
  1101. <listitem>
  1102. <funcsynopsis>
  1103. <funcprototype>
  1104. <funcdef>public void <function>goToNextLine</function></funcdef>
  1105. <paramdef>boolean <parameter>select</parameter></paramdef>
  1106. </funcprototype>
  1107. </funcsynopsis>
  1108. </listitem>
  1109. <listitem>
  1110. <funcsynopsis>
  1111. <funcprototype>
  1112. <funcdef>public void <function>goToPrevLine</function></funcdef>
  1113. <paramdef>boolean <parameter>select</parameter></paramdef>
  1114. </funcprototype>
  1115. </funcsynopsis>
  1116. </listitem>
  1117. <listitem>
  1118. <funcsynopsis>
  1119. <funcprototype>
  1120. <funcdef>public void <function>goToNextParagraph</function></funcdef>
  1121. <paramdef>boolean <parameter>select</parameter></paramdef>
  1122. </funcprototype>
  1123. </funcsynopsis>
  1124. </listitem>
  1125. <listitem>
  1126. <funcsynopsis>
  1127. <funcprototype>
  1128. <funcdef>public void <function>goToPrevParagraph</function></funcdef>
  1129. <paramdef>boolean <parameter>select</parameter></paramdef>
  1130. </funcprototype>
  1131. </funcsynopsis>
  1132. </listitem>
  1133. <listitem>
  1134. <funcsynopsis>
  1135. <funcprototype>
  1136. <funcdef>public void <function>goToNextBracket</function></funcdef>
  1137. <paramdef>boolean <parameter>select</parameter></paramdef>
  1138. </funcprototype>
  1139. </funcsynopsis>
  1140. </listitem>
  1141. <listitem>
  1142. <funcsynopsis>
  1143. <funcprototype>
  1144. <funcdef>public void <function>goToPrevBracket</function></funcdef>
  1145. <paramdef>boolean <parameter>select</parameter></paramdef>
  1146. </funcprototype>
  1147. </funcsynopsis>
  1148. </listitem>
  1149. </itemizedlist>
  1150. </sect2>
  1151. <!-- open sect3 -->
  1152. <sect2 id="class-jedittextarea-scrolling">
  1153. <title>Methods for scrolling the text area</title>
  1154. <itemizedlist>
  1155. <listitem>
  1156. <funcsynopsis>
  1157. <funcprototype>
  1158. <funcdef>public void <function>scrollUpLine</function></funcdef>
  1159. <void/>
  1160. </funcprototype>
  1161. </funcsynopsis>
  1162. </listitem>
  1163. <listitem>
  1164. <funcsynopsis>
  1165. <funcprototype>
  1166. <funcdef>public void <function>scrollUpPage</function></funcdef>
  1167. <void/>
  1168. </funcprototype>
  1169. </funcsynopsis>
  1170. </listitem>
  1171. <listitem>
  1172. <funcsynopsis>
  1173. <funcprototype>
  1174. <funcdef>public void <function>scrollDownLine</function></funcdef>
  1175. <void/>
  1176. </funcprototype>
  1177. </funcsynopsis>
  1178. </listitem>
  1179. <listitem>
  1180. <funcsynopsis>
  1181. <funcprototype>
  1182. <funcdef>public void <function>scrollUpPage</function></funcdef>
  1183. <void/>
  1184. </funcprototype>
  1185. </funcsynopsis>
  1186. </listitem>
  1187. <listitem>
  1188. <funcsynopsis>
  1189. <funcprototype>
  1190. <funcdef>public void <function>scrollTo</function></funcdef>
  1191. <paramdef>int <parameter>location</parameter></paramdef>
  1192. <paramdef>boolean <parameter>doElectricScroll</parameter></paramdef>
  1193. </funcprototype>
  1194. </funcsynopsis>
  1195. </listitem>
  1196. <listitem>
  1197. <funcsynopsis>
  1198. <funcprototype>
  1199. <funcdef>public void <function>scrollToCaret</function></funcdef>
  1200. <paramdef>boolean <parameter>doElectricScroll</parameter></paramdef>
  1201. </funcprototype>
  1202. </funcsynopsis>
  1203. <para>
  1204. The first version scrolls the text area to ensure that the caret is
  1205. visible; the second scrolls to ensure that an arbitrary offset
  1206. (from the start of the buffer) is visible. The
  1207. <parameter>doElectricScroll</parameter> parameter determines whether
  1208. <quote>electric scrolling</quote> will occur. This leaves a minimum
  1209. number of lines between the target line and the top and bottom of the
  1210. editing pane.
  1211. </para>
  1212. </listitem>
  1213. <listitem>
  1214. <funcsynopsis>
  1215. <funcprototype>
  1216. <funcdef>public void <function>centerCaret</function></funcdef>
  1217. <void/>
  1218. </funcprototype>
  1219. </funcsynopsis>
  1220. <para>
  1221. Scrolls the text area so that the line containing the edit caret is
  1222. vertically centered.
  1223. </para>
  1224. </listitem>
  1225. <listitem>
  1226. <funcsynopsis>
  1227. <funcprototype>
  1228. <funcdef>public void <function>setFirstLine</function></funcdef>
  1229. <paramdef>int <parameter>firstLine</parameter></paramdef>
  1230. </funcprototype>
  1231. </funcsynopsis>
  1232. </listitem>
  1233. <listitem>
  1234. <funcsynopsis>
  1235. <funcprototype>
  1236. <funcdef>public int <function>getFirstLine</function></funcdef>
  1237. <void/>
  1238. </funcprototype>
  1239. </funcsynopsis>
  1240. <para>
  1241. This pair of methods deals with the line number of the first line
  1242. displayed at the top of the text area. Lines that are hidden by folds or
  1243. narrowing are ignored when making this <quote>virtual</quote> line
  1244. count, so the line number will not necessarily conform to the line
  1245. numbers displayed in the text area's gutter. In addition, the virtual
  1246. line index is zero-based, so <function>getFirstLine()</function> will
  1247. always return zero for the first line of text.
  1248. </para>
  1249. <para>
  1250. To convert a virtual line count to a physical count or vice versa,
  1251. see <xref linkend="class-jedittextarea-virtual-lines" />.
  1252. </para>
  1253. </listitem>
  1254. </itemizedlist>
  1255. </sect2>
  1256. <sect2 id="class-jedittextarea-delete">
  1257. <title>Methods for deleting text</title>
  1258. <itemizedlist>
  1259. <listitem>
  1260. <funcsynopsis>
  1261. <funcprototype>
  1262. <funcdef>public void <function>backspace</function></funcdef>
  1263. <void/>
  1264. </funcprototype>
  1265. </funcsynopsis>
  1266. </listitem>
  1267. <listitem>
  1268. <funcsynopsis>
  1269. <funcprototype>
  1270. <funcdef>public void <function>backspaceWord</function></funcdef>
  1271. <void/>
  1272. </funcprototype>
  1273. </funcsynopsis>
  1274. </listitem>
  1275. <listitem>
  1276. <funcsynopsis>
  1277. <funcprototype>
  1278. <funcdef>public void <function>delete</function></funcdef>
  1279. <void/>
  1280. </funcprototype>
  1281. </funcsynopsis>
  1282. </listitem>
  1283. <listitem>
  1284. <funcsynopsis>
  1285. <funcprototype>
  1286. <funcdef>public void <function>deleteWord</function></funcdef>
  1287. <void/>
  1288. </funcprototype>
  1289. </funcsynopsis>
  1290. </listitem>
  1291. <listitem>
  1292. <funcsynopsis>
  1293. <funcprototype>
  1294. <funcdef>public void <function>deleteLine</function></funcdef>
  1295. <void/>
  1296. </funcprototype>
  1297. </funcsynopsis>
  1298. </listitem>
  1299. <listitem>
  1300. <funcsynopsis>
  1301. <funcprototype>
  1302. <funcdef>public void <function>deleteParagraph</function></funcdef>
  1303. <void/>
  1304. </funcprototype>
  1305. </funcsynopsis>
  1306. </listitem>
  1307. <listitem>
  1308. <funcsynopsis>
  1309. <funcprototype>
  1310. <funcdef>public void <function>deleteToStartOfLine</function></funcdef>
  1311. <void/>
  1312. </funcprototype>
  1313. </funcsynopsis>
  1314. </listitem>
  1315. <listitem>
  1316. <funcsynopsis>
  1317. <funcprototype>
  1318. <funcdef>public void <function>deleteToEndOfLine</function></funcdef>
  1319. <void/>
  1320. </funcprototype>
  1321. </funcsynopsis>
  1322. </listitem>
  1323. </itemizedlist>
  1324. </sect2>
  1325. <sect2 id="class-jedittextarea-modify">
  1326. <title>Methods for modifying text</title>
  1327. <itemizedlist>
  1328. <listitem>
  1329. <funcsynopsis>
  1330. <funcprototype>
  1331. <funcdef>public void <function>toLowerCase</function></funcdef>
  1332. <void/>
  1333. </funcprototype>
  1334. </funcsynopsis>
  1335. </listitem>
  1336. <listitem>
  1337. <funcsynopsis>
  1338. <funcprototype>
  1339. <funcdef>public void <function>toUpperCase</function></funcdef>
  1340. <void/>
  1341. </funcprototype>
  1342. </funcsynopsis>
  1343. <para>
  1344. These two methods operate on all selected text, including multiple
  1345. selections.
  1346. </para>
  1347. </listitem>
  1348. <listitem>
  1349. <funcsynopsis>
  1350. <funcprototype>
  1351. <funcdef>public void <function>joinLines</function></funcdef>
  1352. <void/>
  1353. </funcprototype>
  1354. </funcsynopsis>
  1355. <para>
  1356. Joins the current line with the following line.
  1357. </para>
  1358. </listitem>
  1359. <listitem>
  1360. <funcsynopsis>
  1361. <funcprototype>
  1362. <funcdef>public void <function>setOverwriteEnabled</function></funcdef>
  1363. <paramdef>boolean <parameter>overwrite</parameter></paramdef>
  1364. </funcprototype>
  1365. </funcsynopsis>
  1366. </listitem>
  1367. <listitem>
  1368. <funcsynopsis>
  1369. <funcprototype>
  1370. <funcdef>public boolean <function>isOverwriteEnabled</function></funcdef>
  1371. <void/>
  1372. </funcprototype>
  1373. </funcsynopsis>
  1374. <para>
  1375. Sets and gets whether added text will overwrite text at the editing
  1376. caret or whether it will be inserted immediately to the right of the
  1377. caret.
  1378. </para>
  1379. </listitem>
  1380. <listitem>
  1381. <funcsynopsis>
  1382. <funcprototype>
  1383. <funcdef>public void <function>userInput</function></funcdef>
  1384. <paramdef>char <parameter>ch</parameter></paramdef>
  1385. </funcprototype>
  1386. </funcsynopsis>
  1387. <para>
  1388. Inserts the character at the caret position as if it were typed at
  1389. the keyboard (keyboard input is actually passed to this method).
  1390. Unlike <function>setSelectedText()</function>, or
  1391. <function>insert()</function> in the
  1392. <classname>Buffer</classname> class, this method triggers
  1393. any active text formatting features such as auto indent,
  1394. abbreviation expansion and word wrap.
  1395. </para>
  1396. </listitem>
  1397. </itemizedlist>
  1398. </sect2>
  1399. <sect2 id="class-jedittextarea-commment">
  1400. <title>Methods for creating comments</title>
  1401. <itemizedlist>
  1402. <listitem>
  1403. <funcsynopsis>
  1404. <funcprototype>
  1405. <funcdef>public void <function>lineComment</function></funcdef>
  1406. <void/>
  1407. </funcprototype>
  1408. </funcsynopsis>
  1409. <para>
  1410. This inserts the line comment string at the beginning of each selected line.
  1411. </para>
  1412. </listitem>
  1413. <listitem>
  1414. <funcsynopsis>
  1415. <funcprototype>
  1416. <funcdef>public void <function>rangeComment</function></funcdef>
  1417. <void/>
  1418. </funcprototype>
  1419. </funcsynopsis>
  1420. <para>
  1421. This surrounds each selected text chunk with
  1422. the comment start and end strings.
  1423. </para>
  1424. </listitem>
  1425. </itemizedlist>
  1426. </sect2>
  1427. <sect2 id="class-jedittextarea-virtual-lines">
  1428. <title>Virtual and physical line indices</title>
  1429. <para>
  1430. When jEdit's folding or narrowing features are used to hide
  1431. portions of a buffer, the <quote>virtual</quote> line count visible
  1432. in the text area is generally not equal to the <quote>physical</quote>
  1433. line count of the buffer represented by the gutter's display. The
  1434. following pair of methods translate one enumeration to the other.
  1435. </para>
  1436. <itemizedlist>
  1437. <listitem>
  1438. <funcsynopsis>
  1439. <funcprototype>
  1440. <funcdef>public int <function>virtualToPhysical</function></funcdef>
  1441. <paramdef>int <parameter>lineNo</parameter></paramdef>
  1442. </funcprototype>
  1443. </funcsynopsis>
  1444. </listitem>
  1445. <listitem>
  1446. <funcsynopsis>
  1447. <funcprototype>
  1448. <funcdef>public int <function>physicalToVirtual</function></funcdef>
  1449. <paramdef>int <parameter>lineNo</parameter></paramdef>
  1450. </funcprototype>
  1451. </funcsynopsis>
  1452. </listitem>
  1453. </itemizedlist>
  1454. </sect2>
  1455. </sect1>
  1456. <sect1 id="class-buffer"><title>Class Buffer</title>
  1457. <para>
  1458. A <classname>Buffer</classname> represents the contents of an open text
  1459. file as it is maintained in the computer's memory (as opposed to
  1460. how it may be stored on a disk).
  1461. </para>
  1462. <sect2 id="class-buffer-attrs"><title>File attribute methods</title>
  1463. <itemizedlist>
  1464. <listitem>
  1465. <funcsynopsis>
  1466. <funcprototype>
  1467. <funcdef>public String <function>getName</function></funcdef>
  1468. <void/>
  1469. </funcprototype>
  1470. </funcsynopsis>
  1471. </listitem>
  1472. <listitem>
  1473. <funcsynopsis>
  1474. <funcprototype>
  1475. <funcdef>public String <function>getPath</function></funcdef>
  1476. <void/>
  1477. </funcprototype>
  1478. </funcsynopsis>
  1479. </listitem>
  1480. <listitem>
  1481. <funcsynopsis>
  1482. <funcprototype>
  1483. <funcdef>public File <function>getFile</function></funcdef>
  1484. <void/>
  1485. </funcprototype>
  1486. </funcsynopsis>
  1487. <para>
  1488. This method may return <constant>null</constant> if the file is stored on
  1489. a remote file system (for example, if the <application>FTP</application>
  1490. or <application>Archive</application> plugins are in use). This method
  1491. should be avoided unless you really need to use the
  1492. <classname>java.io.File</classname> APIs and you are sure the buffer in
  1493. question is a local file.
  1494. </para>
  1495. </listitem>
  1496. <listitem>
  1497. <funcsynopsis>
  1498. <funcprototype>
  1499. <funcdef>public boolean <function>isNewFile</function></funcdef>
  1500. <void/>
  1501. </funcprototype>
  1502. </funcsynopsis>
  1503. <para>
  1504. Returns whether a buffer lacks a corresponding version on disk.
  1505. </para>
  1506. </listitem>
  1507. <listitem>
  1508. <funcsynopsis>
  1509. <funcprototype>
  1510. <funcdef>public boolean <function>isDirty</function></funcdef>
  1511. <void/>
  1512. </funcprototype>
  1513. </funcsynopsis>
  1514. <para>
  1515. Returns whether there have been unsaved changes to the buffer.
  1516. </para>
  1517. </listitem>
  1518. <listitem>
  1519. <funcsynopsis>
  1520. <funcprototype>
  1521. <funcdef>public boolean <function>isReadOnly</function></funcdef>
  1522. <void/>
  1523. </funcprototype>
  1524. </funcsynopsis>
  1525. </listitem>
  1526. <listitem>
  1527. <funcsynopsis>
  1528. <funcprototype>
  1529. <funcdef>public boolean <function>isUntitled</function></funcdef>
  1530. <void/>
  1531. </funcprototype>
  1532. </funcsynopsis>
  1533. </listitem>
  1534. </itemizedlist>
  1535. </sect2>
  1536. <sect2 id="class-buffer-attr"><title>Editing attribute methods</title>
  1537. <itemizedlist>
  1538. <listitem>
  1539. <funcsynopsis>
  1540. <funcprototype>
  1541. <funcdef>public Mode <function>getMode</function></funcdef>
  1542. <void/>
  1543. </funcprototype>
  1544. </funcsynopsis>
  1545. </listitem>
  1546. <listitem>
  1547. <funcsynopsis>
  1548. <funcprototype>
  1549. <funcdef>public void <function>setMode</function></funcdef>
  1550. <paramdef>Mode <parameter>mode</parameter></paramdef>
  1551. </funcprototype>
  1552. </funcsynopsis>
  1553. <para>
  1554. Gets and sets the editing mode for the buffer.
  1555. </para>
  1556. </listitem>
  1557. <listitem>
  1558. <funcsynopsis>
  1559. <funcprototype>
  1560. <funcdef>public int <function>getIndentSize</function></funcdef>
  1561. <void/>
  1562. </funcprototype>
  1563. </funcsynopsis>
  1564. </listitem>
  1565. <listitem>
  1566. <funcsynopsis>
  1567. <funcprototype>
  1568. <funcdef>public int <function>getTabSize</function></funcdef>
  1569. <void/>
  1570. </funcprototype>
  1571. </funcsynopsis>
  1572. <para>
  1573. These methods return the size of an initial indentation at the beginning
  1574. of a line and the distance between tab stops, each measured in
  1575. character columns. If these properties are not individually set for
  1576. a specific buffer, they are inherited from the properties of the buffer's
  1577. associated editing mode.
  1578. </para>
  1579. </listitem>
  1580. </itemizedlist>
  1581. <para>
  1582. The <classname>Buffer</classname> object maintains a table of
  1583. properties that describe a broad range of attributes. The value of each
  1584. property is stored using a
  1585. <classname>String</classname> that names the particular property.
  1586. Most of these properties are documented in <xref
  1587. linkend="buffer-local" />.
  1588. </para>
  1589. <itemizedlist>
  1590. <listitem>
  1591. <funcsynopsis>
  1592. <funcprototype>
  1593. <funcdef>public Object <function>getProperty</function></funcdef>
  1594. <paramdef>String <parameter>name</parameter></paramdef>
  1595. </funcprototype>
  1596. </funcsynopsis>
  1597. <para>
  1598. Using this method is generally discouraged, because it returns an
  1599. <classname>Object</classname> which must be cast to another type
  1600. in order to be useful, and this can cause problems if the object
  1601. is of a different type than what your plugin or macro expects.
  1602. </para>
  1603. <para>
  1604. jEdit 4.0 added a number of <quote>wrapper</quote> methods,
  1605. documented below; you are strongly encouraged to use them
  1606. instead.
  1607. </para>
  1608. </listitem>
  1609. <listitem>
  1610. <funcsynopsis>
  1611. <funcprototype>
  1612. <funcdef>public void <function>setProperty</function></funcdef>
  1613. <paramdef>String <parameter>name</parameter></paramdef>
  1614. <paramdef>Object <parameter>value</parameter></paramdef>
  1615. </funcprototype>
  1616. </funcsynopsis>
  1617. <para>
  1618. Sets the value of a property named by <varname>name</varname> to
  1619. <varname>value</varname>.
  1620. </para>
  1621. </listitem>
  1622. </itemizedlist>
  1623. <para>
  1624. These methods provide shortcuts for getting and setting
  1625. string, integer and <classname>boolean</classname>
  1626. properties.
  1627. </para>
  1628. <itemizedlist>
  1629. <listitem>
  1630. <funcsynopsis>
  1631. <funcprototype>
  1632. <funcdef>public static String <function>getStringProperty</function></funcdef>
  1633. <paramdef>String <parameter>name</parameter></paramdef>
  1634. </funcprototype>
  1635. </funcsynopsis>
  1636. <para>
  1637. Returns the value of the property named by
  1638. <varname>name</varname> as a string.
  1639. </para>
  1640. </listitem>
  1641. <listitem>
  1642. <funcsynopsis>
  1643. <funcprototype>
  1644. <funcdef>public static void <function>setStringProperty</function></funcdef>
  1645. <paramdef>String <parameter>name</parameter></paramdef>
  1646. <paramdef>String <parameter>value</parameter></paramdef>
  1647. </funcprototype>
  1648. </funcsynopsis>
  1649. <para>
  1650. Sets the property named by <varname>name</varname> to
  1651. <varname>value</varname>.
  1652. </para>
  1653. </listitem>
  1654. <listitem>
  1655. <funcsynopsis>
  1656. <funcprototype>
  1657. <funcdef>public static boolean <function>getBooleanProperty</function></funcdef>
  1658. <paramdef>String <parameter>name</parameter></paramdef>
  1659. </funcprototype>
  1660. </funcsynopsis>
  1661. <para>
  1662. Returns a <classname>boolean</classname> value of <constant>true</constant> or
  1663. <constant>false</constant> for the property named by <varname>name</varname> by
  1664. examining the contents of the property; returns
  1665. <constant>false</constant> if the property cannot be found.
  1666. </para>
  1667. </listitem>
  1668. <listitem>
  1669. <funcsynopsis>
  1670. <funcprototype>
  1671. <funcdef>public static void <function>setBooleanProperty</function></funcdef>
  1672. <paramdef>String <parameter>name</parameter></paramdef>
  1673. <paramdef>boolean <parameter>value</parameter></paramdef>
  1674. </funcprototype>
  1675. </funcsynopsis>
  1676. <para>
  1677. Sets the property named by <varname>name</varname> to
  1678. <varname>value</varname>. The boolean value is stored internally as the
  1679. string <quote>true</quote> or <quote>false</quote>.
  1680. </para>
  1681. </listitem>
  1682. <listitem>
  1683. <funcsynopsis>
  1684. <funcprototype>
  1685. <funcdef>public static int <function>getIntegerProperty</function></funcdef>
  1686. <paramdef>String <parameter>name</parameter></paramdef>
  1687. <paramdef>int <parameter>defaultValue</parameter></paramdef>
  1688. </funcprototype>
  1689. </funcsynopsis>
  1690. <para>
  1691. Returns the integer value of the property named by
  1692. <varname>name</varname>. If the property value is not a valid
  1693. numeric string, returns <varname>defaultValue</varname> instead.
  1694. </para>
  1695. </listitem>
  1696. <listitem>
  1697. <funcsynopsis>
  1698. <funcprototype>
  1699. <funcdef>public static void <function>setIntegerProperty</function></funcdef>
  1700. <paramdef>String <parameter>name</parameter></paramdef>
  1701. <paramdef>int <parameter>value</parameter></paramdef>
  1702. </funcprototype>
  1703. </funcsynopsis>
  1704. <para>
  1705. Sets the property named by <varname>name</varname> to
  1706. <varname>value</varname>.
  1707. </para>
  1708. </listitem>
  1709. </itemizedlist>
  1710. </sect2>
  1711. <sect2 id="class-buffer-io"><title>Input/output methods</title>
  1712. <itemizedlist>
  1713. <listitem>
  1714. <funcsynopsis>
  1715. <funcprototype>
  1716. <funcdef>public void <function>reload</function></funcdef>
  1717. <paramdef>View <parameter>view</parameter></paramdef>
  1718. </funcprototype>
  1719. </funcsynopsis>
  1720. <para>
  1721. Reloads the buffer from disk into <parameter>view</parameter>, asking
  1722. for confirmation if the buffer has unsaved changes.
  1723. </para>
  1724. </listitem>
  1725. <listitem>
  1726. <funcsynopsis>
  1727. <funcprototype>
  1728. <funcdef>public boolean <function>save</function></funcdef>
  1729. <paramdef>View <parameter>view</parameter></paramdef>
  1730. <paramdef>String <parameter>path</parameter></paramdef>
  1731. </funcprototype>
  1732. </funcsynopsis>
  1733. </listitem>
  1734. <listitem>
  1735. <funcsynopsis>
  1736. <funcprototype>
  1737. <funcdef>public boolean <function>save</function></funcdef>
  1738. <paramdef>View <parameter>view</parameter></paramdef>
  1739. <paramdef>String <parameter>path</parameter></paramdef>
  1740. <paramdef>boolean <parameter>rename</parameter></paramdef>
  1741. </funcprototype>
  1742. </funcsynopsis>
  1743. <para>
  1744. The <parameter>rename</parameter> parameter causes a buffer's name to
  1745. change if set to <parameter>true</parameter>; if
  1746. <parameter>false</parameter>, a copy is saved to
  1747. <parameter>path</parameter>.
  1748. </para>
  1749. </listitem>
  1750. <listitem>
  1751. <funcsynopsis>
  1752. <funcprototype>
  1753. <funcdef>public boolean <function>saveAs</function></funcdef>
  1754. <paramdef>View <parameter>view</parameter></paramdef>
  1755. <paramdef>boolean <parameter>rename</parameter></paramdef>
  1756. </funcprototype>
  1757. </funcsynopsis>
  1758. <para>
  1759. Prompts the user for a new name for saving the file.
  1760. </para>
  1761. </listitem>
  1762. </itemizedlist>
  1763. </sect2>
  1764. <sect2 id="class-buffer-editing"><title>General editing methods</title>
  1765. <itemizedlist>
  1766. <listitem>
  1767. <funcsynopsis>
  1768. <funcprototype>
  1769. <funcdef>public String <function>getText</function></funcdef><!--
  1770. --><paramdef>int <parameter>offset</parameter></paramdef>
  1771. <paramdef>int <parameter>length</parameter></paramdef>
  1772. </funcprototype>
  1773. </funcsynopsis>
  1774. </listitem>
  1775. <listitem>
  1776. <funcsynopsis>
  1777. <funcprototype>
  1778. <funcdef>public void <function>getText</function></funcdef><!--
  1779. --><paramdef>int <parameter>offset</parameter></paramdef>
  1780. <paramdef>int <parameter>length</parameter></paramdef>
  1781. <paramdef>Segment <parameter>text</parameter></paramdef>
  1782. </funcprototype>
  1783. </funcsynopsis>
  1784. <para>
  1785. These methods extract a portion of buffer text having length
  1786. <varname>length</varname> beginning at offset position
  1787. <varname>offset</varname>. The first method returns a newly
  1788. created <classname>String</classname> containing the requested
  1789. excerpt. The second version initializes an existing
  1790. <classname>Segment</classname> object with the location of the
  1791. requested excerpt. The <classname>Segment</classname> object
  1792. represents array locations within the <classname>Buffer</classname>
  1793. object's data and should be used on a read-only basis. Calling
  1794. <function>toString()</function> on the <classname>Segment</classname>
  1795. will create a new object suitable for manipulation.
  1796. </para>
  1797. <para>
  1798. Using a <classname>Segment</classname> is generally more
  1799. efficient than using a <classname>String</classname> because it
  1800. results in less memory allocation and array copying. However,
  1801. <classname>Segments</classname> are slightly harder to set up and
  1802. use.
  1803. </para>
  1804. </listitem>
  1805. <listitem>
  1806. <funcsynopsis>
  1807. <funcprototype>
  1808. <funcdef>public String <function>getLineText</function></funcdef>
  1809. <paramdef>int <parameter>lineIndex</parameter></paramdef>
  1810. </funcprototype>
  1811. </funcsynopsis>
  1812. </listitem>
  1813. <listitem>
  1814. <funcsynopsis>
  1815. <funcprototype>
  1816. <funcdef>public void <function>getLineText</function></funcdef>
  1817. <paramdef>int <parameter>lineIndex</parameter></paramdef>
  1818. <paramdef>Segment <parameter>text</parameter></paramdef>
  1819. </funcprototype>
  1820. </funcsynopsis>
  1821. <para>
  1822. Returns the text of the given line. Just as with
  1823. <function>getText()</function>, there are two forms of this
  1824. method; the first returns a <classname>String</classname>, the
  1825. second copies into a <classname>Segment</classname>.
  1826. </para>
  1827. </listitem>
  1828. <listitem>
  1829. <funcsynopsis>
  1830. <funcprototype>
  1831. <funcdef>public void <function>beginCompoundEdit</function></funcdef>
  1832. <void/>
  1833. </funcprototype>
  1834. </funcsynopsis>
  1835. </listitem>
  1836. <listitem>
  1837. <funcsynopsis>
  1838. <funcprototype>
  1839. <funcdef>public void <function>endCompoundEdit</function></funcdef>
  1840. <void/>
  1841. </funcprototype>
  1842. </funcsynopsis>
  1843. <para>
  1844. Marks the beginning and end of a series of editing operations that will
  1845. be dealt with by a single <guimenuitem>Undo</guimenuitem> command.
  1846. </para>
  1847. </listitem>
  1848. <listitem>
  1849. <funcsynopsis>
  1850. <funcprototype>
  1851. <funcdef>public void <function>insert</function></funcdef><!--
  1852. --><paramdef>int <parameter>offset</parameter></paramdef>
  1853. <paramdef>String <parameter>text</parameter></paramdef>
  1854. </funcprototype>
  1855. </funcsynopsis>
  1856. <para>
  1857. This method inserts the string <varname>text</varname> at offset
  1858. <varname>offset</varname> in the buffer.
  1859. </para>
  1860. </listitem>
  1861. <listitem>
  1862. <funcsynopsis>
  1863. <funcprototype>
  1864. <funcdef>public void <function>remove</function></funcdef><!--
  1865. --><paramdef>int <parameter>offset</parameter></paramdef>
  1866. <paramdef>int <parameter>length</parameter></paramdef>
  1867. </funcprototype>
  1868. </funcsynopsis>
  1869. <para>
  1870. This method removes <varname>length</varname> characters of
  1871. text starting from <varname>offset</varname>.
  1872. </para>
  1873. </listitem>
  1874. <listitem>
  1875. <funcsynopsis>
  1876. <funcprototype>
  1877. <funcdef>public void <function>removeTrailingWhiteSpace</function></funcdef>
  1878. <paramdef>int[] <parameter>lines</parameter></paramdef>
  1879. </funcprototype>
  1880. </funcsynopsis>
  1881. <para>
  1882. Removes trailing whitespace in the lines referenced by the index numbers
  1883. in <parameter>lines</parameter> array.
  1884. </para>
  1885. </listitem>
  1886. <listitem>
  1887. <funcsynopsis>
  1888. <funcprototype>
  1889. <funcdef>public int <function>getLineOfOffset</function></funcdef>
  1890. <paramdef>int <parameter>offset</parameter></paramdef>
  1891. </funcprototype>
  1892. </funcsynopsis>
  1893. <para>
  1894. Returns the line on which the given offset is found.
  1895. </para>
  1896. </listitem>
  1897. <listitem>
  1898. <funcsynopsis>
  1899. <funcprototype>
  1900. <funcdef>public int <function>getLineStartOffset</function></funcdef>
  1901. <paramdef>int <parameter>line</parameter></paramdef>
  1902. </funcprototype>
  1903. </funcsynopsis>
  1904. </listitem>
  1905. <listitem>
  1906. <funcsynopsis>
  1907. <funcprototype>
  1908. <funcdef>public int <function>getLineEndOffset</function></funcdef>
  1909. <paramdef>int <parameter>line</parameter></paramdef>
  1910. </funcprototype>
  1911. </funcsynopsis>
  1912. <para>
  1913. Returns the offset of the beginning or end of the given line.
  1914. </para>
  1915. </listitem>
  1916. <listitem>
  1917. <funcsynopsis>
  1918. <funcprototype>
  1919. <funcdef>public int <function>getLineLength</function></funcdef>
  1920. <paramdef>int <parameter>line</parameter></paramdef>
  1921. </funcprototype>
  1922. </funcsynopsis>
  1923. <para>
  1924. Returns the length of the line number <varname>line</varname> (using a
  1925. zero-based count).
  1926. </para>
  1927. </listitem>
  1928. <listitem>
  1929. <funcsynopsis>
  1930. <funcprototype>
  1931. <funcdef>public int <function>getLineCount</function></funcdef>
  1932. <void/>
  1933. </funcprototype>
  1934. </funcsynopsis>
  1935. <para>
  1936. Returns the number of lines in the buffer being edited.
  1937. </para>
  1938. </listitem>
  1939. <listitem>
  1940. <funcsynopsis>
  1941. <funcprototype>
  1942. <funcdef>public int <function>getLength</function></funcdef><void/>
  1943. </funcprototype>
  1944. </funcsynopsis>
  1945. <para>
  1946. Returns the number of characters in the buffer.
  1947. </para>
  1948. </listitem>
  1949. </itemizedlist>
  1950. </sect2>
  1951. <sect2 id="class-buffer-markers"><title>Marker methods</title>
  1952. <para>
  1953. Buffers may have one or more <glossterm>markers</glossterm> which serve
  1954. as textual bookmarks. A <classname>Marker</classname> has three key attributes: the
  1955. <classname>Buffer</classname> to which it relates, the line number to which
  1956. the marker refers, and an optional shortcut character. The shortcut
  1957. identifies the the key that can be pressed with the
  1958. <guimenu>Markers</guimenu>&gt;<guimenuitem>Go To Marker</guimenuitem>
  1959. command to move the editing caret to the marker line location.
  1960. </para>
  1961. <para>
  1962. The position and shortcut character of a <classname>Marker</classname>
  1963. object can be retrieved with the methods <function>getPosition()</function>
  1964. and <function>getShortcut()</function>.
  1965. </para>
  1966. <para>
  1967. The <classname>Buffer</classname> class includes the following methods to
  1968. set and retrieve markers:
  1969. </para>
  1970. <itemizedlist>
  1971. <listitem>
  1972. <funcsynopsis>
  1973. <funcprototype>
  1974. <funcdef>public void <function>addMarker</function></funcdef>
  1975. <paramdef>char <parameter>shortcut</parameter></paramdef>
  1976. <paramdef>int <parameter>pos</parameter></paramdef>
  1977. </funcprototype>
  1978. </funcsynopsis>
  1979. <para>
  1980. Adds a marker for the line indicated by <parameter>pos</parameter>
  1981. using <parameter>shortcut</parameter>. Set
  1982. <parameter>shortcut</parameter> to <constant>'\0'</constant> to
  1983. indicate the absence of a shortcut.
  1984. </para>
  1985. </listitem>
  1986. <listitem>
  1987. <funcsynopsis>
  1988. <funcprototype>
  1989. <funcdef>public Vector <function>getMarkers</function></funcdef>
  1990. <void/>
  1991. </funcprototype>
  1992. </funcsynopsis>
  1993. <para>
  1994. Returns a <classname>Vector</classname> containing the buffer's
  1995. current markers.
  1996. </para>
  1997. </listitem>
  1998. <listitem>
  1999. <funcsynopsis>
  2000. <funcprototype>
  2001. <funcdef>public Marker <function>getMarkerAtLine</function></funcdef>
  2002. <paramdef>int <parameter>line</parameter></paramdef>
  2003. </funcprototype>
  2004. </funcsynopsis>
  2005. <para>
  2006. Returns the first marker at the specified line, or
  2007. <constant>null</constant> if no marker is present at the line.
  2008. </para>
  2009. </listitem>
  2010. <listitem>
  2011. <funcsynopsis>
  2012. <funcprototype>
  2013. <funcdef>public Marker <function>getMarker</function></funcdef>
  2014. <paramdef>char <parameter>shortcut</parameter></paramdef>
  2015. </funcprototype>
  2016. </funcsynopsis>
  2017. <para>
  2018. Returns the marker with the specified shortcut, or
  2019. <constant>null</constant> if no such marker exists.
  2020. </para>
  2021. </listitem>
  2022. <listitem>
  2023. <funcsynopsis>
  2024. <funcprototype>
  2025. <funcdef>public void <function>removeMarker</function></funcdef>
  2026. <paramdef>int <parameter>line</parameter></paramdef>
  2027. </funcprototype>
  2028. </funcsynopsis>
  2029. <para>
  2030. Removes all markers at the specified line.
  2031. </para>
  2032. </listitem>
  2033. <listitem>
  2034. <funcsynopsis>
  2035. <funcprototype>
  2036. <funcdef>public void <function>removeAllMarkers</function></funcdef>
  2037. <void/>
  2038. </funcprototype>
  2039. </funcsynopsis>
  2040. <para>
  2041. Removes all markers in the buffer.
  2042. </para>
  2043. </listitem>
  2044. </itemizedlist>
  2045. </sect2>
  2046. </sect1>
  2047. <sect1 id="class-macros"><title>Class Macros</title>
  2048. <para>
  2049. This class contains a few methods useful for displaying output messages
  2050. or obtaining input from a macro. These methods are documented in
  2051. detail in <xref linkend="helpful-methods" />.
  2052. Plugins should use the methods in the
  2053. <classname>GUIUtilities</classname> class instead; see
  2054. <xref linkend="class-guiutilities" />.
  2055. </para>
  2056. <itemizedlist>
  2057. <listitem>
  2058. <funcsynopsis>
  2059. <funcprototype>
  2060. <funcdef>public static void <function>message</function></funcdef>
  2061. <paramdef>Component <parameter>comp</parameter></paramdef>
  2062. <paramdef>String <parameter>message</parameter></paramdef>
  2063. </funcprototype>
  2064. </funcsynopsis>
  2065. </listitem>
  2066. <listitem>
  2067. <funcsynopsis>
  2068. <funcprototype>
  2069. <funcdef>public static void <function>error</function></funcdef>
  2070. <paramdef>View <parameter>view</parameter></paramdef>
  2071. <paramdef>String <parameter>message</parameter></paramdef>
  2072. </funcprototype>
  2073. </funcsynopsis>
  2074. </listitem>
  2075. <listitem>
  2076. <funcsynopsis>
  2077. <funcprototype>
  2078. <funcdef>public static String <function>input</function></funcdef>
  2079. <paramdef>View <parameter>view</parameter></paramdef>
  2080. <paramdef>String <parameter>prompt</parameter></paramdef>
  2081. </funcprototype>
  2082. </funcsynopsis>
  2083. </listitem>
  2084. <listitem>
  2085. <funcsynopsis>
  2086. <funcprototype>
  2087. <funcdef>public static String <function>input</function></funcdef>
  2088. <paramdef>View <parameter>view</parameter></paramdef>
  2089. <paramdef>String <parameter>prompt</parameter></paramdef>