Class TokenMarker
- java.lang.Object
-
- net.sf.gridarta.textedit.textarea.tokenmarker.TokenMarker
-
- Direct Known Subclasses:
CrossfireDialogTokenMarker,CTokenMarker,DaimoninAITokenMarker,EmptyTokenMarker,HTMLTokenMarker,LuaTokenMarker,PythonTokenMarker
public abstract class TokenMarker extends java.lang.ObjectA token marker that splits lines of text into tokens. Each token carries a length field and an identification tag that can be mapped to a color for painting that token.For performance reasons, the linked list of tokens is reused after each line is tokenized. Therefore, the return value of
markTokensshould only be used for immediate painting. Notably, it cannot be cached.- See Also:
Token
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTokenMarker()Creates a newTokenMarker.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddToken(int length, byte id)Adds a token to the token list.voiddeleteLines(int index, int lines)Informs the token marker that line have been deleted from the document.voidinsertLines(int index, int lines)Informs the token marker that lines have been inserted into the document.booleanisNextLineRequested()Returns true if the next line should be repainted.@NotNull java.util.List<Token>markTokens(@NotNull javax.swing.text.Segment line, int lineIndex)A wrapper for the lower-levelmarkTokensImplmethod that is called to split a line up into tokens.protected abstract bytemarkTokensImpl(byte token, @NotNull javax.swing.text.Segment line)An abstract method that splits a line up into tokens.
-
-
-
Method Detail
-
markTokens
@NotNull public @NotNull java.util.List<Token> markTokens(@NotNull @NotNull javax.swing.text.Segment line, int lineIndex)
A wrapper for the lower-levelmarkTokensImplmethod that is called to split a line up into tokens.- Parameters:
line- the linelineIndex- the line number- Returns:
- the tokens
-
markTokensImpl
protected abstract byte markTokensImpl(byte token, @NotNull @NotNull javax.swing.text.Segment line)An abstract method that splits a line up into tokens. It should parse the line, and calladdToken()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 multi-line comment that doesn't end on that line, this method should return the comment token type so that it continues on the next line.
- Parameters:
token- the initial token type for this lineline- the line to be tokenized- Returns:
- the initial token type for the next line
-
insertLines
public void insertLines(int index, int lines)Informs the token marker that lines have been inserted into the document. This inserts a gap in thelineInfoarray.- Parameters:
index- the first line numberlines- the number of lines
-
deleteLines
public void deleteLines(int index, int lines)Informs the token marker that line have been deleted from the document. This removes the lines in question from thelineInfoarray.- Parameters:
index- the first line numberlines- the number of lines
-
isNextLineRequested
public boolean isNextLineRequested()
Returns true if the next line should be repainted. This will return true after a line has been tokenized that starts a multi-line token that continues onto the next line.
-
addToken
protected void addToken(int length, byte id)Adds a token to the token list.- Parameters:
length- the length of the tokenid- the id of the token
-
-