public class HighlightingStyledDocument
extends javax.swing.text.DefaultStyledDocument
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement
javax.swing.text.DefaultStyledDocument.AttributeUndoableEdit, javax.swing.text.DefaultStyledDocument.ElementBuffer, javax.swing.text.DefaultStyledDocument.ElementSpec, javax.swing.text.DefaultStyledDocument.SectionElement
Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
newline |
The system specific line separator String.
|
Constructor | Description |
---|---|
HighlightingStyledDocument() |
Modifier and Type | Method | Description |
---|---|---|
protected void |
fireRemoveUpdate(javax.swing.event.DocumentEvent e) |
Overrides the default method from DefaultStyledDocument.
|
void |
insertString(int offs,
java.lang.String str,
javax.swing.text.AttributeSet a) |
Overrides the default method from DefaultStyledDocument.
|
void |
setCommentStyle(javax.swing.text.SimpleAttributeSet style) |
Sets the style of text to use for comments
|
void |
setDefaultStyle(javax.swing.text.SimpleAttributeSet style) |
Sets the default style of text to use
|
void |
setEnvironmentWords(java.lang.String[] words) |
Sets a collection of environment words to highlight.
|
void |
setEnvironmentWordStyle(javax.swing.text.SimpleAttributeSet style) |
Sets the style of text to use for environment words
|
void |
setKeywords(java.lang.String[] words) |
Sets a collection of keywords to highlight.
|
void |
setKeywordStyle(javax.swing.text.SimpleAttributeSet style) |
Sets the style of text to use for keywords
|
void |
setLParenStyle(javax.swing.text.SimpleAttributeSet style) |
Sets the style of text to use for invalid Left Parens
|
void |
setRParenStyle(javax.swing.text.SimpleAttributeSet style) |
Sets the style of text to use for invalid Right Parens
|
void |
setStringStyle(javax.swing.text.SimpleAttributeSet style) |
Sets the style of text to use for strings
|
void |
updateHighlightingInRange(int offset,
int length) |
Looks at a given range of text in a document and highlights it
according to keywords, environment, strings, and comments.
|
addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
addDocumentListener, addStyle, create, createDefaultRoot, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, getStyleNames, insert, insertUpdate, removeDocumentListener, removeElement, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, setParagraphAttributes, styleChanged
public static java.lang.String newline
public void insertString(int offs, java.lang.String str, javax.swing.text.AttributeSet a) throws javax.swing.text.BadLocationException
insertString
in class javax.swing.text.AbstractDocument
offs
- the starting offset >= 0str
- the string to insert; does nothing with null/empty stringsa
- the attributes for the inserted contentjavax.swing.text.BadLocationException
protected void fireRemoveUpdate(javax.swing.event.DocumentEvent e)
fireRemoveUpdate
in class javax.swing.text.AbstractDocument
e
- the DocumentEventpublic void updateHighlightingInRange(int offset, int length)
offset
- where in the document the change startedlength
- the length of change measured from the offsetpublic void setKeywords(java.lang.String[] words)
words
- an array of all the wordspublic void setEnvironmentWords(java.lang.String[] words)
words
- an array of all the wordspublic void setKeywordStyle(javax.swing.text.SimpleAttributeSet style)
style
- the new text stylepublic void setEnvironmentWordStyle(javax.swing.text.SimpleAttributeSet style)
style
- the new text stylepublic void setCommentStyle(javax.swing.text.SimpleAttributeSet style)
style
- the new text stylepublic void setStringStyle(javax.swing.text.SimpleAttributeSet style)
style
- the new text stylepublic void setLParenStyle(javax.swing.text.SimpleAttributeSet style)
style
- the new text stylepublic void setRParenStyle(javax.swing.text.SimpleAttributeSet style)
style
- the new text stylepublic void setDefaultStyle(javax.swing.text.SimpleAttributeSet style)
style
- the new text style