All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fife.ui.rsyntaxtextarea.templates.CodeTemplate Maven / Gradle / Ivy

The newest version!
/*
 * 11/29/2008
 *
 * CodeTemplate.java - A "template" (macro) for commonly-typed code.
 * 
 * This library is distributed under a modified BSD license.  See the included
 * RSyntaxTextArea.License.txt file for details.
 */
package org.fife.ui.rsyntaxtextarea.templates;

import java.io.Serializable;
import javax.swing.text.BadLocationException;

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;


/**
 * A "code template" is a kind of macro for commonly-typed code.  It
 * associates a short identifier with a longer code snippet, then when the
 * code template is enabled and the short identifier is typed, it is
 * replaced with the longer code snippet.

* * For example, you can associate the identifier forb * (short for "for-block") with the following code:

* *

 *   for (<caret>) {
 *
 *   }
 * 
* * Then, whenever you type forb followed by a trigger * (e.g., a space) into a text area with this CodeTemplate, * the code snippet is added in place of forb. Further, * the caret is placed at the position denoted by <caret>.

* * Static text replacements are done with {@link StaticCodeTemplate}. Dynamic * templates can also be created and used. * * @author Robert Futrell * @version 0.1 * @see StaticCodeTemplate */ public interface CodeTemplate extends Cloneable, Comparable, Serializable { /** * Creates a deep copy of this template. * * @return A deep copy of this template. */ public Object clone(); /** * Returns the ID of this code template. * * @return The template's ID. */ public String getID(); /** * Invokes this code template. The changes are made to the given text * area. * * @param textArea The text area to operate on. * @throws BadLocationException If something bad happens. */ public void invoke(RSyntaxTextArea textArea) throws BadLocationException; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy