/// <summary> /// Imports the settings from another highlighting strategy. /// </summary> /// <param name="source">The source.</param> protected void ImportSettingsFrom(DefaultHighlightingStrategy source) { if (source == null) throw new ArgumentNullException("source"); properties = source.properties; extensions = source.extensions; digitColor = source.digitColor; defaultRuleSet = source.defaultRuleSet; name = source.name; rules = source.rules; environmentColors = source.environmentColors; defaultTextColor = source.defaultTextColor; }
/// <summary> /// Merges spans etc. from the other rule set into this rule set. /// </summary> /// <param name="ruleSet">The rule set.</param> public void MergeFrom(HighlightRuleSet ruleSet) { for (int i = 0; i < delimiters.Length; i++) { delimiters[i] |= ruleSet.delimiters[i]; } // insert merged spans in front of old spans List <Span> oldSpans = spans; spans = new List <Span>(ruleSet.spans); spans.AddRange(oldSpans); //keyWords.MergeFrom(ruleSet.keyWords); //prevMarkers.MergeFrom(ruleSet.prevMarkers); //nextMarkers.MergeFrom(ruleSet.nextMarkers); }
/// <summary> /// Imports the settings from another highlighting strategy. /// </summary> /// <param name="source">The source.</param> protected void ImportSettingsFrom(DefaultHighlightingStrategy source) { if (source == null) throw new ArgumentNullException("source"); _properties = source._properties; _extensions = source._extensions; _digitColor = source._digitColor; _defaultRuleSet = source._defaultRuleSet; _name = source._name; _rules = source._rules; _environmentColors = source._environmentColors; _defaultTextColor = source._defaultTextColor; }
/// <summary> /// Gets the highlighting color for a certain position in the document. /// </summary> /// <param name="ruleSet">The rule set.</param> /// <param name="document">The document.</param> /// <param name="currentSegment">The current segment.</param> /// <param name="currentOffset">The current offset.</param> /// <param name="currentLength">Length of the current.</param> /// <returns></returns> protected virtual 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; }
/// <summary> /// Adds the rule set. /// </summary> /// <param name="ruleSet">A rule set.</param> public void AddRuleSet(HighlightRuleSet ruleSet) { HighlightRuleSet existing = FindHighlightRuleSet(ruleSet.Name); if (existing != null) existing.MergeFrom(ruleSet); else _rules.Add(ruleSet); }
void UpdateSpanCountryVariables() { _inSpan = (_currentSpanStack != null && !_currentSpanStack.IsEmpty); _activeSpan = _inSpan ? _currentSpanStack.Peek() : null; _activeRuleSet = GetRuleSet(_activeSpan); }
void ResolveRuleSetReferences() { foreach (HighlightRuleSet ruleSet in Rules) { if (ruleSet.Name == null) _defaultRuleSet = ruleSet; foreach (Span aSpan in ruleSet.Spans) { if (aSpan.Rule != null) { bool found = false; foreach (HighlightRuleSet refSet in Rules) { if (refSet.Name == aSpan.Rule) { found = true; aSpan.RuleSet = refSet; break; } } if (!found) { aSpan.RuleSet = null; throw new HighlightingDefinitionInvalidException("The RuleSet " + aSpan.Rule + " could not be found in mode definition " + Name); } } else { aSpan.RuleSet = null; } } } if (_defaultRuleSet == null) throw new HighlightingDefinitionInvalidException("No default RuleSet is defined for mode definition " + Name); }
/// <summary> /// Merges spans etc. from the other rule set into this rule set. /// </summary> /// <param name="ruleSet">The rule set.</param> public void MergeFrom(HighlightRuleSet ruleSet) { for (int i = 0; i < delimiters.Length; i++) { delimiters[i] |= ruleSet.delimiters[i]; } // insert merged spans in front of old spans List<Span> oldSpans = spans; spans = new List<Span>(ruleSet.spans); spans.AddRange(oldSpans); //keyWords.MergeFrom(ruleSet.keyWords); //prevMarkers.MergeFrom(ruleSet.prevMarkers); //nextMarkers.MergeFrom(ruleSet.nextMarkers); }
void UpdateSpanStateVariables() { inSpan = (currentSpanStack != null && !currentSpanStack.IsEmpty); activeSpan = inSpan ? currentSpanStack.Peek() : null; activeRuleSet = GetRuleSet(activeSpan); }