public class SyntaxDocument
extends javax.swing.text.PlainDocument
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
Modifier and Type | Field and Description |
---|---|
protected boolean |
editable
True if the document is editable.
|
protected javax.swing.undo.UndoManager |
manager
The document UndoManager.
|
protected SyntaxListener |
syntaxListener
The syntax listener.
|
protected TokenMarker |
tokenMarker
The document TokenMarker.
|
Constructor and Description |
---|
SyntaxDocument() |
Modifier and Type | Method and Description |
---|---|
protected void |
fireInsertUpdate(javax.swing.event.DocumentEvent evt)
We overwrite this method to update the token marker state immediately so that any event listeners get a consistent token marker.
|
protected void |
fireRemoveUpdate(javax.swing.event.DocumentEvent evt)
We overwrite this method to update the token marker state immediately so that any event listeners get a consistent token marker.
|
int |
getLineEndOffset(int line)
Returns the end offset of the specified line.
|
int |
getLineLength(int line)
Returns the length of the specified line.
|
int |
getLineOffset(int line,
int column)
Return the offset for a line and a column.
|
int |
getLineOfOffset(int offset)
Returns the line containing the specified offset.
|
int |
getLineStartOffset(int line)
Returns the start offset of the specified line.
|
java.lang.String |
getLineText(int lineIndex)
Returns the text on the specified line.
|
boolean |
getLineText(int lineIndex,
javax.swing.text.Segment segment)
Copies the text on the specified line into a segment.
|
SyntaxListener |
getSyntaxListener()
Return the syntax listener.
|
java.lang.String |
getText()
Returns the entire text of the document.
|
java.lang.String |
getTextProtected(int start,
int len)
Returns the specified substring of the document.
|
TokenMarker |
getTokenMarker()
Returns the token marker that is to be used to split lines of this document up into tokens.
|
javax.swing.undo.UndoManager |
getUndoManager()
Return the document UndoManager.
|
void |
insertString(int offs,
java.lang.String string,
javax.swing.text.AttributeSet a) |
boolean |
isEditable()
Retuen true if the document is editable.
|
void |
remove(int offs,
int length) |
void |
setEditable(boolean editable)
Set if the document is editable.
|
void |
setSyntaxListener(SyntaxListener syntaxListener)
Set the syntax listener.
|
void |
setTokenMarker(TokenMarker tm)
Sets the token marker that is to be used to split lines of this document up into tokens.
|
void |
tokenizeContent()
Tokenize the content.
|
void |
tokenizeContent(boolean force)
Tokenize the content.
|
void |
tokenizeLines()
Reparses the document, by passing all lines to the token marker.
|
void |
tokenizeLines(boolean forceMultiline)
Reparses the document, by passing all lines to the token marker.
|
void |
tokenizeLines(int start,
int len)
Reparses the document, by passing the specified lines to the token marker.
|
void |
tokenizeLines(int start,
int len,
boolean forceMultiline)
Reparses the document, by passing the specified lines to the token marker.
|
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
protected TokenMarker tokenMarker
protected javax.swing.undo.UndoManager manager
protected boolean editable
protected SyntaxListener syntaxListener
public void setEditable(boolean editable)
editable
- true if the document is editablepublic boolean isEditable()
public void setSyntaxListener(SyntaxListener syntaxListener)
syntaxListener
- the listenerpublic SyntaxListener getSyntaxListener()
public javax.swing.undo.UndoManager getUndoManager()
public TokenMarker getTokenMarker()
public void insertString(int offs, java.lang.String string, javax.swing.text.AttributeSet a) throws javax.swing.text.BadLocationException
insertString
in interface javax.swing.text.Document
insertString
in class javax.swing.text.PlainDocument
javax.swing.text.BadLocationException
public void remove(int offs, int length) throws javax.swing.text.BadLocationException
remove
in interface javax.swing.text.Document
remove
in class javax.swing.text.AbstractDocument
javax.swing.text.BadLocationException
public final int getLineOfOffset(int offset)
offset
- The offsetpublic void setTokenMarker(TokenMarker tm)
tm
- the new token markerpublic void tokenizeLines()
public void tokenizeLines(boolean forceMultiline)
forceMultiline
- true if the tokenization will be performed even if the Tokenmarker does not support multilinepublic void tokenizeLines(int start, int len)
start
- The first line to parselen
- The number of lines, after the first one to parsepublic void tokenizeContent()
public final java.lang.String getTextProtected(int start, int len)
start
- The start offsetlen
- The length of the substringpublic final java.lang.String getLineText(int lineIndex)
lineIndex
- the linepublic int getLineEndOffset(int line)
line
- the linepublic int getLineLength(int line)
line
- the linepublic int getLineOffset(int line, int column)
line
- the linecolumn
- the columnpublic int getLineStartOffset(int line)
line
- The linepublic final boolean getLineText(int lineIndex, javax.swing.text.Segment segment)
lineIndex
- The linesegment
- the segmentpublic java.lang.String getText()
public void tokenizeContent(boolean force)
force
- true to tokenize even is the document has not been updatedpublic void tokenizeLines(int start, int len, boolean forceMultiline)
start
- The first line to parselen
- The number of lines, after the first one to parseforceMultiline
- true if the tokenization will be performed even if the Tokenmarker does not support multilineprotected void fireInsertUpdate(javax.swing.event.DocumentEvent evt)
fireInsertUpdate
in class javax.swing.text.AbstractDocument
evt
- the DocumentEventprotected void fireRemoveUpdate(javax.swing.event.DocumentEvent evt)
fireRemoveUpdate
in class javax.swing.text.AbstractDocument
evt
- the DocumentEventCopyright © 2016, 2017, 2018, 2019, 2023, 2025 Herve Girod. All Rights Reserved. Documentation and source under the MIT licence