public HighlightWordsRule(XElement rule) { Words = new List<string>(); Options = new RuleOptions(rule); string wordsStr = rule.Element("Words").Value; wordsStr = wordsStr.Replace(" ", " ").Replace(" ", "|"); Expression = new Regex("\b(" + wordsStr + ")\b"); string[] words = Regex.Split(wordsStr, "\\s+"); foreach (string word in words) if (!string.IsNullOrWhiteSpace(word)) Words.Add(word); }
public HighlightLineRule(XElement rule) { LineStart = rule.Element("LineStart").Value.Trim(); Expression = new Regex(Regex.Escape(LineStart) + ".*"); Options = new RuleOptions(rule); }
/// <summary> /// Applies a format in rule options to the formatted text /// </summary> /// <param name="text"></param> /// <param name="options"></param> /// <param name="index"></param> /// <param name="length"></param> public void ApplyFormat(FormattedText text, RuleOptions options, int index, int length) { text.SetForegroundBrush(options.Foreground, index, length); text.SetFontWeight(options.FontWeight, index, length); text.SetFontStyle(options.FontStyle, index, length); }
public AdvancedHighlightRule(XElement rule) { Expression = new Regex(rule.Element("Expression").Value.Trim()); Options = new RuleOptions(rule); }