Example #1
0
        public HighlightRuleSet(XmlElement el)
        {
            XmlNodeList elementsByTagName = el.GetElementsByTagName("KeyWords");

            if (el.Attributes["name"] != null)
            {
                this.Name = el.Attributes["name"].InnerText;
            }
            if (el.Attributes["noescapesequences"] != null)
            {
                this.noEscapeSequences = bool.Parse(el.Attributes["noescapesequences"].InnerText);
            }
            if (el.Attributes["reference"] != null)
            {
                this.reference = el.Attributes["reference"].InnerText;
            }
            if (el.Attributes["ignorecase"] != null)
            {
                this.ignoreCase = bool.Parse(el.Attributes["ignorecase"].InnerText);
            }
            for (int i = 0; i < this.Delimiters.Length; i++)
            {
                this.Delimiters[i] = false;
            }
            if (el["Delimiters"] != null)
            {
                string innerText = el["Delimiters"].InnerText;
                string text      = innerText;
                for (int j = 0; j < text.Length; j++)
                {
                    char c = text[j];
                    this.Delimiters[(int)c] = true;
                }
            }
            this.keyWords    = new LookupTable(!this.IgnoreCase);
            this.prevMarkers = new LookupTable(!this.IgnoreCase);
            this.nextMarkers = new LookupTable(!this.IgnoreCase);
            foreach (XmlElement xmlElement in elementsByTagName)
            {
                HighlightColor value = new HighlightColor(xmlElement);
                XmlNodeList    elementsByTagName2 = xmlElement.GetElementsByTagName("Key");
                foreach (XmlElement xmlElement2 in elementsByTagName2)
                {
                    this.keyWords[xmlElement2.Attributes["word"].InnerText] = value;
                }
            }
            elementsByTagName = el.GetElementsByTagName("Span");
            foreach (XmlElement span in elementsByTagName)
            {
                this.Spans.Add(new Span(span));
            }
            elementsByTagName = el.GetElementsByTagName("MarkPrevious");
            foreach (XmlElement mark in elementsByTagName)
            {
                PrevMarker prevMarker = new PrevMarker(mark);
                this.prevMarkers[prevMarker.What] = prevMarker;
            }
            elementsByTagName = el.GetElementsByTagName("MarkFollowing");
            foreach (XmlElement mark2 in elementsByTagName)
            {
                NextMarker nextMarker = new NextMarker(mark2);
                this.nextMarkers[nextMarker.What] = nextMarker;
            }
        }
Example #2
0
 private void PushCurWord(IDocument document, ref HighlightColor markNext, ArrayList words)
 {
     if (this.currentLength > 0)
     {
         if (words.Count > 0 && this.activeRuleSet != null)
         {
             int i = words.Count - 1;
             while (i >= 0)
             {
                 if (!((TextWord)words[i]).IsWhiteSpace)
                 {
                     TextWord textWord = (TextWord)words[i];
                     if (!textWord.HasDefaultColor)
                     {
                         break;
                     }
                     PrevMarker prevMarker = (PrevMarker)this.activeRuleSet.PrevMarkers[document, this.currentLine, this.currentOffset, this.currentLength];
                     if (prevMarker != null)
                     {
                         textWord.SyntaxColor = prevMarker.Color;
                         break;
                     }
                     break;
                 }
                 else
                 {
                     i--;
                 }
             }
         }
         if (this.inSpan)
         {
             bool           hasDefaultColor = true;
             HighlightColor highlightColor;
             if (this.activeSpan.Rule == null)
             {
                 highlightColor = this.activeSpan.Color;
             }
             else
             {
                 highlightColor  = this.GetColor(this.activeRuleSet, document, this.currentLine, this.currentOffset, this.currentLength);
                 hasDefaultColor = false;
             }
             if (highlightColor == null)
             {
                 highlightColor = this.activeSpan.Color;
                 if (highlightColor.Color == Color.Transparent)
                 {
                     highlightColor = this.GetColorFor("Default");
                 }
                 hasDefaultColor = true;
             }
             words.Add(new TextWord(document, this.currentLine, this.currentOffset, this.currentLength, (markNext != null) ? markNext : highlightColor, hasDefaultColor));
         }
         else
         {
             HighlightColor highlightColor2 = (markNext != null) ? markNext : this.GetColor(this.activeRuleSet, document, this.currentLine, this.currentOffset, this.currentLength);
             if (highlightColor2 == null)
             {
                 words.Add(new TextWord(document, this.currentLine, this.currentOffset, this.currentLength, this.GetColorFor("Default"), true));
             }
             else
             {
                 words.Add(new TextWord(document, this.currentLine, this.currentOffset, this.currentLength, highlightColor2, false));
             }
         }
         if (this.activeRuleSet != null)
         {
             NextMarker nextMarker = (NextMarker)this.activeRuleSet.NextMarkers[document, this.currentLine, this.currentOffset, this.currentLength];
             if (nextMarker != null)
             {
                 if (nextMarker.MarkMarker && words.Count > 0)
                 {
                     TextWord textWord2 = (TextWord)words[words.Count - 1];
                     textWord2.SyntaxColor = nextMarker.Color;
                 }
                 markNext = nextMarker.Color;
             }
             else
             {
                 markNext = null;
             }
         }
         this.currentOffset += this.currentLength;
         this.currentLength  = 0;
     }
 }