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
public class StaticCodeTemplate extends AbstractCodeTemplate
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 typeforb
followed by a trigger (e.g., a space) into a text area with thisCodeTemplate
, the code snippet is added in place offorb
. Further, the caret is placed at the position denoted by<caret>
.- See Also:
CodeTemplate
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StaticCodeTemplate()
Constructor.StaticCodeTemplate(String id, String beforeCaret, String afterCaret)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAfterCaretText()
Returns the text that will be placed after the caret.String
getBeforeCaretText()
Returns the text that will be placed before the caret.void
invoke(RSyntaxTextArea textArea)
Invokes this code template.void
setAfterCaretText(String afterCaret)
Sets the text to place after the caret.void
setBeforeCaretText(String beforeCaret)
Sets the text to place before the caret.String
toString()
Returns a string representation of this template for debugging purposes.
-
-
-
Method Detail
-
getAfterCaretText
public String getAfterCaretText()
Returns the text that will be placed after the caret.- Returns:
- The text.
- See Also:
setAfterCaretText(java.lang.String)
-
getBeforeCaretText
public String getBeforeCaretText()
Returns the text that will be placed before the caret.- Returns:
- The text.
- See Also:
setBeforeCaretText(java.lang.String)
-
invoke
public void invoke(RSyntaxTextArea textArea) throws BadLocationException
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
public void setAfterCaretText(String afterCaret)
Sets the text to place after the caret.- Parameters:
afterCaret
- The text.- See Also:
getAfterCaretText()
-
setBeforeCaretText
public void setBeforeCaretText(String beforeCaret)
Sets the text to place before the caret.- Parameters:
beforeCaret
- The text.- See Also:
getBeforeCaretText()
-
-