Posted 19 years ago
by John Youren

Hi,
I am trying to dynamically add [multi-word] tokens at runtime, here is the code I have.The problem is even a simple word such as 'hello' won't highlight, even though I have stepped through it getting added.
Any ideas? :)
I am trying to dynamically add [multi-word] tokens at runtime, here is the code I have.
Documents[tabID].getCode().Document.LoadLanguageFromXml(Application.StartupPath + "\\Syntax\\" + Variables.Compiler + ".xml", 0);
// Set up TPC's
if (Variables.Compiler == Constant.CompilerDBP)
{
Documents[tabID].getCode().Document.Language.IsUpdating = true;
for(int pattern = 0; pattern < DBPSyntax.keywords.Count; pattern++)
{
Console.WriteLine(DBPSyntax.keywords[pattern].Replace(" ", "\\s+"));
Documents[tabID].getCode().Document.Language.DefaultLexicalState.LexicalPatternGroups.Add(new ActiproSoftware.SyntaxEditor.LexicalPatternGroup(ActiproSoftware.SyntaxEditor.LexicalPatternType.Regex, "ReservedWordToken", Documents[tabID].getCode().Document.Language.HighlightingStyles["ReservedWordStyle"], DBPSyntax.keywords[pattern].Replace(" ", "\\s+"), "{NonWordMacro}"));
}
Documents[tabID].getCode().Document.Language.IsUpdating = false;
}
Any ideas? :)