Fast Colored TextBox for Syntax Highlighting[
^]
I'm using the above control for a custom syntax highlighter. I'm trying to dynamically update the styles used. When I look at the example, it changes color when the TextChangedDelayed event is fired, but when I implement similar code, it changes color and then changes the text:
Example:
fctb.Range.ClearStyle(KeywordsStyle, FunctionNameStyle);
fctb.Range.SetStyle(KeywordsStyle, @"\b(and|eval|else|if|lambda|or|set|defun)\b", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
foreach (Range found in fctb.GetRanges(@"\b(defun|DEFUN)\s+(?<range>\w+)\b"))
fctb.Range.SetStyle(FunctionNameStyle, @"\b" + found.Text + @"\b");
My Code:
fctb.Range.ClearStyle(FnDynamic, VarDynamic);
foreach (Range found in fctb.GetRanges(@"\bprocess\s+(?<range>\w+)\b"))
fctb.Range.SetStyle(FnDynamic, @"\b" + found.Text + @"\b");
foreach (Range found in fctb.GetRanges(@"\bvariable\s+(?<range>\w+)\b"))
fctb.Range.SetStyle(VarDynamic, @"\b" + found.Text + @"\b");
foreach (Range found in fctb.GetRanges(@"\bfor\s+(?<range>\w+)\b"))
fctb.Range.SetStyle(VarDynamic, @"\b" + found.Text + @"\b");
I implement this control using System.Windows.Forms.Integration.WindowsFormsHost, so it should work the same (I think). Instead, it seems like the same event (TextChangedDelayed) is firing at different times in WPF (Before the text is written to the screen) than in windows forms (After the text is written to the screen an the user has stopped typing).
Any ideas as to why this would happen?
Thanks!