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

/bundles/plugins-trunk/SideKick/users-guide.xml

#
XML | 448 lines | 368 code | 78 blank | 2 comment | 0 complexity | 543b9903c13a2895538c8516f388b37c 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. <?xml version="1.0" encoding="utf-8"?>
  2. <book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:noNamespaceSchemaLocation='http://www.docbook.org/xsd/4.4/docbook.xsd' >
  4. <!-- jEdit buffer-local properties: -->
  5. <!-- :indentSize=2:noTabs=true:folding=sidekick: -->
  6. <bookinfo>
  7. <title>SideKick plugin user's guide</title>
  8. <authorgroup>
  9. <author>
  10. <firstname>Slava</firstname>
  11. <surname>Pestov</surname>
  12. </author>
  13. <author>
  14. <firstname>Dale</firstname>
  15. <surname>Anson</surname>
  16. </author>
  17. <author>
  18. <firstname>Martin</firstname>
  19. <surname>Raspe</surname>
  20. </author>
  21. <author>
  22. <firstname>Alan</firstname>
  23. <surname>Ezust</surname>
  24. </author>
  25. <author>
  26. <firstname>Shlomy</firstname>
  27. <surname>Reinstein</surname>
  28. </author>
  29. </authorgroup>
  30. <legalnotice>
  31. <title>Legal Notice</title>
  32. <para>
  33. Permission is granted to copy, distribute and/or modify this document
  34. under the terms of the GNU Free Documentation License, Version 1.1 or
  35. any later version published by the Free Software Foundation; with no
  36. <quote>Invariant Sections</quote>, <quote>Front-Cover Texts</quote> or
  37. <quote>Back-Cover Texts</quote>, each as defined in the license. A copy of
  38. the license can be found in the file <filename>COPYING.DOC.txt</filename>
  39. included with jEdit.
  40. </para>
  41. <para>
  42. The SideKick plugin itself is released under the GNU General Public License.
  43. A copy of the GPL can be found in the jEdit online help.
  44. </para>
  45. </legalnotice>
  46. </bookinfo>
  47. <chapter id="browser">
  48. <title>The SideKick dockable</title>
  49. <para>
  50. The SideKick plugin provides a dockable in which other plugins can
  51. display buffer structure.
  52. </para>
  53. <para>
  54. <guimenu>Plugins</guimenu>&gt;<guisubmenu>SideKick</guisubmenu>&gt;<guimenuitem>SideKick</guimenuitem> displays the current buffer's structure in a dockable window. This window is floating by default, but it can be docked into the view 2 ways.
  55. </para>
  56. <orderedlist>
  57. <listitem>
  58. <para> Choosing a docking area from the docking menu (a little arrow in the upper left corner of each floating dockable)</para>
  59. </listitem>
  60. <listitem>
  61. <para> Go to the <guibutton>Docking</guibutton>
  62. pane of the <guimenuitem>Global Options</guimenuitem> dialog box </para>
  63. </listitem>
  64. </orderedlist>
  65. <para> On the top of the window, you will see a combobox which lists all installed SideKick parsers. You can switch to another parser temporarily for a buffer by selecting it from the combo box. </para>
  66. <para>
  67. The SideKick plugin can automatically parse your buffer depending on various events, such as: Buffer Switch, Buffer Save, or on the fly (after it is idle for a period of time). The last option is rarely used since it can eat up CPU time, so it is disabled by default. </para>
  68. <para>
  69. <guimenu>Plugins</guimenu>&gt;<guisubmenu>SideKick</guisubmenu>&gt;<guimenuitem>Parse
  70. on Keystroke</guimenuitem> is a checkbox menu item that toggles on-the-fly parsing, for the current buffer only.
  71. </para>
  72. <para> You can also manually parse a buffer by clicking on the "Parse" button in the Sidekick dockable, or through a keyboard shortcut, if you bind Sidekick's "parse buffer" action to a keystroke. <footnote><para>
  73. global options - jedit - Shortcuts - Plugin: Sidekick (combo) - Parse Buffer</para>
  74. </footnote>
  75. </para>
  76. <para>
  77. The current buffer can be parsed at any other time by clicking the parse
  78. button in the <guimenuitem>Sidekick</guimenuitem> window, or by
  79. invoking the
  80. <guimenu>Plugins</guimenu>&gt;<guisubmenu>SideKick</guisubmenu>&gt;<guimenuitem>Parse
  81. Buffer</guimenuitem> command.
  82. </para>
  83. <tip>
  84. <title> Parse button menu </title>
  85. <para> A popup menu is available in JDK 1.5 which
  86. appears when you right-click the "Parse" button.
  87. From there, you can set some auto-parse options
  88. without going to the plugin options. </para>
  89. </tip>
  90. <tip>
  91. <title> Mode Options </title>
  92. <para> SideKick supports what are called "Mode Options". Certain properties can be set on an edit-mode basis, such as the SideKick parser, tree expansion depth, etc. Other plugins (such as CtagsSideKick) added their own optionpane to this dialog, via the
  93. services API. </para>
  94. </tip>
  95. <tip>
  96. <title> Filter textfield </title>
  97. <para>
  98. Also at the top of the window is a "Filter" box. Entering text into the box will cause the tree to collapse to show only those items in the tree whose names contain the text in the filter box. This makes it easy to quickly locate items in the tree. By default, clicking on an item in the tree clears the filter, but this can be changed in the SideKick plugin option settings by using the "Filter persists after tree selection" checkbox.
  99. </para>
  100. <para>
  101. You don't have to click into the filter box to begin typing. As long as SideKick has focus, keystrokes are automatically sent to the box to make locating items even faster.
  102. </para>
  103. </tip>
  104. <para>
  105. Any errors found while parsing the buffer are sent to the
  106. <application>ErrorList</application> plugin, which means they are highlighted
  107. in the text area, and shown in the
  108. <guimenu>Plugins</guimenu>&gt;<guisubmenu>Error
  109. List</guisubmenu>&gt; window. See the
  110. documentation for the <application>ErrorList</application> plugin for details.
  111. </para>
  112. <para>
  113. Clicking on a node in the tree will move the caret to its location in the
  114. buffer;
  115. conversely, moving the caret in the buffer will select the corresponding
  116. node.
  117. </para>
  118. <para>
  119. <keycap>Shift</keycap>-clicking on a node will select that node in the text
  120. area. <keycap>Alt</keycap>-clicking on a node will narrow the text area
  121. display to that node.
  122. </para>
  123. <para>
  124. If SideKick is docked into the current view, hovering the mouse
  125. over a node will display its attributes in the status bar.
  126. </para>
  127. </chapter>
  128. <chapter id="moving-around">
  129. <title>Moving around</title>
  130. <para>
  131. <guimenu>Plugins</guimenu>&gt;<guisubmenu>SideKick</guisubmenu>&gt;<guimenuitem>Go
  132. to Previous Asset</guimenuitem> moves the caret to start of the structure
  133. element (<quote>asset</quote>).
  134. </para>
  135. <para>
  136. <guimenu>Plugins</guimenu>&gt;<guisubmenu>SideKick</guisubmenu>&gt;<guimenuitem>Go
  137. to Next Asset</guimenuitem> moves the caret to start of the next asset.
  138. </para>
  139. <para>
  140. <guimenu>Plugins</guimenu>&gt;<guisubmenu>SideKick</guisubmenu>&gt;<guimenuitem>Select
  141. Asset at Caret</guimenuitem> selects the asset at the caret position.
  142. </para>
  143. <bridgehead> Keyboard Shortcuts </bridgehead>
  144. <itemizedlist>
  145. <listitem><para> Up and Down arrow keys let you navigate between sibling nodes,
  146. or to parents/children of exploded nodes. </para></listitem>
  147. <listitem><para> Ctrl+Up and Ctrl+Down keys go to previous/next asset.
  148. </para></listitem>
  149. <listitem><para> Right and Left arrow keys expand and collapse tree nodes.
  150. </para></listitem>
  151. </itemizedlist>
  152. </chapter>
  153. <chapter id="toolbar">
  154. <title>Toolbar</title>
  155. <para>
  156. SideKick can optionally display the structure of the buffer in a toolbar, using
  157. one or more combo-boxes. This option is useful where screen real-estate is
  158. important and the tree takes too much of the screen. To use this option, select
  159. <guimenu>Plugins</guimenu>&gt;<guisubmenu>SideKick</guisubmenu>&gt;
  160. <guisubmenu>General</guisubmenu>&gt;<guimenuitem>Show the assets in a
  161. combo-box (inside a toolbar)</guimenuitem>.
  162. By default, a single combo-box is shown, which can be used to jump to various
  163. positions inside the buffer.
  164. </para>
  165. <para>
  166. There is also an option to show a separate check-box for each level in the
  167. SideKick tree. To use this option, select
  168. <guimenu>Plugins</guimenu>&gt;<guisubmenu>SideKick</guisubmenu>&gt;
  169. <guisubmenu>General</guisubmenu>&gt;<guimenuitem>Use a separate combo-box
  170. for each level of the tree</guimenuitem>.
  171. </para>
  172. <para>
  173. To make the combo-box (or multiple combo-boxes) show the asset where the caret is
  174. currently located, select
  175. <guimenu>Plugins</guimenu>&gt;<guisubmenu>SideKick</guisubmenu>&gt;
  176. <guisubmenu>General</guisubmenu>&gt;<guimenuitem>Tree/combo-box selection
  177. follows caret position</guimenuitem>.
  178. </para>
  179. </chapter>
  180. <chapter id="folding">
  181. <title>Folding</title>
  182. <para>
  183. The SideKick plugin adds a new <quote>sidekick</quote> fold handler that
  184. folds the buffer according to the structure tree. See the jEdit user's guide
  185. for general details about folding.
  186. </para>
  187. <para>
  188. <guimenu>Plugins</guimenu>&gt;<guisubmenu>SideKick</guisubmenu>&gt;<guimenuitem>Narrow to
  189. Asset at Caret</guimenuitem> hides all text except that of the asset at the
  190. caret location. This works in any folding mode, not just the <quote>sidekick</quote>
  191. mode.
  192. </para>
  193. </chapter>
  194. <chapter id="completion">
  195. <title>Completion</title>
  196. <para>
  197. A completion popup can be shown at any time
  198. by invoking the
  199. <guimenu>Plugins</guimenu>&gt;<guisubmenu>SideKick</guisubmenu>&gt;<guimenuitem>Show
  200. Completion Popup</guimenuitem> command. Each plugin that uses SideKick
  201. implements its own specific completion behavior; see the plugin documentation
  202. for details.
  203. </para>
  204. </chapter>
  205. <chapter id="other-plugins">
  206. <title>Developing SideKick back-ends</title>
  207. <para>
  208. By itself the SideKick plugin is not very useful; it relies on other plugins to
  209. provide buffer structure information. This chapter gives a brief overview of
  210. how it's done.
  211. </para>
  212. <sect1 id="preliminaries">
  213. <title>Preliminaries</title>
  214. <para>
  215. First you will also need to add a dependency for the SideKick plugin in your plugin's
  216. property file:
  217. </para>
  218. <programlisting>plugin.MyPlugin.depend.<replaceable>n</replaceable>=plugin sidekick.SideKickPlugin 0.1</programlisting>
  219. <para>
  220. Note that you must replace <replaceable>n</replaceable> with the
  221. appropriate number, as dependency properties must have consecutive numbers.
  222. </para>
  223. <para>
  224. All SideKick plugin classes are in the <classname>sidekick</classname> package;
  225. you will need to add <literal>import</literal> statements where appropriate.
  226. </para>
  227. <para>
  228. Parser instances must be registered using the
  229. <literal>services.xml</literal> file. With this, you define a service which
  230. returns a derived instance of <ulink url="jeditresource:/Sidekick.jar!/docs/api/sidekick/SideKickParser.html">
  231. <classname>SideKickParser</classname>
  232. </ulink>
  233. </para>
  234. <programlisting>
  235. &lt;?xml version=&quot;1.0&quot;?&gt;
  236. &lt;!DOCTYPE SERVICES SYSTEM &quot;services.dtd&quot;&gt;
  237. &lt;SERVICES&gt;
  238. &lt;SERVICE CLASS=&quot;sidekick.SideKickParser&quot; NAME=&quot;xml&quot;&gt;
  239. new xml.parser.SAXParserImpl();
  240. &lt;/SERVICE&gt;
  241. &lt;/SERVICES&gt;
  242. </programlisting>
  243. </sect1>
  244. <sect1 id="class-sidekickparser">
  245. <title>The SideKickParser class</title>
  246. <para>
  247. <ulink url="jeditresource:/Sidekick.jar!/docs/api/sidekick/SideKickParser.html">
  248. <classname>SideKickParser</classname>
  249. </ulink> is an abstract class. The constructor takes one string parameter. This string is used in several properties:
  250. </para>
  251. <itemizedlist>
  252. <listitem>
  253. <para>
  254. <literal>sidekick.parser.<replaceable>name</replaceable>.label</literal>
  255. - specifies a human-readable label for the parser, shown in status messages. </para>
  256. <para> Your derived parser class should return this same name from the <literal>getName()</literal> function.
  257. </para>
  258. </listitem>
  259. <listitem>
  260. <para>
  261. <literal>mode.<replaceable>mode</replaceable>.sidekick.parser</literal>
  262. - properties of this form are used to associate a parser with an edit mode.
  263. </para>
  264. </listitem>
  265. </itemizedlist>
  266. <para>
  267. For example, the XML plugin, which used to provide two <classname>SideKickParser</classname>
  268. implementations, had these properties:
  269. </para>
  270. <programlisting>sidekick.parser.xml.label=XML
  271. mode.xml.sidekick.parser=xml
  272. mode.xsl.sidekick.parser=xml
  273. sidekick.parser.html.label=HTML
  274. mode.asp.sidekick.parser=html
  275. mode.coldfusion.sidekick.parser=html
  276. mode.html.sidekick.parser=html
  277. mode.jhtml.sidekick.parser=html
  278. mode.jsp.sidekick.parser=html
  279. mode.php.sidekick.parser=html
  280. mode.shtml.sidekick.parser=html
  281. mode.sgml.sidekick.parser=html
  282. mode.velocity.sidekick.parser=html</programlisting>
  283. </sect1>
  284. <sect1 id="implement-structure-tree">
  285. <title>Implementing a structure tree</title>
  286. <para>
  287. The <ulink url="jeditresource:/Sidekick.jar!/docs/api/sidekick/SideKickParser.html">
  288. <classname>SideKickParser</classname>
  289. </ulink> has one abstract method that all
  290. subclasses must implement:
  291. </para>
  292. <funcsynopsis>
  293. <funcprototype>
  294. <funcdef>public
  295. SideKickParsedData <function>parse</function>
  296. </funcdef>
  297. <paramdef>Buffer <parameter>buffer</parameter>
  298. </paramdef>
  299. <paramdef>DefaultErrorSource <parameter>errorSource</parameter>
  300. </paramdef>
  301. </funcprototype>
  302. </funcsynopsis>
  303. <para>
  304. The <literal>errorSource</literal> is an instance of a class provided by the
  305. <application>ErrorList</application> plugin; consult its documentation for
  306. details.
  307. </para>
  308. <para>
  309. The method is called from a thread, so care must be taken to access the
  310. buffer in a thread-safe manner; the API documentation for the
  311. <classname>Buffer</classname> class describes how this is done.
  312. </para>
  313. <para>
  314. Your implementation of the <function>parse()</function> method should create and return
  315. an instance of
  316. <ulink url="jeditresource:/Sidekick.jar!/docs/api/sidekick/SideKickParsedData.html">SideKickParsedData </ulink>. Its constructor of the takes one parameter, which is the file name (to be shown at the root of the structure tree). Your method should
  317. add structure elements to the <varname>root</varname> field of the instance.
  318. <varname>root</varname> is an instance of Java's <classname>DefaultMutableTreeNode</classname> class,
  319. and is given an initial value by the <classname>SideKickParsedData</classname> constructor.
  320. </para>
  321. <formalpara id="optionalPanel">
  322. <title> getPanel() </title>
  323. <para> Some SideKick parsers, such as CtagsSideKick, offer an additional toolbar to provide a convenient interface to change certain mode options such as sort by, and group by. They achieve this by overriding the <literal>getPanel()</literal> method of SideKickParser. </para>
  324. </formalpara>
  325. </sect1>
  326. <sect1 id="implement-completion">
  327. <title>Implementing completion popups</title>
  328. <para> Your derived instance of
  329. <ulink url="jeditresource:/Sidekick.jar!/docs/api/sidekick/SideKickParser.html">
  330. SideKickParser</ulink> can implement additional
  331. methods to tell Sidekick that your parser supports completions.
  332. </para>
  333. <programlisting>
  334. /* @return true if plugin supports completion */
  335. public boolean supportsCompletion();
  336. /* @return true if we show completions after a period of inactivity. */
  337. public boolean canCompleteAnywhere() ;
  338. /* @return a list of characters which trigger completion immediately. */
  339. public String getInstantCompletionTriggers();
  340. /* @return all completions at a given caret position for this
  341. editpane */
  342. public SideKickCompletion complete(EditPane editPane, int caret)
  343. </programlisting>
  344. <para> If your SideKickParser does support completion, the actual
  345. brains of the plugin goes in the last method, <literal>complete()</literal>,
  346. which must construct an instance of <ulink url="jeditresource:/Sidekick.jar!/docs/api/sidekick/SideKickCompletion.html">
  347. SideKickCompletion</ulink>, given an <literal>EditPane</literal> and a caret position.
  348. </para>
  349. <para>
  350. The constructor for <literal>SideKickCompletion</literal> accepts a list (or array) of possible values, these are the values that are displayed in the dropdown.
  351. This is an abstract class, so you'll need to derive a specific implementation. You may want to override the 'insert(int)' method to
  352. support language specifics, like "dot" completion.
  353. </para>
  354. <para>How you actually create the completion depends on the specific language and support classes, and the information provided by the parser for the current file. </para>
  355. </sect1>
  356. </chapter>
  357. <appendix id="futureplans">
  358. <title> Future Plans </title>
  359. <itemizedlist>
  360. <listitem>
  361. <para> Adding a Help tooltip to the CompletionPopup window and methods to the CompletinoInfo for getting/setting help.
  362. </para>
  363. </listitem>
  364. </itemizedlist>
  365. </appendix>
  366. <appendix id="changes">
  367. <title>Changes</title>
  368. <para> Click <ulink url="CHANGES.txt">here</ulink> to see the detailed changes. </para>
  369. </appendix>
  370. </book>