Class StaticCodeTemplate
java.lang.Object
org.fife.ui.rsyntaxtextarea.templates.AbstractCodeTemplate
org.fife.ui.rsyntaxtextarea.templates.StaticCodeTemplate
- All Implemented Interfaces:
Serializable, Cloneable, Comparable<CodeTemplate>, CodeTemplate
A code template that inserts static text before and after the caret.
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>.- Version:
- 0.1
- Author:
- Robert Futrell
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor.StaticCodeTemplate(String id, String beforeCaret, String afterCaret) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the text that will be placed after the caret.Returns the text that will be placed before the caret.voidinvoke(RSyntaxTextArea textArea) Invokes this code template.voidsetAfterCaretText(String afterCaret) Sets the text to place after the caret.voidsetBeforeCaretText(String beforeCaret) Sets the text to place before the caret.toString()Returns a string representation of this template for debugging purposes.
-
Constructor Details
-
StaticCodeTemplate
public StaticCodeTemplate()Constructor. This constructor only exists to support persistence through serialization. -
StaticCodeTemplate
-
-
Method Details
-
getAfterCaretText
Returns the text that will be placed after the caret.- Returns:
- The text.
- See Also:
-
getBeforeCaretText
Returns the text that will be placed before the caret.- Returns:
- The text.
- See Also:
-
invoke
Invokes this code template. The changes are made to the given text area.- Parameters:
textArea- The text area to operate on.- Throws:
BadLocationException- If something bad happens.
-
setAfterCaretText
Sets the text to place after the caret.- Parameters:
afterCaret- The text.- See Also:
-
setBeforeCaretText
Sets the text to place before the caret.- Parameters:
beforeCaret- The text.- See Also:
-
toString
-