|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.text.AbstractDocument
javax.swing.text.DefaultStyledDocument
HighlightingStyledDocument
public class HighlightingStyledDocument
Highlights jython syntax in a Document Created for the Jython Environment for Students (JES) Hilghights keywords and environment words that are defined for it. It will also highlight single-line comments that start with '#', and single-line strings that start with "'" or '"'.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.text.DefaultStyledDocument |
---|
javax.swing.text.DefaultStyledDocument.AttributeUndoableEdit, javax.swing.text.DefaultStyledDocument.ElementBuffer, javax.swing.text.DefaultStyledDocument.ElementSpec, javax.swing.text.DefaultStyledDocument.SectionElement |
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument |
---|
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 |
Field Summary | |
---|---|
static java.lang.String |
newline
|
Fields inherited from class javax.swing.text.DefaultStyledDocument |
---|
buffer, BUFFER_SIZE_DEFAULT |
Fields inherited from class javax.swing.text.AbstractDocument |
---|
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName |
Fields inherited from interface javax.swing.text.Document |
---|
StreamDescriptionProperty, TitleProperty |
Constructor Summary | |
---|---|
HighlightingStyledDocument()
|
Method Summary | |
---|---|
void |
addEnvironmentWord(java.lang.String word)
Method: addEnvironmentWord Adds an environment word to the Vector of environment words. |
void |
addKeyword(java.lang.String word)
Method: addKeyword Adds a keyword to the Vector of keywords. |
protected void |
fireRemoveUpdate(javax.swing.event.DocumentEvent e)
fireRemoveUpdate Overrides the default method from DefaultStyledDocument. |
void |
insertString(int offs,
java.lang.String str,
javax.swing.text.AttributeSet a)
insertString Overrides the default method from DefaultStyledDocument. |
boolean |
isEnvWord(java.lang.String word)
Method: isEnvWord Sets the default style of text to use |
void |
setCommentStyle(javax.swing.text.SimpleAttributeSet style)
Method: setCommentStyle Sets the style of text to use for comments |
void |
setDefaultStyle(javax.swing.text.SimpleAttributeSet style)
Method: setDefaultStyle Sets the default style of text to use |
void |
setEnvironmentWords(java.lang.String[] words)
Method: setEnvironmentWords Sets a collection of environment words to highlight. |
void |
setEnvironmentWordStyle(javax.swing.text.SimpleAttributeSet style)
Method: setEnvironmentWordStyle Sets the style of text to use for environment words |
void |
setKeywords(java.lang.String[] words)
Method: setKeywords Sets a collection of keywords to highlight. |
void |
setKeywordStyle(javax.swing.text.SimpleAttributeSet style)
Method: setKeywordStyle Sets the style of text to use for keywords |
void |
setLParenStyle(javax.swing.text.SimpleAttributeSet style)
Method: setLParenStyle Sets the style of text to use for invalid Left Parens |
void |
setRParenStyle(javax.swing.text.SimpleAttributeSet style)
Method: setRParenStyle Sets the style of text to use for invalid Right Parens |
void |
setStringStyle(javax.swing.text.SimpleAttributeSet style)
Method: setStringStyle Sets the style of text to use for strings |
void |
updateHighlightingInRange(int offset,
int length)
Method: updateHighlightingInRange Looks at a given range of text in a document and highlights it according to keywords, environment, strings, and comments. |
Methods inherited from class javax.swing.text.DefaultStyledDocument |
---|
addDocumentListener, addStyle, create, createDefaultRoot, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, getStyleNames, insert, insertUpdate, removeDocumentListener, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, setParagraphAttributes, styleChanged |
Methods inherited from class javax.swing.text.AbstractDocument |
---|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.swing.text.Document |
---|
addUndoableEditListener, createPosition, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, putProperty, remove, removeUndoableEditListener, render |
Field Detail |
---|
public static java.lang.String newline
Constructor Detail |
---|
public HighlightingStyledDocument()
Method Detail |
---|
public void insertString(int offs, java.lang.String str, javax.swing.text.AttributeSet a) throws javax.swing.text.BadLocationException
insertString
in interface javax.swing.text.Document
insertString
in class javax.swing.text.AbstractDocument
javax.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 addKeyword(java.lang.String word)
word
- The word to addpublic void addEnvironmentWord(java.lang.String word)
word
- The word to addpublic 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 stylepublic boolean isEnvWord(java.lang.String word)
word
- the word to check for
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |