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

# · XML · 2313 lines · 2035 code · 267 blank · 11 comment · 0 complexity · 7b33c5388593559491492d8fe06320ac MD5 · raw file

Large files are truncated click here to view the full file

  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-macro"><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 boolean <function>getBooleanProperty</function></funcdef>
  121. <paramdef>String <parameter>name</parameter></paramdef>
  122. </funcprototype>
  123. </funcsynopsis>
  124. <para>
  125. Returns a <type>boolean</type> value of <constant>true</constant> or
  126. <constant>false</constant> for the property named by <varname>name</varname> by
  127. examining the contents of the property; returns
  128. <constant>false</constant> if the property cannot be found.
  129. </para>
  130. </listitem>
  131. <listitem>
  132. <funcsynopsis>
  133. <funcprototype>
  134. <funcdef>public static void <function>setProperty</function></funcdef>
  135. <paramdef>String <parameter>name</parameter></paramdef>
  136. <paramdef>String <parameter>property</parameter></paramdef>
  137. </funcprototype>
  138. </funcsynopsis>
  139. <para>
  140. This method sets the property named by <varname>name</varname> with the value
  141. <varname>property</varname>. An existing property is overwritten.
  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. This method 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 void <function>setTemporaryProperty</function></funcdef>
  162. <paramdef>String <parameter>name</parameter></paramdef>
  163. <paramdef>String <parameter>property</parameter></paramdef>
  164. </funcprototype>
  165. </funcsynopsis>
  166. <para>
  167. This sets a property that will not be stored during the current
  168. jEdit session only. This method is useful for storing a value
  169. obtained by one macro for use by another macro.
  170. </para>
  171. </listitem>
  172. <listitem>
  173. <funcsynopsis>
  174. <funcprototype>
  175. <funcdef>public static String <function>getJEditHome</function></funcdef>
  176. <void/>
  177. </funcprototype>
  178. </funcsynopsis>
  179. <para>
  180. Returns the path of the directory containing the jEdit executable file.
  181. </para>
  182. </listitem>
  183. <listitem>
  184. <funcsynopsis>
  185. <funcprototype>
  186. <funcdef>public static String <function>getSettingsDirectory</function></funcdef>
  187. <void/>
  188. </funcprototype>
  189. </funcsynopsis>
  190. <para>
  191. Returns the path of the directory in which user-specific settings
  192. are stored. This will be null if jEdit was started with the
  193. <command>-nosettings</command> command-line switch; so do not
  194. blindly use this method without checking for a null return value
  195. first.
  196. </para>
  197. </listitem>
  198. </itemizedlist>
  199. <para>The jEdit object also maintains a number of collections which
  200. are useful in some situations. They include the following:</para>
  201. <itemizedlist>
  202. <listitem>
  203. <funcsynopsis>
  204. <funcprototype>
  205. <funcdef>public static EditAction[] <function>getActions</function></funcdef>
  206. <void/>
  207. </funcprototype>
  208. </funcsynopsis>
  209. <para>
  210. Returns an array of <quote>actions</quote> or short routines maintained and used
  211. by the editor.
  212. </para>
  213. </listitem>
  214. <listitem>
  215. <funcsynopsis>
  216. <funcprototype>
  217. <funcdef>public static EditAction <function>getAction</function></funcdef>
  218. <paramdef>String <parameter>action</parameter></paramdef>
  219. </funcprototype>
  220. </funcsynopsis>
  221. <para>
  222. Returns the action named <varname>action</varname>, or
  223. <constant>null</constant> if it does not exist.
  224. </para>
  225. </listitem>
  226. <listitem>
  227. <funcsynopsis>
  228. <funcprototype>
  229. <funcdef>public static Buffer[] <function>getBuffers</function></funcdef>
  230. <void/>
  231. </funcprototype>
  232. </funcsynopsis>
  233. <para>
  234. Returns an array of open buffers.
  235. </para>
  236. </listitem>
  237. <listitem>
  238. <funcsynopsis>
  239. <funcprototype>
  240. <funcdef>public static Properties <function>getProperties</function></funcdef>
  241. <void/>
  242. </funcprototype>
  243. </funcsynopsis>
  244. <para>
  245. Returns a Java <classname>Properties</classname> object (a class derived from
  246. <classname>Hashtable</classname>) holding all properties
  247. currently used by the program. The constituent properties fall into three
  248. categories: application properties, <quote>site</quote> properties, and
  249. <quote>user</quote> properties. Site properties take precedence over application
  250. properties with the same <quote>key</quote> or name, and user properties take
  251. precedence over both application and site properties. User settings are
  252. written to a file named <filename>properties</filename> in the user settings
  253. directory upon program exit or whenever <function>jEdit.saveSettings()</function>
  254. is called.
  255. </para>
  256. </listitem>
  257. <listitem>
  258. <funcsynopsis>
  259. <funcprototype>
  260. <funcdef>public static int <function>getBufferCount</function></funcdef>
  261. <void/>
  262. </funcprototype>
  263. </funcsynopsis>
  264. <para>
  265. Returns the number of open buffers.
  266. </para>
  267. </listitem>
  268. <listitem>
  269. <funcsynopsis>
  270. <funcprototype>
  271. <funcdef>public static Buffer <function>getBuffer</function></funcdef>
  272. <paramdef>String <parameter>path</parameter></paramdef>
  273. </funcprototype>
  274. </funcsynopsis>
  275. <para>
  276. Returns the <classname>Buffer</classname> object containing the file named
  277. <varname>path</varname>. or <constant>null</constant> if the buffer does not exist.
  278. </para>
  279. </listitem>
  280. <listitem>
  281. <funcsynopsis>
  282. <funcprototype>
  283. <funcdef>public static Mode[] <function>getModes</function></funcdef>
  284. <void/>
  285. </funcprototype>
  286. </funcsynopsis>
  287. <para>
  288. Returns an array containing all editing modes used by jEdit.
  289. </para>
  290. </listitem>
  291. <listitem>
  292. <funcsynopsis>
  293. <funcprototype>
  294. <funcdef>public static Mode <function>getMode</function></funcdef>
  295. <paramdef>String <parameter>name</parameter></paramdef>
  296. </funcprototype>
  297. </funcsynopsis>
  298. <para>
  299. Returns the editing mode named by <varname>name</varname>, or
  300. <constant>null</constant> if such a mode does not exist.
  301. </para>
  302. </listitem>
  303. <listitem>
  304. <funcsynopsis>
  305. <funcprototype>
  306. <funcdef>public static EditPlugin[] <function>getPlugins</function></funcdef>
  307. <void/>
  308. </funcprototype>
  309. </funcsynopsis>
  310. <para>
  311. Returns an array containing all existing plugins.
  312. </para>
  313. </listitem>
  314. <listitem>
  315. <funcsynopsis>
  316. <funcprototype>
  317. <funcdef>plugin static EditPlugin <function>getPlugin</function></funcdef>
  318. <paramdef>String <parameter>name</parameter></paramdef>
  319. </funcprototype>
  320. </funcsynopsis>
  321. <para>
  322. Returns the plugin named by <varname>name</varname>, or
  323. <constant>null</constant> if such a plugin does not exist.
  324. </para>
  325. </listitem>
  326. </itemizedlist>
  327. </sect1>
  328. <sect1 id="class-view"><title>Class View</title>
  329. <para>
  330. This class represents the <quote>parent</quote> or top-level frame window
  331. in which the editing occurs. It contains the various visible
  332. components of the program, including the editing pane, menubar,
  333. toolbar, and any docking windows containing plugins.
  334. </para>
  335. <para>
  336. Some useful methods from this class include the following:
  337. </para>
  338. <itemizedlist>
  339. <listitem>
  340. <funcsynopsis>
  341. <funcprototype>
  342. <funcdef>public void <function>splitHorizontally</function></funcdef>
  343. <void/>
  344. </funcprototype>
  345. </funcsynopsis>
  346. <para>
  347. Splits the view horizontally.
  348. </para>
  349. </listitem>
  350. <listitem>
  351. <funcsynopsis>
  352. <funcprototype>
  353. <funcdef>public void <function>splitVertically</function></funcdef>
  354. <void/>
  355. </funcprototype>
  356. </funcsynopsis>
  357. <para>
  358. Splits the view vertically.
  359. </para>
  360. </listitem>
  361. <listitem>
  362. <funcsynopsis>
  363. <funcprototype>
  364. <funcdef>public void <function>unsplit</function></funcdef>
  365. <void/>
  366. </funcprototype>
  367. </funcsynopsis>
  368. <para>
  369. Unsplits the view.
  370. </para>
  371. </listitem>
  372. <listitem>
  373. <funcsynopsis>
  374. <funcprototype>
  375. <funcdef>public synchronized void <function>showWaitCursor</function></funcdef>
  376. <void/>
  377. </funcprototype>
  378. </funcsynopsis>
  379. <para>
  380. Shows a <quote>waiting</quote> cursor (typically, an hourglass).
  381. </para>
  382. </listitem>
  383. <listitem>
  384. <funcsynopsis>
  385. <funcprototype>
  386. <funcdef>public synchronized void <function>hideWaitCursor</function></funcdef>
  387. <void/>
  388. </funcprototype>
  389. </funcsynopsis>
  390. <para>
  391. Removes the <quote>waiting</quote> cursor. This method and
  392. <function>showWaitCursor()</function> are implemented using a reference
  393. count of requests for wait cursors, so that nested calls work
  394. correctly; however, you should
  395. be careful to use these methods in tandem.
  396. </para>
  397. </listitem>
  398. <listitem>
  399. <funcsynopsis>
  400. <funcprototype>
  401. <funcdef>public StatusBar <function>getStatus</function></funcdef>
  402. <void/>
  403. </funcprototype>
  404. </funcsynopsis>
  405. <para>
  406. Eeach <classname>View</classname> displays a
  407. <classname>StatusBar</classname> at its bottom edge. It shows the
  408. current cursor position, the editing mode of the current buffer and
  409. other information. The method <function>setMessage(String
  410. message)</function> can be called on the return value of
  411. <function>getStatus()</function> to display reminders or updates.
  412. The message remains until the method is called
  413. again. To display a temporary message in the status bar, call
  414. <function>setMessageAndClear(String message)</function>, which will
  415. erase the message automatically after ten seconds.
  416. </para>
  417. </listitem>
  418. <listitem>
  419. <funcsynopsis>
  420. <funcprototype>
  421. <funcdef>public DockableWindowManager <function>getDockableWindowManager</function></funcdef>
  422. <void/>
  423. </funcprototype>
  424. </funcsynopsis>
  425. <para>
  426. The object returned by this method keeps track of all dockable
  427. windows. See <xref linkend="class-dockablewindowmanager" />.
  428. </para>
  429. </listitem>
  430. </itemizedlist>
  431. </sect1>
  432. <!-- open sect1 -->
  433. <sect1 id="class-registers"><title>Class Registers</title>
  434. <para>
  435. A <classname>Register</classname> is string of text indexed by a
  436. single character. Typically the text is taken from selected buffer text
  437. and the index character is a keyboard character selected by the user.
  438. </para>
  439. <para>
  440. The application maintains a single <classname>Registers</classname> object
  441. consisting of an dynamically sized array of <classname>Register</classname>
  442. objects. The <classname>Registers</classname> class defines a number of methods
  443. that give each register the properties of a virtual clipboard.
  444. </para>
  445. <para>
  446. The following methods provide a clipboard operations for register
  447. objects:
  448. </para>
  449. <itemizedlist>
  450. <listitem>
  451. <funcsynopsis>
  452. <funcprototype>
  453. <funcdef>public static void <function>copy</function></funcdef>
  454. <paramdef>JEditTextArea <parameter>textArea</parameter></paramdef>
  455. <paramdef>char <parameter>register</parameter></paramdef>
  456. </funcprototype>
  457. </funcsynopsis>
  458. <para>
  459. Saves the selected text in the designated <parameter>textArea</parameter>
  460. to the register indexed at <parameter>register</parameter>. This
  461. will replace the existing contents of the designated register.
  462. </para>
  463. </listitem>
  464. <listitem>
  465. <funcsynopsis>
  466. <funcprototype>
  467. <funcdef>public static void <function>cut</function></funcdef>
  468. <paramdef>JEditTextArea <parameter>textArea</parameter></paramdef>
  469. <paramdef>char <parameter>register</parameter></paramdef>
  470. </funcprototype>
  471. </funcsynopsis>
  472. <para>
  473. Saves the selected text in the designated <parameter>textArea</parameter>
  474. to the register indexed at <parameter>register</parameter>, and removes the
  475. text from the text area. This will replace the existing contents of the
  476. designated register.
  477. </para>
  478. </listitem>
  479. <listitem>
  480. <funcsynopsis>
  481. <funcprototype>
  482. <funcdef>public static void <function>append</function></funcdef>
  483. <paramdef>JEditTextArea <parameter>textArea</parameter></paramdef>
  484. <paramdef>char <parameter>register</parameter></paramdef>
  485. <paramdef>String <parameter>separator</parameter></paramdef>
  486. <paramdef>boolean <parameter>cut</parameter></paramdef>
  487. </funcprototype>
  488. </funcsynopsis>
  489. </listitem>
  490. <listitem>
  491. <funcsynopsis>
  492. <funcprototype>
  493. <funcdef>public static void <function>append</function></funcdef>
  494. <paramdef>JEditTextArea <parameter>textArea</parameter></paramdef>
  495. <paramdef>char <parameter>register</parameter></paramdef>
  496. <paramdef>String <parameter>separator</parameter></paramdef>
  497. </funcprototype>
  498. </funcsynopsis>
  499. </listitem>
  500. <listitem>
  501. <funcsynopsis>
  502. <funcprototype>
  503. <funcdef>public static void <function>append</function></funcdef>
  504. <paramdef>JEditTextArea <parameter>textArea</parameter></paramdef>
  505. <paramdef>char <parameter>register</parameter></paramdef>
  506. </funcprototype>
  507. </funcsynopsis>
  508. <para>
  509. These three methods append the selected text in the
  510. <parameter>textArea</parameter> to the designated register. If the
  511. <parameter>cut</parameter> parameter is not specified, the selected text
  512. remains in the text area. If the <parameter>separator</parameter>
  513. parameter is not specified, a newline character is used to separate the
  514. appended text from any existng register text.
  515. </para>
  516. </listitem>
  517. </itemizedlist>
  518. <para>
  519. The following methods provide a lower-level interface for working with
  520. registers:
  521. </para>
  522. <itemizedlist>
  523. <listitem>
  524. <funcsynopsis>
  525. <funcprototype>
  526. <funcdef>public static void <function>setRegister</function></funcdef>
  527. <paramdef>char <parameter>name</parameter></paramdef>
  528. <paramdef>Register <parameter>register</parameter></paramdef>
  529. </funcprototype>
  530. </funcsynopsis>
  531. </listitem>
  532. <listitem>
  533. <funcsynopsis>
  534. <funcprototype>
  535. <funcdef>public static void <function>setRegister</function></funcdef>
  536. <paramdef>char <parameter>name</parameter></paramdef>
  537. <paramdef>Register <parameter>newRegister</parameter></paramdef>
  538. </funcprototype>
  539. </funcsynopsis>
  540. </listitem>
  541. <listitem>
  542. <funcsynopsis>
  543. <funcprototype>
  544. <funcdef>public static void <function>clearRegister</function></funcdef>
  545. <paramdef>char <parameter>name</parameter></paramdef>
  546. </funcprototype>
  547. </funcsynopsis>
  548. <para>
  549. Sets the text of the designated register to <constant>null</constant>.
  550. If the register is one of the two registers reserved by the
  551. application (as discussed in the next section), the text value is
  552. set to an empty string.
  553. </para>
  554. </listitem>
  555. <listitem>
  556. <funcsynopsis>
  557. <funcprototype>
  558. <funcdef>public static Register <function>getRegister</function></funcdef>
  559. <paramdef>char <parameter>name</parameter></paramdef>
  560. </funcprototype>
  561. </funcsynopsis>
  562. </listitem>
  563. <listitem>
  564. <funcsynopsis>
  565. <funcprototype>
  566. <funcdef>public static Register[] <function>getRegisters</function></funcdef>
  567. <void/>
  568. </funcprototype>
  569. </funcsynopsis>
  570. </listitem>
  571. </itemizedlist>
  572. </sect1>
  573. <sect1 id="class-register"><title>Interface Registers.Register</title>
  574. <para>
  575. This interface requires implementation of two methods:
  576. <function>setValue()</function>, which takes a
  577. <classname>String</classname> parameter, and
  578. <function>toString()</function>, which return a textual representation
  579. of the register's contents. Two classes implement this interface. A
  580. <classname>ClipboardRegister</classname> is tied to the contents of the
  581. application's clipboard. The application assigns a
  582. <classname>ClipboardRegister</classname> to the register indexed under
  583. the character <filename>$</filename>. A
  584. <classname>StringRegister</classname> is created for registers assigned
  585. by the user. In addition, the application assigns to the
  586. <classname>StringRegister</classname> indexed under <filename>%</filename>
  587. the last text segment selected in the text area.
  588. </para>
  589. <para>
  590. A <classname>Register</classname> object does not maintain a copy of
  591. its index key. Indexing is performed by the <classname>Registers</classname>
  592. object.
  593. </para>
  594. </sect1>
  595. <!-- LaTeX spews with id's that are too long? -->
  596. <sect1 id="class-dockablewindowmanager"><title>Class DockableWindowManager</title>
  597. <para>
  598. Windows conforming to jEdit's dockable window API can appear in
  599. <quote>panes</quote> located above, below or to the left or right of the
  600. main editing pane. They can also be displayed in <quote>floating</quote>
  601. frame windows. A <classname>DockableWindowManager</classname> keeps
  602. track of the plugins associated with a particular
  603. <classname>View</classname>. Each <classname>View</classname> object
  604. contains an instance of this class.
  605. </para>
  606. <itemizedlist>
  607. <listitem>
  608. <funcsynopsis>
  609. <funcprototype>
  610. <funcdef>public DockableWindow <function>getDockableWindow</function></funcdef>
  611. <paramdef>String <parameter>name</parameter></paramdef>
  612. </funcprototype>
  613. </funcsynopsis>
  614. <para>
  615. This method returns the <classname>DockableWindow</classname>
  616. object named by the <varname>name</varname> parameter. The name of a
  617. <classname>DockableWindow</classname> is a required property of the
  618. plugin. If there is no <classname>DockableWindow</classname> bearing the
  619. requested name, the method returns <constant>null</constant>.
  620. </para>
  621. </listitem>
  622. <listitem>
  623. <funcsynopsis>
  624. <funcprototype>
  625. <funcdef>public void <function>addDockableWindow</function></funcdef>
  626. <paramdef>String <parameter>name</parameter></paramdef>
  627. </funcprototype>
  628. </funcsynopsis>
  629. <para>
  630. If the <classname>DockableWindow</classname> named by the
  631. <varname>name</varname> parameter does not exist, a message is
  632. sent to the associated plugin to create it. The
  633. <classname>DockableWindow</classname> is then made visible.
  634. </para>
  635. </listitem>
  636. <listitem>
  637. <funcsynopsis>
  638. <funcprototype>
  639. <funcdef>public void <function>showDockableWindow</function></funcdef>
  640. <paramdef>String <parameter>name</parameter></paramdef>
  641. </funcprototype>
  642. </funcsynopsis>
  643. </listitem>
  644. <listitem>
  645. <funcsynopsis>
  646. <funcprototype>
  647. <funcdef>public void <function>removeDockableWindow</function></funcdef>
  648. <paramdef>String <parameter>name</parameter></paramdef>
  649. </funcprototype>
  650. </funcsynopsis>
  651. </listitem>
  652. <listitem>
  653. <funcsynopsis>
  654. <funcprototype>
  655. <funcdef>public void <function>toggleDockableWindow</function></funcdef>
  656. <paramdef>String <parameter>name</parameter></paramdef>
  657. </funcprototype>
  658. </funcsynopsis>
  659. <para>
  660. These methods, respectively show, hide and toggle the visibility
  661. of the <classname>DockableWindow</classname> object named by
  662. the <varname>name</varname> parameter. If the
  663. <classname>DockableWindowManager</classname> does not contain a
  664. reference to the window, these methods send an error message to the
  665. activity log and have no other effect. Only
  666. <function>addDockableWindow()</function> can cause the creation
  667. of a <classname>DockableWindow</classname>.
  668. </para>
  669. </listitem>
  670. </itemizedlist>
  671. </sect1>
  672. <sect1 id="class-jedittextarea"><title>Class JEditTextArea</title>
  673. <para>
  674. This class is the visible component that displays the file
  675. being edited. It is derived from Java's <classname>JComponent</classname> class.
  676. </para>
  677. <para>
  678. Methods in this class that deal with selecting text
  679. rely upon classes derived from jEdit's
  680. <classname>Selection</classname> class. The
  681. <quote>Selection API</quote> permits selection and concurrent manipulation
  682. of multiple, non-contiguous regions of text. After describing the
  683. selection classes, we will outline the selection methods
  684. of <classname>JEditTextArea</classname>, followed by a listing of
  685. other methods in this class that are useful in writing macros.
  686. </para>
  687. <sect2 id="class-selection"><title>Class Selection</title>
  688. <para>
  689. This is an <glossterm>abstract class</glossterm> which holds data
  690. on a region of selected text. As an abstract class, it cannot be used
  691. directly, but instead serves as a parent class for specific types
  692. of selection structures. The definition of
  693. <classname>Selection</classname> contains two child classes used by the
  694. Selection API:
  695. </para>
  696. <itemizedlist>
  697. <listitem>
  698. <para>
  699. <classname>Selection.Range</classname> - representing an ordinary
  700. range of selected text
  701. </para>
  702. </listitem>
  703. <listitem>
  704. <para>
  705. <classname>Selection.Rect</classname> - representing a rectangular
  706. selection region
  707. </para>
  708. </listitem>
  709. </itemizedlist>
  710. <para>
  711. A new instance of either type of <classname>Selection</classname>
  712. can be created by specifying its starting and ending caret positions:
  713. </para>
  714. <informalexample><programlisting> selRange = new Selection.Range(start, end);
  715. setRect = new Selection.Rect(start, end);</programlisting></informalexample>
  716. <para>
  717. Both classes inherit or implement the following methods of the parent
  718. <classname>Selection</classname> class:
  719. </para>
  720. <itemizedlist>
  721. <listitem>
  722. <funcsynopsis>
  723. <funcprototype>
  724. <funcdef>public int <function>getStart</function></funcdef>
  725. <void/>
  726. </funcprototype>
  727. </funcsynopsis>
  728. </listitem>
  729. <listitem>
  730. <funcsynopsis>
  731. <funcprototype>
  732. <funcdef>public int <function>getEnd</function></funcdef>
  733. <void/>
  734. </funcprototype>
  735. </funcsynopsis>
  736. <para>
  737. Retrieves the buffer position representing the start or end
  738. of the selection.
  739. </para>
  740. </listitem>
  741. <listitem>
  742. <funcsynopsis>
  743. <funcprototype>
  744. <funcdef>public int <function>getStartLine</function></funcdef>
  745. <void/>
  746. </funcprototype>
  747. </funcsynopsis>
  748. </listitem>
  749. <listitem>
  750. <funcsynopsis>
  751. <funcprototype>
  752. <funcdef>public int <function>getEndLine</function></funcdef>
  753. <void/>
  754. </funcprototype>
  755. </funcsynopsis>
  756. <para>
  757. Retrieves the zero-based index number representing the line
  758. on which the selection starts or ends.
  759. </para>
  760. </listitem>
  761. <listitem>
  762. <funcsynopsis>
  763. <funcprototype>
  764. <funcdef>public int <function>getStart</function></funcdef>
  765. <paramdef>Buffer <parameter>buffer</parameter></paramdef>
  766. <paramdef>int <parameter>line</parameter></paramdef>
  767. </funcprototype>
  768. </funcsynopsis>
  769. </listitem>
  770. <listitem>
  771. <funcsynopsis>
  772. <funcprototype>
  773. <funcdef>public int <function>getEnd</function></funcdef>
  774. <paramdef>Buffer <parameter>buffer</parameter></paramdef>
  775. <paramdef>int <parameter>line</parameter></paramdef>
  776. </funcprototype>
  777. </funcsynopsis>
  778. <para>
  779. These two methods return the position of the beginning or end of
  780. that portion of the selection falling on the line referenced by
  781. the <parameter>line</parameter> parameter. The parameter
  782. <parameter>buffer</parameter> is required because a
  783. <classname>Selection</classname> object is a lightweight structure
  784. that does not contain a reference to the
  785. <classname>Buffer</classname> object to which it relates.
  786. </para>
  787. <para>
  788. These methods do not check whether the <parameter>line</parameter>
  789. parameter is within the range of lines actually covered by the
  790. selection. They would typically be used within a
  791. loop defined by the <function>getStartLine()</function> and
  792. <function>getEndLine()</function> methods to manipulate
  793. selection text on a line-by-line basis. Using them without range
  794. checking could cause unintended behavior.
  795. </para>
  796. </listitem>
  797. </itemizedlist>
  798. </sect2>
  799. <sect2 id="class-jedittextarea-selection"><title>Selection methods in
  800. JEditTextArea</title>
  801. <para>
  802. A <classname>JEditTextArea</classname> object maintains an
  803. <classname>Vector</classname> of current <classname>Selection</classname>
  804. objects. When a selection is added, the <classname>JEditTextArea</classname>
  805. attempts to merge the new selection with any existing selection whose range
  806. contains or overlaps with the new item. When selections are added or
  807. removed using by these methods, the editing display is updated to show
  808. the change in selection status.
  809. </para>
  810. <para>
  811. Here are the principal methods of <classname>JEditTextArea</classname>
  812. dealing with <classname>Selection</classname> objects:
  813. </para>
  814. <sect3 id="class-jedittextarea-selection-add-remove">
  815. <title>Adding and removing selections</title>
  816. <itemizedlist>
  817. <listitem>
  818. <funcsynopsis>
  819. <funcprototype>
  820. <funcdef>public void <function>setMultipleSelectionEnabled</function></funcdef>
  821. <paramdef>boolean <parameter>multi</parameter></paramdef>
  822. </funcprototype>
  823. </funcsynopsis>
  824. <para>
  825. Set multiple selection on or off according to the value of
  826. <parameter>multi</parameter>. This only affects the ability to
  827. make multiple selections in the user interface; macros and plugins
  828. can manipulate them regardless of the setting of this flag. In fact,
  829. in most cases, calling this method should not be necessary.
  830. </para>
  831. </listitem>
  832. <listitem>
  833. <funcsynopsis>
  834. <funcprototype>
  835. <funcdef>public Selection[] <function>getSelection</function></funcdef>
  836. <void/>
  837. </funcprototype>
  838. </funcsynopsis>
  839. <para>
  840. Returns an array containing a copy of the current selections.
  841. </para>
  842. </listitem>
  843. <listitem>
  844. <funcsynopsis>
  845. <funcprototype>
  846. <funcdef>public int <function>getSelectionCount</function></funcdef>
  847. <void/>
  848. </funcprototype>
  849. </funcsynopsis>
  850. <para>
  851. Returns the current number of selections. This can be used to test
  852. for the existence of selections.
  853. </para>
  854. </listitem>
  855. <listitem>
  856. <funcsynopsis>
  857. <funcprototype>
  858. <funcdef>public Selection <function>getSelectionAtOffset</function></funcdef>
  859. <paramdef>int <parameter>offset</parameter></paramdef>
  860. </funcprototype>
  861. </funcsynopsis>
  862. <para>
  863. Returns the <classname>Selection</classname> containing the specific offset,
  864. or <constant>null</constant> if there is no selection at that offset.
  865. </para>
  866. </listitem>
  867. <listitem>
  868. <funcsynopsis>
  869. <funcprototype>
  870. <funcdef>public void <function>addToSelection</function></funcdef>
  871. <paramdef>Selection <parameter>selection</parameter></paramdef>
  872. </funcprototype>
  873. </funcsynopsis>
  874. </listitem>
  875. <listitem>
  876. <funcsynopsis>
  877. <funcprototype>
  878. <funcdef>public void <function>addToSelection</function></funcdef>
  879. <paramdef>Selection[] <parameter>selection</parameter></paramdef>
  880. </funcprototype>
  881. </funcsynopsis>
  882. <para>
  883. Adds a single <classname>Selection</classname> or an array of
  884. <classname>Selection</classname> objects to the existing collection
  885. maintined by the <classname>JEditTextArea</classname>. Nested or
  886. overlapping selections will be merged where possible.
  887. </para>
  888. </listitem>
  889. <listitem>
  890. <funcsynopsis>
  891. <funcprototype>
  892. <funcdef>public void <function>extendSelection</function></funcdef>
  893. <paramdef>int <parameter>offset</parameter></paramdef>
  894. <paramdef>int <parameter>end</parameter></paramdef>
  895. </funcprototype>
  896. </funcsynopsis>
  897. <para>
  898. Extends the existing selection containing the position at
  899. <parameter>offset</parameter> to the position represented by
  900. <parameter>end</parameter>. If there is no selection containing
  901. <parameter>offset</parameter> the method creates a new
  902. <classname>Selection.Range</classname> extending from
  903. <parameter>offset</parameter> to <parameter>end</parameter> and
  904. adds it to the current collection.
  905. </para>
  906. </listitem>
  907. <listitem>
  908. <funcsynopsis>
  909. <funcprototype>
  910. <funcdef>public void <function>removeFromSelection</function></funcdef>
  911. <paramdef>Selection <parameter>sel</parameter></paramdef>
  912. </funcprototype>
  913. </funcsynopsis>
  914. </listitem>
  915. <listitem>
  916. <funcsynopsis>
  917. <funcprototype>
  918. <funcdef>public void <function>removeFromSelection</function></funcdef>
  919. <paramdef>int <parameter>offset</parameter></paramdef>
  920. </funcprototype>
  921. </funcsynopsis>
  922. <para>
  923. These methods remove a selection from the current collection. The
  924. second version removes any selection that contains the position at
  925. <parameter>offset</parameter>, and has no effect if no such
  926. selection exists.
  927. </para>
  928. </listitem>
  929. </itemizedlist>
  930. </sect3>
  931. <sect3 id="class-jedittextarea-selection-text">
  932. <title>Getting and setting selected text</title>
  933. <itemizedlist>
  934. <listitem>
  935. <funcsynopsis>
  936. <funcprototype>
  937. <funcdef>public String <function>getSelectedText</function></funcdef>
  938. <paramdef>Selection <parameter>s</parameter></paramdef>
  939. </funcprototype>
  940. </funcsynopsis>
  941. </listitem>
  942. <listitem>
  943. <funcsynopsis>
  944. <funcprototype>
  945. <funcdef>public String <function>getSelectedText</function></funcdef>
  946. <paramdef>String <parameter>separator</parameter></paramdef>
  947. </funcprototype>
  948. </funcsynopsis>
  949. </listitem>
  950. <listitem>
  951. <funcsynopsis>
  952. <funcprototype>
  953. <funcdef>public String <function>getSelectedText</function></funcdef>
  954. <void/>
  955. </funcprototype>
  956. </funcsynopsis>
  957. <para>
  958. These three methods return a <classname>String</classname> containing
  959. text corresponding to the current selections. The first version returns
  960. the text corresponding to a particular selection named as the parameter,
  961. allowing for iteration through the collection or focus on a specific
  962. selection (such as a selection containing the current caret position).
  963. The second version combines all selection text in a single
  964. <classname>String</classname>, separated by the
  965. <classname>String</classname> given as the
  966. <parameter>separator</parameter>. The final version operates like the
  967. second version, separating individual selections with newline characters.
  968. </para>
  969. </listitem>
  970. <listitem>
  971. <funcsynopsis>
  972. <funcprototype>
  973. <funcdef>public void <function>setSelectedText</function></funcdef>
  974. <paramdef>Selection <parameter>s</parameter></paramdef>
  975. <paramdef>String <parameter>selectedText</parameter></paramdef>
  976. </funcprototype>
  977. </funcsynopsis>
  978. </listitem>
  979. <listitem>
  980. <funcsynopsis>
  981. <funcprototype>
  982. <funcdef>public void <function>setSelectedText</function></funcdef>
  983. <paramdef>String <parameter>selectedText</parameter></paramdef>
  984. </funcprototype>
  985. </funcsynopsis>
  986. <para>
  987. The first version changes the text of the selection represented
  988. by <parameter>s</parameter> to
  989. <parameter>selectedText</parameter>. The second version sets the
  990. text of all active selections; if there are no selections, the
  991. text will be inserted at the current caret position.
  992. </para>
  993. <para>
  994. The second version of <function>setSelectedText()</function> is
  995. the method that will typically be used in macro scripts to insert
  996. text.
  997. </para>
  998. </listitem>
  999. <listitem>
  1000. <funcsynopsis>
  1001. <funcprototype>
  1002. <funcdef>public int[] <function>getSelectedLines</function></funcdef>
  1003. <void/>
  1004. </funcprototype>
  1005. </funcsynopsis>
  1006. <para>
  1007. Returns a sorted array of line numbers on which a selection or selections
  1008. are present. The current line is included in the array whether or
  1009. not it is part of a selection.
  1010. </para>
  1011. <para>
  1012. This method is the most convenient way to iterate through selected lines
  1013. in a buffer. The line numbers in the array returned by this method can
  1014. be passed as a parameter to such methods as
  1015. <function>getLineText()</function>, as discussed below.
  1016. </para>
  1017. </listitem>
  1018. </itemizedlist>
  1019. </sect3>
  1020. <sect3 id="class-jedittextarea-selection-other">
  1021. <title>Other selection methods</title>
  1022. <para>
  1023. The following methods perform selection operations without using
  1024. <classname>Selection</classname> objects as parameters or return
  1025. values. These methods should only be used in macros.
  1026. </para>
  1027. <itemizedlist>
  1028. <listitem>
  1029. <funcsynopsis>
  1030. <funcprototype>
  1031. <funcdef>public void <function>selectBlock</function></funcdef>
  1032. <void/>
  1033. </funcprototype>
  1034. </funcsynopsis>
  1035. <para>
  1036. Selects the code block surrounding the caret.
  1037. </para>
  1038. </listitem>
  1039. <listitem>
  1040. <funcsynopsis>
  1041. <funcprototype>
  1042. <funcdef>public void <function>selectWord</function></funcdef>
  1043. <void/>
  1044. </funcprototype>
  1045. </funcsynopsis>
  1046. </listitem>
  1047. <listitem>
  1048. <funcsynopsis>
  1049. <funcprototype>
  1050. <funcdef>public void <function>selectLine</function></funcdef>
  1051. <void/>
  1052. </funcprototype>
  1053. </funcsynopsis>
  1054. </listitem>
  1055. <listitem>
  1056. <funcsynopsis>
  1057. <funcprototype>
  1058. <funcdef>public void <function>selectParagraph</function></funcdef>
  1059. <void/>
  1060. </funcprototype>
  1061. </funcsynopsis>
  1062. </listitem>
  1063. <listitem>
  1064. <funcsynopsis>
  1065. <funcprototype>
  1066. <funcdef>public void <function>selectFold</function></funcdef>
  1067. <void/>
  1068. </funcprototype>
  1069. </funcsynopsis>
  1070. <para>
  1071. Selects the <quote>fold</quote> (a portion of text sharing a given
  1072. indentation level) that contains the line where the editing caret
  1073. is positioned.
  1074. </para>
  1075. </listitem>
  1076. <listitem>
  1077. <funcsynopsis>
  1078. <funcprototype>
  1079. <funcdef>public void <function>selectFoldAt</function></funcdef>
  1080. <paramdef>int <parameter>line</parameter></paramdef>
  1081. </funcprototype>
  1082. </funcsynopsis>
  1083. <para>
  1084. Selects the fold containing the line referenced by
  1085. <parameter>line</parameter>.
  1086. </para>
  1087. </listitem>
  1088. <listitem>
  1089. <funcsynopsis>
  1090. <funcprototype>
  1091. <funcdef>public void <function>selectAll</function></funcdef>
  1092. <void/>
  1093. </funcprototype>
  1094. </funcsynopsis>
  1095. </listitem>
  1096. <listitem>
  1097. <funcsynopsis>
  1098. <funcprototype>
  1099. <funcdef>public void <function>selectNone</function></funcdef>
  1100. <void/>
  1101. </funcprototype>
  1102. </funcsynopsis>
  1103. </listitem>
  1104. <listitem>
  1105. <funcsynopsis>
  1106. <funcprototype>
  1107. <funcdef>public void <function>indentSelectedLines</function></funcdef>
  1108. <void/>
  1109. </funcprototype>
  1110. </funcsynopsis>
  1111. </listitem>
  1112. </itemizedlist>
  1113. </sect3>
  1114. </sect2>
  1115. <sect2 id="class-jedittextarea-non-selection">
  1116. <title>Other methods in JEditTextArea</title>
  1117. <sect3 id="class-jedittextarea-caret">
  1118. <title>Editing caret methods</title>
  1119. <para>
  1120. These methods are used to get, set and move the position of the
  1121. editing caret:
  1122. </para>
  1123. <itemizedlist>
  1124. <listitem>
  1125. <funcsynopsis>
  1126. <funcprototype>
  1127. <funcdef>public int <function>getCaretPosition</function></funcdef>
  1128. <void/>
  1129. </funcprototype>
  1130. </funcsynopsis>
  1131. <para>
  1132. Returns a zero-based index of the caret position in the existing buffer.
  1133. </para>
  1134. </listitem>
  1135. <listitem>
  1136. <funcsynopsis>
  1137. <funcprototype>
  1138. <funcdef>public void <function>setCaretPosition</function></funcdef>
  1139. <paramdef>int <parameter>caret</parameter></paramdef>
  1140. </funcprototype>
  1141. </funcsynopsis>
  1142. <para>
  1143. Sets the caret position at <parameter>caret</parameter> and deactivates
  1144. any selection of text.
  1145. </para>
  1146. </listitem>
  1147. <listitem>
  1148. <funcsynopsis>
  1149. <funcprototype>
  1150. <funcdef>public void <function>moveCaretPosition</function></funcdef>
  1151. <paramdef>int <parameter>caret</parameter></paramdef>
  1152. </funcprototype>
  1153. </funcsynopsis>
  1154. <para>
  1155. This moves the caret to the position represented by
  1156. <parameter>caret</parameter> without affecting any selection of
  1157. text.
  1158. </para>
  1159. </listitem>
  1160. <listitem>
  1161. <funcsynopsis>
  1162. <funcprototype>
  1163. <funcdef>public int <function>getCaretLine</function></funcdef>
  1164. <void/>
  1165. </funcprototype>
  1166. </funcsynopsis>
  1167. <para>
  1168. Returns the line on which the caret is positioned.
  1169. </para>
  1170. </listitem>
  1171. </itemizedlist>
  1172. <para>
  1173. Each of the following shortcut methods moves the caret. If the
  1174. <parameter>select</parameter> parameter is set to
  1175. <constant>true</constant>, the intervening text will be selected
  1176. as well.
  1177. </para>
  1178. <itemizedlist>
  1179. <listitem>
  1180. <funcsynopsis>
  1181. <funcprototype>
  1182. <funcdef>public void <function>goToStartOfLine</function></funcdef>
  1183. <paramdef>boolean <parameter>select</parameter></paramdef>
  1184. </funcprototype>
  1185. </funcsynopsis>
  1186. </listitem>
  1187. <listitem>
  1188. <funcsynopsis>
  1189. <funcprototype>
  1190. <funcdef>public void <function>goToEndOfLine</function></funcdef>
  1191. <paramdef>boolean <parameter>select</parameter></paramdef>
  1192. </funcprototype>
  1193. </funcsynopsis>
  1194. </listitem>
  1195. <listitem>
  1196. <funcsynopsis>
  1197. <funcprototype>
  1198. <funcdef>public void <function>goToStartOfWhiteSpace</function></funcdef>
  1199. <paramdef>boolean <parameter>select</parameter></paramdef>
  1200. </funcprototype>
  1201. </funcsynopsis>
  1202. </listitem>
  1203. <listitem>
  1204. <funcsynopsis>
  1205. <funcprototype>
  1206. <funcdef>public void <function>goToEndOfWhiteSpace</function></funcdef>
  1207. <paramdef>boolean <parameter>select</parameter></paramdef>
  1208. </funcprototype>
  1209. </funcsynopsis>
  1210. </listitem>
  1211. <listitem>
  1212. <funcsynopsis>
  1213. <funcprototype>
  1214. <funcdef>public void <function>goToFirstVisibleLine</function></funcdef>
  1215. <paramdef>boolean <parameter>select</parameter></paramdef>
  1216. </funcprototype>
  1217. </funcsynopsis>
  1218. </listitem>
  1219. <listitem>
  1220. <funcsynopsis>
  1221. <funcprototype>
  1222. <funcdef>public void <function>goToLastVisibleLine</function></funcdef>
  1223. <paramdef>boolean <parameter>select</parameter></paramdef>
  1224. </funcprototype>
  1225. </funcsynopsis>
  1226. </listitem>
  1227. <listitem>
  1228. <funcsynopsis>
  1229. <funcprototype>
  1230. <funcdef>public void <function>goToNextCharacter</function></funcdef>
  1231. <paramdef>boolean <parameter>select</parameter></paramdef>
  1232. </funcprototype>
  1233. </funcsynopsis>
  1234. </listitem>
  1235. <listitem>
  1236. <funcsynopsis>
  1237. <funcprototype>
  1238. <funcdef>public void <function>goToPrevCharacter</function></funcdef>
  1239. <paramdef>boolean <parameter>select</parameter></paramdef>
  1240. </funcprototype>
  1241. </funcsynopsis>
  1242. </listitem>
  1243. <listitem>
  1244. <funcsynopsis>
  1245. <funcprototype>
  1246. <funcdef>public void <function>goToNextWord</function></funcdef>
  1247. <paramdef>boolean <parameter>select</parameter></paramdef>
  1248. </funcprototype>
  1249. </funcsynopsis>
  1250. </listitem>
  1251. <listitem>
  1252. <funcsynopsis>
  1253. <funcprototype>
  1254. <funcdef>public void <function>goToPrevWord</function></funcdef>
  1255. <paramdef>boolean <parameter>select</parameter></paramdef>
  1256. </funcprototype>
  1257. </funcsynopsis>
  1258. </listitem>
  1259. <listitem>
  1260. <funcsynopsis>
  1261. <funcprototype>
  1262. <funcdef>public void <function>goToNextLine</function></funcdef>
  1263. <paramdef>boolean <parameter>select</parameter></paramdef>
  1264. </funcprototype>
  1265. </funcsynopsis>
  1266. </listitem>
  1267. <listitem>
  1268. <funcsynopsis>
  1269. <funcprototype>
  1270. <funcdef>public void <function>goToPrevLine</function></funcdef>
  1271. <paramdef>boolean <parameter>select</parameter></paramdef>
  1272. </funcprototype>
  1273. </funcsynopsis>
  1274. </listitem>
  1275. <listitem>
  1276. <funcsynopsis>
  1277. <funcprototype>
  1278. <funcdef>public void <function>goToNextParagraph</function></funcdef>
  1279. <paramdef>boolean <parameter>select</parameter></paramdef>
  1280. </funcprototype>
  1281. </funcsynopsis>
  1282. </listitem>
  1283. <listitem>
  1284. <funcsynopsis>
  1285. <funcprototype>
  1286. <funcdef>public void <function>goToPrevParagraph</function></funcdef>
  1287. <paramdef>boolean <parameter>select</parameter></paramdef>
  1288. </funcprototype>
  1289. </funcsynopsis>
  1290. </listitem>
  1291. <listitem>
  1292. <funcsynopsis>
  1293. <funcprototype>
  1294. <funcdef>public void <function>goToNextBracket</function></funcdef>
  1295. <paramdef>boolean <parameter>select</parameter></paramdef>
  1296. </funcprototype>
  1297. </funcsynopsis>
  1298. </listitem>
  1299. <listitem>
  1300. <funcsynopsis>
  1301. <funcprototype>
  1302. <funcdef>public void <function>goToPrevBracket</function></funcdef>
  1303. <paramdef>boolean <parameter>select</parameter></paramdef>
  1304. </funcprototype>
  1305. </funcsynopsis>
  1306. </listitem>
  1307. </itemizedlist>
  1308. </sect3>
  1309. <!-- open sect3 -->
  1310. <sect3 id="class-jedittextarea-scrolling">
  1311. <title>Methods for scrolling the text area</title>
  1312. <itemizedlist>
  1313. <listitem>
  1314. <funcsynopsis>
  1315. <funcprototype>
  1316. <funcdef>public void <function>scrollUpLine</function></funcdef>
  1317. <void/>
  1318. </funcprototype>
  1319. </funcsynopsis>
  1320. </listitem>
  1321. <listitem>
  1322. <funcsynopsis>
  1323. <funcprototype>
  1324. <funcdef>public void <function>scrollUpPage</function></funcdef>
  1325. <void/>
  1326. </funcprototype>
  1327. </funcsynopsis>
  1328. </listitem>
  1329. <listitem>
  1330. <funcsynopsis>
  1331. <funcprototype>
  1332. <funcdef>public void <function>scrollDownLine</function></funcdef>
  1333. <void/>
  1334. </funcprototype>
  1335. </funcsynopsis>
  1336. </listitem>
  1337. <listitem>
  1338. <funcsynopsis>
  1339. <funcprototype>
  1340. <funcdef>public void <function>scrollUpPage</function></funcdef>
  1341. <void/>
  1342. </funcprototype>
  1343. </funcsynopsis>
  1344. </listitem>
  1345. <listitem>
  1346. <funcsynopsis>
  1347. <funcprototype>
  1348. <funcdef>public void <function>scrollToCaret</function></funcdef>
  1349. <paramdef>boolean <parameter>doElectricScroll</parameter></paramdef>
  1350. </funcprototype>
  1351. </funcsynopsis>
  1352. <para>
  1353. Scrolls the text area to ensure that the caret is visible. The
  1354. <parameter>doElectricScroll</parameter> parameter detemines whether
  1355. <quote>electric scrolling</quote> will occur. This leaves a minimum
  1356. number of lines between the caret line and the top and bottom of the
  1357. editing pane.
  1358. </para>
  1359. </listitem>
  1360. <listitem>
  1361. <funcsynopsis>
  1362. <funcprototype>
  1363. <funcdef>public void <function>centerCaret</function></funcdef>
  1364. <void/>
  1365. </funcprototype>
  1366. </funcsynopsis>
  1367. <para>
  1368. Scrolls the text area so that the line containing the edit caret is
  1369. vertically centered.
  1370. </para>
  1371. </listitem>
  1372. <listitem>
  1373. <funcsynopsis>
  1374. <funcprototype>
  1375. <funcdef>public void <function>setFirstLine</function></funcdef>
  1376. <paramdef>int <parameter>firstLine</parameter></paramdef>
  1377. </funcprototype>
  1378. </funcsynopsis>
  1379. </listitem>
  1380. <listitem>
  1381. <funcsynopsis>
  1382. <funcprototype>
  1383. <funcdef>public int <function>getFirstLine</function></funcdef>
  1384. <void/>
  1385. </funcprototype>
  1386. </funcsynopsis>
  1387. <para>
  1388. This pair of methods deals with the line number of the first line
  1389. displayed at the top of the text area. Lines that are hidden by folds or
  1390. narrowing are ignored when making this <quote>virtual</quote> line
  1391. count, so the line number will not necessarily conform to the line
  1392. numbers displayed in the text area's gutter. In addition, the virtual
  1393. line index is zero-based, so <function>getFirstLine()</function> will
  1394. always return zero for the first line of text.
  1395. </para>
  1396. <para>
  1397. To convert a virtual line count to a physical count or vice versa,
  1398. see <xref linkend="class-buffer-virtual-lines" />.
  1399. </para>
  1400. </listitem>
  1401. <listitem>
  1402. <funcsynopsis>
  1403. <funcprototype>
  1404. <funcdef>public void <function>setElectricScroll</function></funcdef>
  1405. <paramdef>int <parameter>electricScroll</parameter></paramdef>
  1406. </funcprototype>
  1407. </funcsynopsis>
  1408. </listitem>
  1409. <listitem>
  1410. <funcsynopsis>
  1411. <funcprototype>
  1412. <funcdef>public int <function>getElectricScroll</function></funcdef>
  1413. <void/>
  1414. </funcprototype>
  1415. </funcsynopsis>
  1416. <para>
  1417. The <quote>electric scroll</quote> attribute is the number of lines
  1418. above and below the editing caret that always remain visible when
  1419. scrolling.
  1420. </para>
  1421. </listitem>
  1422. </itemizedlist>
  1423. </sect3>
  1424. <sect3 id="class-jedittextarea-position">
  1425. <title>Methods for calculating editing positions</title>
  1426. <itemizedlist>
  1427. <listitem>
  1428. <funcsynopsis>
  1429. <funcprototype>
  1430. <funcdef>public int <function>getLineOfOffset</function></funcdef>
  1431. <paramdef>int <parameter>offset</parameter></paramdef>
  1432. </funcprototype>
  1433. </funcsynopsis>
  1434. <para>
  1435. Returns the line on which the given offset is found.
  1436. </para>
  1437. </listitem>
  1438. <listitem>
  1439. <funcsynopsis>
  1440. <funcprototype>
  1441. <funcdef>public int <function>getLineStartOffset</function></funcdef>
  1442. <paramdef>int <parameter>line</parameter></paramdef>
  1443. </funcprototype>
  1444. </funcsynopsis>
  1445. </listitem>
  1446. <listitem>
  1447. <funcsynopsis>
  1448. <funcprototype>
  1449. <funcdef>public int <function>getLineEndOffset</function></funcdef>
  1450. <paramdef>int <parameter>line</parameter></paramdef>
  1451. </funcprototype>
  1452. </funcsynopsis>
  1453. <para>
  1454. Returns the offset of the beginning or end of the given line.
  1455. </para>
  1456. </listitem>
  1457. </itemizedlist>
  1458. </sect3>
  1459. <sect3 id="class-jedittextarea-gettext">
  1460. <title>Other methods for retrieving text</title>
  1461. <para>
  1462. These methods can retrieve buffer text without regard
  1463. to a selection or the position of the editing caret.
  1464. </para>
  1465. <itemizedlist>
  1466. <listitem>
  1467. <funcsynopsis>
  1468. <funcprototype>
  1469. <funcdef>public String <function>getText</function></funcdef>
  1470. <paramdef>int <parameter>start</parameter></paramdef>
  1471. <paramdef>int <parameter>len</parameter></paramdef>
  1472. </funcprototype>
  1473. </funcsynopsis>
  1474. <para>
  1475. Returns the text located between buffer offset positions.
  1476. </para>
  1477. </listitem>
  1478. <listitem>
  1479. <funcsynopsis>
  1480. <funcprototype>
  1481. <funcdef>public String <function>getLineText</function></funcdef>
  1482. <paramdef>int <parameter>lineIndex</parameter></paramdef>
  1483. </funcprototype>
  1484. </funcsynopsis>
  1485. <para>
  1486. Returns the text on the given line.
  1487. </para>
  1488. </listitem>
  1489. <listitem>
  1490. <funcsynopsis>
  1491. <funcprototype>
  1492. <funcdef>public String <function>getText</function></funcdef>
  1493. <void/>
  1494. </funcprototype>
  1495. </funcsynopsis>
  1496. <para>
  1497. Returns the entire text in the text area.
  1498. </para>
  1499. </listitem>
  1500. <listitem>
  1501. <funcsynopsis>
  1502. <funcprototype>
  1503. <funcdef>public void <function>setText</function></funcdef>
  1504. <paramdef>String <parameter>text</parameter></paramdef>
  1505. </funcprototype>
  1506. </funcsynopsis>
  1507. <para>
  1508. Sets (and replaces) the entire text of the text area.
  1509. </para>
  1510. </listitem>
  1511. </itemizedlist>
  1512. </sect3>
  1513. <sect3 id="class-jedittextar…