// I think tokens should not cross lines, it messes about // RSyntaxTextArea's hyperlink finding. please include class RSyntaxTextArea. import org.fife.ui.rsyntaxtextarea.TokenMakerBase; sclass HashRefTokenMaker extends TokenMakerBase { delegate Token to org.fife.ui.rsyntaxtextarea. /** * Returns a list of tokens representing the given text. * * @param text The text to break into tokens. * @param startTokenType The token with which to start tokenizing. * @param startOffset The offset at which the line of tokens begins. * @return A linked list of tokens representing text. */ @Override public Token getTokenList(Segment text, int startTokenType, final int startOffset) { resetTokenList(); char[] array = text.array; int offset = text.offset; int count = text.count; int end = offset + count; int newStartOffset = startOffset - offset; S src = str(array, offset, count); LS tok = hashRefTok(src); int ofs = offset; for i, t over tok: { if (empty(t)) continue; bool isHyperlink = odd(i); // split at line breaks, spaces and punctuation to allow // word wrapping (does it work?) for (part : singlePredTok(c -> isSpaceEtc(c), t)) { if (nempty(part)) { var tokenType = isHyperlink ? Token.VARIABLE : startsWithSpaceEtc(part) ? Token.WHITESPACE : Token.IDENTIFIER; int l = l(part); addToken(array, ofs, ofs+l-1, tokenType, ofs+newStartOffset, isHyperlink); ofs += l; } } } addNullToken(); // Return the first token in our linked list. ret firstToken; } }