PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/doc/users-guide/plugin-tips.xml

#
XML | 160 lines | 149 code | 8 blank | 3 comment | 0 complexity | 4ccd8c54139f16f1b0aab8ed7f16f98a 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. <chapter id="plugin-tips">
  3. <title>Plugin Tips and Techniques</title>
  4. <!-- jEdit buffer-local properties: -->
  5. <!-- :tabSize=1:indentSize=1:noTabs=true: -->
  6. <!-- :xml.root=users-guide.xml: -->
  7. <section id="plugin-tips-libraries">
  8. <title>Bundling Additional Class Libraries</title>
  9. <para>Recall that any class whose name ends with
  10. <classname>Plugin.class</classname> is called a plugin core class. JAR
  11. files with no plugin core classes are also loaded by jEdit; the classes
  12. they contain are made available to other plugins. Many plugins that rely
  13. on third-party class libraries ship them as separate JAR files. The
  14. libraries will be available inside the jEdit environment but are not
  15. part of a general classpath or library collection when running other
  16. Java applications.</para>
  17. <para>A plugin that bundles extra JAR files must list them in the
  18. <filename>plugin.<replaceable>class name</replaceable>.jars</filename>
  19. property. See the documentation for the <ulink
  20. url="../api/org/gjt/sp/jedit/EditPlugin.html">
  21. <classname>EditPlugin</classname></ulink> class for details.</para>
  22. </section>
  23. <section id="plugin-tips-non-java-libraries">
  24. <title>Bundling Additional Non-Java Libraries</title>
  25. <para>If your plugin bundles non-Java files, like native libraries, you
  26. need to list them in the <filename>plugin.<replaceable>class
  27. name</replaceable>.files</filename> property. If you don't do so, they
  28. don't get deleted if the plugin is uninstalled. See the documentation
  29. for the <ulink url="../api/org/gjt/sp/jedit/EditPlugin.html">
  30. <classname>EditPlugin</classname></ulink> class for details.</para>
  31. </section>
  32. <section id="plugin-tips-plugin-data">
  33. <title>Storing plugin data</title>
  34. <para>If your plugin needs to create files and store data in the
  35. filesystem, you should use the <methodname>getPluginHome()</methodname>
  36. API of the <classname>EditPlugin</classname> class. To signal that you
  37. use the plugin home API you have to set the
  38. <filename>plugin.<replaceable>class
  39. name</replaceable>.usePluginHome</filename> property to
  40. <constant>true</constant>. Even if your plugin doesn't create any files,
  41. you should set the property to <constant>true</constant>, so that e. g.
  42. the plugin manager knows that there is actually no data in favor of not
  43. knowing if there is any data and thus displaying that it doesn't know
  44. the data size. See the documentation for the <ulink
  45. url="../api/org/gjt/sp/jedit/EditPlugin.html"><classname>EditPlugin</classname></ulink>
  46. class for details.</para>
  47. </section>
  48. <section id="plugin-tips-colors">
  49. <title>Plugin colors</title>
  50. <para>There are a number of colors used by the View that should also be
  51. used by plugins where possible. This helps promote a consistent color
  52. scheme throughout jEdit.
  53. </para><para>
  54. The main color properties are:
  55. </para>
  56. <itemizedlist>
  57. <listitem><para><literal>view.bgColor</literal> - the background color of the main text area</para></listitem>
  58. <listitem><para><literal>view.fgColor</literal> - the base foreground color for text in the main text area</para></listitem>
  59. <listitem><para><literal>view.lineHighlightColor</literal> - color of the current line highlight</para></listitem>
  60. <listitem><para><literal>view.selectionColor</literal> - the color of selected text in the main text area</para></listitem>
  61. <listitem><para><literal>view.caretColor</literal> - the color of the caret in the main text area</para></listitem>
  62. <listitem><para><literal>view.eolMarkerColor</literal> - the color of the end-of-line marker</para></listitem>
  63. </itemizedlist>
  64. <para>
  65. To use these colors in your plugin, use
  66. <programlisting>jEdit.getColorProperty("view.whatever", default_color)</programlisting>
  67. </para>
  68. <para>
  69. For example, the QuickNotepad example should have lines like this:
  70. </para>
  71. <programlisting>
  72. textarea.setBackground(jEdit.getColorProperty("view.bgColor", Color.WHITE);
  73. textarea.setForeground(jEdit.getColorProperty("view.fgColor", Color.BLACK);
  74. </programlisting><para>
  75. This sets the foreground and background colors of QuickNotepad to be the same
  76. as those in the View.
  77. </para>
  78. <para>
  79. There are other color properties that may be useful, depending on what your
  80. plugin displays.
  81. </para>
  82. <para>
  83. Gutter colors:
  84. </para><itemizedlist>
  85. <listitem><para><literal>view.gutter.bgColor</literal></para></listitem>
  86. <listitem><para><literal>view.gutter.currentLineColor</literal></para></listitem>
  87. <listitem><para><literal>view.gutter.fgColor</literal></para></listitem>
  88. <listitem><para><literal>view.gutter.focusBorderColor</literal></para></listitem>
  89. <listitem><para><literal>view.gutter.foldColor</literal></para></listitem>
  90. <listitem><para><literal>view.gutter.highlightColor</literal></para></listitem>
  91. <listitem><para><literal>view.gutter.markerColor</literal></para></listitem>
  92. <listitem><para><literal>view.gutter.noFocusBorderColor</literal></para></listitem>
  93. <listitem><para><literal>view.gutter.registerColor</literal></para></listitem>
  94. <listitem><para><literal>view.gutter.structureHighlightColor</literal></para></listitem>
  95. </itemizedlist>
  96. <para>
  97. Status bar colors:
  98. </para>
  99. <itemizedlist>
  100. <listitem><para><literal>view.status.background</literal></para></listitem>
  101. <listitem><para><literal>view.status.foreground</literal></para></listitem>
  102. <listitem><para><literal>view.status.memory.background</literal></para></listitem>
  103. <listitem><para><literal>view.status.memory.foreground</literal></para></listitem>
  104. </itemizedlist>
  105. <para>
  106. </para><para>
  107. Structure highlight colors:
  108. </para><itemizedlist>
  109. <listitem><para><literal>view.structureHighlightColor</literal></para></listitem>
  110. <listitem><para><literal>view.structureHighlightColor</literal></para></listitem>
  111. </itemizedlist>
  112. <para>
  113. Style colors. Use <classname>GUIUtilities.parseStyle</classname> for these.
  114. </para>
  115. <itemizedlist>
  116. <listitem><para><literal>view.style.comment1</literal></para></listitem>
  117. <listitem><para><literal>view.style.comment2</literal></para></listitem>
  118. <listitem><para><literal>view.style.comment3</literal></para></listitem>
  119. <listitem><para><literal>view.style.comment4</literal></para></listitem>
  120. <listitem><para><literal>view.style.digit</literal></para></listitem>
  121. <listitem><para><literal>view.style.foldLine.0</literal></para></listitem>
  122. <listitem><para><literal>view.style.foldLine.1</literal></para></listitem>
  123. <listitem><para><literal>view.style.foldLine.2</literal></para></listitem>
  124. <listitem><para><literal>view.style.foldLine.3</literal></para></listitem>
  125. <listitem><para><literal>view.style.function</literal></para></listitem>
  126. <listitem><para><literal>view.style.invalid</literal></para></listitem>
  127. <listitem><para><literal>view.style.keyword1</literal></para></listitem>
  128. <listitem><para><literal>view.style.keyword2</literal></para></listitem>
  129. <listitem><para><literal>view.style.keyword3</literal></para></listitem>
  130. <listitem><para><literal>view.style.keyword4</literal></para></listitem>
  131. <listitem><para><literal>view.style.label</literal></para></listitem>
  132. <listitem><para><literal>view.style.literal1</literal></para></listitem>
  133. <listitem><para><literal>view.style.literal2</literal></para></listitem>
  134. <listitem><para><literal>view.style.literal3</literal></para></listitem>
  135. <listitem><para><literal>view.style.literal4</literal></para></listitem>
  136. <listitem><para><literal>view.style.markup</literal></para></listitem>
  137. <listitem><para><literal>view.style.operator</literal></para></listitem>
  138. <listitem><para><literal>view.wrapGuideColor</literal></para></listitem>
  139. </itemizedlist>
  140. <para>
  141. For example, here is a setting for a fold line color:
  142. </para>
  143. <programlisting>
  144. view.style.foldLine.0=color\:\#000000 bgColor\:\#f5deb8 style\:b
  145. </programlisting>
  146. <para>
  147. Passing the value to <classname>GUIUtilities.parseStyle</classname> will
  148. return a SyntaxStyle object, which you can query for background color,
  149. foreground color, and font.
  150. </para>
  151. </section>
  152. </chapter>