HighlightColor GetColor(HighlightRuleSet ruleSet, IDocument document, LineSegment currentSegment, int currentOffset, int currentLength) { if (ruleSet != null) { if (ruleSet.Reference != null) { return(ruleSet.Highlighter.GetColor(document, currentSegment, currentOffset, currentLength)); } else { return((HighlightColor)ruleSet.KeyWords[document, currentSegment, currentOffset, currentLength]); } } return(null); }
void ResolveRuleSetReferencesForSpan() { foreach (HighlightRuleSet ruleSet in RuleSets) { if (ruleSet.Name == null) { defaultRuleSet = ruleSet; } foreach (Span aSpan in ruleSet.Spans) { if (aSpan.Rule != null) //如果a当前Span引用的RuleSet不为空,则查找该引用. { bool found = false; foreach (HighlightRuleSet refSet in RuleSets) { if (refSet.Name == aSpan.Rule) { found = true; aSpan.RuleSet = refSet; break; } } if (!found) { MessageBox.Show("The RuleSet " + aSpan.Rule + " could not be found in mode definition " + this.Name, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); aSpan.RuleSet = null; } } else { aSpan.RuleSet = null; } } } if (defaultRuleSet == null) { MessageBox.Show("No default RuleSet is defined for mode definition " + this.Name, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); } }
void UpdateSpanStateVariables() { inSpan = (currentSpanStack != null && currentSpanStack.Count > 0); activeSpan = inSpan ? (Span)currentSpanStack.Peek() : null; activeRuleSet = GetRuleSetForSpan(activeSpan); }
public void AddRuleSet(HighlightRuleSet aRuleSet) { ruleSets.Add(aRuleSet); }