Hi omadawn,
Kyrremann's right, I never got around to adding "official" support for adding keywords to existing languages. It didn't seem like the requirement would come up very often, and it feels lopsided allowing users to easily add keywords but not providing a means to easily delete existing ones.
I could modify the existing TokenMakers to make it easier to do these things, but that would impact performance (perhaps marginally, but it would hit languages with large amounts of keywords/functions/etc. harder than those with smaller numbers, where the impact would be negligible).
You probably could add keywords quite easily yourself though. You'd just need to extend the existing TokenMaker you're interested in, and override the right addToken() overload to check for your added tokens and change the token type if necessary. To do this, you'd do something similar to what's done in UnixShellTokenMaker.
First you'd create an org.fife.ui.rsyntaxtextarea.TokenMap, and load it up with your tokens to add. Then, in your subclass of e.g. TclTokenMaker, override the following addToken() overload to check for your extra tokens:
java code:
public void addToken(char[] array, int start, int end, int tokenType, int startOffset) {
if (tokenType==Token.IDENTIFIER) { // Assuming all of your new highlighted words are identifiers
int value = myWordsToHighlight.get(array, start, end);
if (value != -1) {
tokenType = value;
}
}
super.addToken(array, start,end, tokenType, startOffset);
}
You're basically intercepting tokens that would be painted as plain identifiers, and deciding whether they should be something different. You can change them to be keywords, functions, or any other token type supported by RSTA.
Finally, register your TclTokenMaker extension class as described by Hookahey back on page 1 of this thread:
java code:
AbstractTokenMakerFactory atmf = (AbstractTokenMakerFactory) TokenMakerFactory.getDefaultInstance();
atmf.putMapping("a key string denoting your style", "fully.qualified.classNameOfYourSyntaxStyle");
textArea.setSyntaxEditingStyle("a key string denoting your style");
You can of course use SyntaxConstants.SYNTAX_STYLE_TCL if you wanted to "override" the existing TCL highlighting.
Does this work for you?