# Plugin Tips and Techniques

## Bundling Additional Class Libraries

Recall that any class whose name ends with `Plugin.class` is called a plugin core class. JAR files with no plugin core classes are also loaded by jEdit; the classes they contain are made available to other plugins. Many plugins that rely on third-party class libraries ship them as separate JAR files. The libraries will be available inside the jEdit environment but are not part of a general classpath or library collection when running other Java applications.

A plugin that bundles extra JAR files must list them in the `plugin.class name.jars` property. See the documentation for the `EditPlugin` class for details.

## Bundling Additional Non-Java Libraries

If your plugin bundles non-Java files, like native libraries, you need to list them in the `plugin.class name.files` property. If you don't do so, they don't get deleted if the plugin is uninstalled. See the documentation for the `EditPlugin` class for details.

## Storing plugin data

If your plugin needs to create files and store data in the filesystem, you should use the `getPluginHome()` API of the `EditPlugin` class. To signal that you use the plugin home API you have to set the `plugin.class name.usePluginHome` property to `true`. Even if your plugin doesn't create any files, you should set the property to `true`, so that e. g. the plugin manager knows that there is actually no data in favor of not knowing if there is any data and thus displaying that it doesn't know the data size. See the documentation for the `EditPlugin` class for details.

## Plugin colors

There are a number of colors used by the View that should also be used by plugins where possible. This helps promote a consistent color scheme throughout jEdit.

The main color properties are:

- `view.bgColor` - the background color of the main text area

- `view.fgColor` - the base foreground color for text in the main text area

- `view.lineHighlightColor` - color of the current line highlight

- `view.selectionColor` - the color of selected text in the main text area

- `view.caretColor` - the color of the caret in the main text area

- `view.eolMarkerColor` - the color of the end-of-line marker

To use these colors in your plugin, use

    jEdit.getColorProperty("view.whatever", default_color)

For example, the QuickNotepad example should have lines like this:

            textarea.setBackground(jEdit.getColorProperty("view.bgColor", Color.WHITE));
            textarea.setForeground(jEdit.getColorProperty("view.fgColor", Color.BLACK));

This sets the foreground and background colors of QuickNotepad to be the same as those in the View.

There are other color properties that may be useful, depending on what your plugin displays.

Gutter colors:

- `view.gutter.bgColor`

- `view.gutter.currentLineColor`

- `view.gutter.fgColor`

- `view.gutter.focusBorderColor`

- `view.gutter.foldColor`

- `view.gutter.highlightColor`

- `view.gutter.markerColor`

- `view.gutter.noFocusBorderColor`

- `view.gutter.registerColor`

- `view.gutter.structureHighlightColor`

Status bar colors:

- `view.status.background`

- `view.status.foreground`

- `view.status.memory.background`

- `view.status.memory.foreground`

Structure highlight colors:

- `view.structureHighlightColor`

- `view.structureHighlightColor`

Style colors. Use `GUIUtilities.parseStyle` for these.

- `view.style.comment1`

- `view.style.comment2`

- `view.style.comment3`

- `view.style.comment4`

- `view.style.digit`

- `view.style.foldLine.0`

- `view.style.foldLine.1`

- `view.style.foldLine.2`

- `view.style.foldLine.3`

- `view.style.function`

- `view.style.invalid`

- `view.style.keyword1`

- `view.style.keyword2`

- `view.style.keyword3`

- `view.style.keyword4`

- `view.style.label`

- `view.style.literal1`

- `view.style.literal2`

- `view.style.literal3`

- `view.style.literal4`

- `view.style.markup`

- `view.style.operator`

- `view.wrapGuideColor`

For example, here is a setting for a fold line color:

             view.style.foldLine.0=color\:\#000000 bgColor\:\#f5deb8 style\:b

Passing the value to `GUIUtilities.parseStyle` will return a SyntaxStyle object, which you can query for background color, foreground color, and font.