Exemplo n.º 1
0
        public void AddRuleSet(HighlightRuleSet aRuleSet)
        {
            var existing = FindHighlightRuleSet(aRuleSet.Name);

            if (existing != null)
            {
                existing.MergeFrom(aRuleSet);
            }
            else
            {
                Rules.Add(aRuleSet);
            }
        }
Exemplo n.º 2
0
        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));
                }
                return((HighlightColor)ruleSet.KeyWords[document, currentSegment, currentOffset, currentLength]);
            }

            return(null);
        }
Exemplo n.º 3
0
 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>
        public void MergeFrom(HighlightRuleSet ruleSet)
        {
            for (var i = 0; i < Delimiters.Length; i++)
            {
                Delimiters[i] |= ruleSet.Delimiters[i];
            }
            // insert merged spans in front of old spans
            var oldSpans = Spans;

            Spans = (ArrayList)ruleSet.Spans.Clone();
            Spans.AddRange(oldSpans);
            //keyWords.MergeFrom(ruleSet.keyWords);
            //prevMarkers.MergeFrom(ruleSet.prevMarkers);
            //nextMarkers.MergeFrom(ruleSet.nextMarkers);
        }
Exemplo n.º 5
0
        private void ResolveRuleSetReferences()
        {
            foreach (var ruleSet in Rules)
            {
                if (ruleSet.Name == null)
                {
                    defaultRuleSet = ruleSet;
                }

                foreach (Span aSpan in ruleSet.Spans)
                {
                    if (aSpan.Rule != null)
                    {
                        var found = false;
                        foreach (var 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);
            }
        }
Exemplo n.º 6
0
 private void UpdateSpanStateVariables()
 {
     inSpan        = currentSpanStack != null && !currentSpanStack.IsEmpty;
     activeSpan    = inSpan ? currentSpanStack.Peek() : null;
     activeRuleSet = GetRuleSet(activeSpan);
 }