public abstract class TokenMarker
extends java.lang.Object
markTokens
should only be used for immediate painting. Notably, it cannot be cached.Modifier and Type | Class and Description |
---|---|
class |
TokenMarker.LineInfo
Inner class for storing information about tokenized lines.
|
Modifier and Type | Field and Description |
---|---|
protected int |
currentTokenOffset
The current offset.
|
protected Token |
firstToken
The first token in the list.
|
protected int |
lastLine
The last tokenized line.
|
protected Token |
lastToken
The last token in the list.
|
protected int |
length
The number of lines in the model being tokenized.
|
protected int |
lineIndex
The current line index.
|
protected TokenMarker.LineInfo[] |
lineInfo
An array for storing information about lines.
|
protected boolean |
nextLineRequested
True if the next line should be painted.
|
protected int |
offsetGap
The offset gap for the current line.
|
protected SyntaxListener |
syntaxListener
The syntax lixtener.
|
Modifier | Constructor and Description |
---|---|
protected |
TokenMarker()
Creates a new
TokenMarker . |
Modifier and Type | Method and Description |
---|---|
protected void |
addToken(int length,
byte id,
boolean externalTokenizer)
Adds a token to the token list.
|
void |
deleteLines(int index,
int lines)
Informs the token marker that line have been deleted from the document.
|
protected void |
ensureCapacity(int index)
Ensures that the
lineInfo array can contain the specified index. |
int |
getLineCount()
Returns the number of lines in this token marker.
|
int |
getLineIndex()
Return the current line index.
|
int |
getMaxLineWidth(int start,
int len)
Returns the maximum line width in the specified line range.
|
int |
getOffsetGap()
Return the offset gap for the current line.
|
SyntaxListener |
getSyntaxListener()
Return the syntax listener.
|
void |
insertLines(int index,
int lines)
Informs the token marker that lines have been inserted into the document.
|
boolean |
isNextLineRequested()
Returns true if the next line should be repainted.
|
Token |
markTokens(javax.swing.text.Segment line,
int lineIndex)
A wrapper for the lower-level
markTokensImpl method that is called to split a line up into tokens. |
Token |
markTokens(javax.swing.text.Segment line,
int lineIndex,
boolean externalTokenizer)
A wrapper for the lower-level
markTokensImpl method that is called to split a line up into tokens. |
protected abstract byte |
markTokensImpl(byte token,
javax.swing.text.Segment line,
int lineIndex,
boolean externalTokenizer)
An abstract method that splits a line up into tokens.It should parse the line, and call
addToken() to add syntax tokens
to the token list. |
boolean |
setLineWidth(int lineIndex,
int width)
Store the width of a line, in pixels.
|
void |
setOffsetGap(int offsetGap)
Set the offset gap for the current line.
|
void |
setSyntaxListener(SyntaxListener syntaxListener)
Set the syntax listener.
|
boolean |
supportsMultilineTokens()
Returns true if the token marker supports tokens that span multiple lines.
|
protected Token firstToken
markTokens()
.protected Token lastToken
protected TokenMarker.LineInfo[] lineInfo
insertLines()
and
deleteLines()
methods.protected int length
lineInfo
array.protected int lastLine
protected boolean nextLineRequested
protected SyntaxListener syntaxListener
protected int lineIndex
protected int currentTokenOffset
protected int offsetGap
protected TokenMarker()
TokenMarker
. This DOES NOT create a lineInfo array; an initial call to insertLines(int, int)
does
that.public void setSyntaxListener(SyntaxListener syntaxListener)
syntaxListener
- the syntax listenerpublic SyntaxListener getSyntaxListener()
public void setOffsetGap(int offsetGap)
offsetGap
- the offset gappublic int getOffsetGap()
public int getLineIndex()
public Token markTokens(javax.swing.text.Segment line, int lineIndex)
markTokensImpl
method that is called to split a line up into tokens.line
- The linelineIndex
- The line numberpublic Token markTokens(javax.swing.text.Segment line, int lineIndex, boolean externalTokenizer)
markTokensImpl
method that is called to split a line up into tokens.line
- The linelineIndex
- The line numberexternalTokenizer
- true when using an external tokenizerprotected abstract byte markTokensImpl(byte token, javax.swing.text.Segment line, int lineIndex, boolean externalTokenizer)
addToken()
to add syntax tokens
to the token list. Then, it should return the initial token type for the next line.
For example if the current line contains the start of a multiline comment that doesn't end on that line, this method should return the
comment token type so that it continues on the next line.token
- The initial token type for this lineline
- The line to be tokenizedlineIndex
- The index of the line in the document, starting at 0externalTokenizer
- true for an external tokenizerpublic boolean supportsMultilineTokens()
markTokens()
method (in turn).
The default implementation returns true. It should be overridden to return false on simpler token markers for increased speed.public void insertLines(int index, int lines)
lineInfo
array.index
- The first line numberlines
- The number of linespublic void deleteLines(int index, int lines)
lineInfo
array.index
- The first line numberlines
- The number of linespublic int getLineCount()
public boolean isNextLineRequested()
protected void ensureCapacity(int index)
lineInfo
array can contain the specified index. This enlarges it if necessary. No action is taken if the
array is large enough already.
It should be unnecessary to call this under normal circumstances; insertLine()
should take care of enlarging the line
info array automatically.
index
- The array indexprotected void addToken(int length, byte id, boolean externalTokenizer)
length
- The length of the tokenid
- The id of the tokenexternalTokenizer
- true for an external tokenizerpublic boolean setLineWidth(int lineIndex, int width)
lineIndex
- The line numberwidth
- The widthpublic int getMaxLineWidth(int start, int len)
start
- The first linelen
- The number of linesCopyright © 2016, 2017, 2018, 2019, 2023, 2025 Herve Girod. All Rights Reserved. Documentation and source under the MIT licence