|
||||||||||
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.PlainDocument
jsyntaxpane.SyntaxDocument
public class SyntaxDocument
A document that supports being highlighted. The document maintains an internal List of all the Tokens. The Tokens are updated using a Lexer, passed to it during construction.
Nested Class Summary |
---|
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 org.apache.log4j.Logger |
LOG
|
Fields inherited from class javax.swing.text.PlainDocument |
---|
lineLimitAttribute, tabSizeAttribute |
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 | |
---|---|
SyntaxDocument(Lexer lexer)
|
Method Summary | |
---|---|
SyntaxDocument |
append(java.lang.String str)
Append the given string to the text of this document. |
void |
clearUndos()
This will discard all undoable edits |
void |
doRedo()
Perform a redo action, if possible. |
void |
doUndo()
Perform an undo action, if possible |
protected void |
fireChangedUpdate(javax.swing.event.DocumentEvent e)
|
protected void |
fireInsertUpdate(javax.swing.event.DocumentEvent e)
|
protected void |
fireRemoveUpdate(javax.swing.event.DocumentEvent e)
|
java.lang.String |
getLineAt(int pos)
Gets the line at given position. |
int |
getLineCount()
Return the number of lines in this document |
int |
getLineEndOffset(int pos)
Returns the end position of the line at pos. |
int |
getLineNumberAt(int pos)
Return the line number at given position. |
int |
getLineStartOffset(int pos)
Returns the starting position of the line at pos |
java.util.regex.Matcher |
getMatcher(java.util.regex.Pattern pattern)
Return a matcher that matches the given pattern on the entire document |
java.util.regex.Matcher |
getMatcher(java.util.regex.Pattern pattern,
int start)
Return a matcher that matches the given pattern in the part of the document starting at offset start. |
java.util.regex.Matcher |
getMatcher(java.util.regex.Pattern pattern,
int start,
int length)
Return a matcher that matches the given pattern in the part of the document starting at offset start and ending at start + length. |
Token |
getNextToken(Token tok)
Return the token following the current token, or null This is an expensive operation, so do not use it to update the gui |
Token |
getPairFor(Token t)
This is used to return the other part of a paired token in the document. |
Token |
getPrevToken(Token tok)
Return the token prior to the given token, or null This is an expensive operation, so do not use it to update the gui |
Token |
getTokenAt(int pos)
Find the token at a given position. |
java.util.Iterator<Token> |
getTokens(int start,
int end)
Return an iterator of tokens between p0 and p1. |
java.lang.String |
getUncommentedText(int aStart,
int anEnd)
Gets the text without the comments. |
Token |
getWordAt(int offs,
java.util.regex.Pattern p)
|
void |
removeLineAt(int pos)
Deletes the line at given position |
void |
replace(int offset,
int length,
java.lang.String text,
javax.swing.text.AttributeSet attrs)
We override this here so that the replace is treated as one operation by the undomanager |
void |
replaceLineAt(int pos,
java.lang.String newLines)
Replace the line at given position with the given string, which can span multiple lines |
void |
replaceToken(Token token,
java.lang.String replacement)
Replace the token with the replacement string |
java.lang.String |
toString()
|
Methods inherited from class javax.swing.text.PlainDocument |
---|
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertString, insertUpdate, removeUpdate |
Methods inherited from class javax.swing.text.AbstractDocument |
---|
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final org.apache.log4j.Logger LOG
Constructor Detail |
---|
public SyntaxDocument(Lexer lexer)
Method Detail |
---|
protected void fireChangedUpdate(javax.swing.event.DocumentEvent e)
fireChangedUpdate
in class javax.swing.text.AbstractDocument
protected void fireInsertUpdate(javax.swing.event.DocumentEvent e)
fireInsertUpdate
in class javax.swing.text.AbstractDocument
protected void fireRemoveUpdate(javax.swing.event.DocumentEvent e)
fireRemoveUpdate
in class javax.swing.text.AbstractDocument
public void replaceToken(Token token, java.lang.String replacement)
token
- replacement
- public java.util.Iterator<Token> getTokens(int start, int end)
start
- start position for getting tokensend
- position for last token
public Token getTokenAt(int pos)
pos
-
public Token getWordAt(int offs, java.util.regex.Pattern p)
public Token getNextToken(Token tok)
tok
-
public Token getPrevToken(Token tok)
tok
-
public Token getPairFor(Token t)
t
-
public void doUndo()
public void doRedo()
public java.util.regex.Matcher getMatcher(java.util.regex.Pattern pattern)
pattern
-
public java.util.regex.Matcher getMatcher(java.util.regex.Pattern pattern, int start)
start
pattern
- start
-
public java.util.regex.Matcher getMatcher(java.util.regex.Pattern pattern, int start, int length)
start
pattern
- start
- length
-
public void clearUndos()
public java.lang.String getLineAt(int pos) throws javax.swing.text.BadLocationException
pos
- Position (usually from text.getCaretPosition()
javax.swing.text.BadLocationException
public void removeLineAt(int pos) throws javax.swing.text.BadLocationException
pos
-
javax.swing.text.BadLocationException
public void replaceLineAt(int pos, java.lang.String newLines) throws javax.swing.text.BadLocationException
pos
- newLines
-
javax.swing.text.BadLocationException
public java.lang.String getUncommentedText(int aStart, int anEnd)
{ // it's a comment
this method will return "{ ".
aStart
- start of the text.anEnd
- end of the text.
public int getLineStartOffset(int pos)
pos
-
public int getLineEndOffset(int pos)
pos
-
public int getLineCount()
public int getLineNumberAt(int pos)
pos
-
public java.lang.String toString()
toString
in class java.lang.Object
public void replace(int offset, int length, java.lang.String text, javax.swing.text.AttributeSet attrs) throws javax.swing.text.BadLocationException
replace
in class javax.swing.text.AbstractDocument
offset
- length
- text
- attrs
-
javax.swing.text.BadLocationException
public SyntaxDocument append(java.lang.String str)
str
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |