public HighlightRuleSet(XmlElement el) { if (el.Attributes["name"] != null) { this.Name = el.Attributes["name"].InnerText; } if (el.HasAttribute("escapecharacter")) { this.escapeCharacter = el.GetAttribute("escapecharacter")[0]; } 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 < (int)this.Delimiters.Length; i++) { this.delimiters[i] = false; } if (el["Delimiters"] != null) { string innerText = el["Delimiters"].InnerText; for (int j = 0; j < innerText.Length; j++) { char chr = innerText[j]; this.delimiters[chr] = true; } } this.keyWords = new LookupTable(!this.IgnoreCase); this.prevMarkers = new LookupTable(!this.IgnoreCase); this.nextMarkers = new LookupTable(!this.IgnoreCase); foreach (XmlElement elementsByTagName in el.GetElementsByTagName("KeyWords")) { HighlightColor highlightColor = new HighlightColor(elementsByTagName); foreach (XmlElement xmlElement in elementsByTagName.GetElementsByTagName("Key")) { this.keyWords[xmlElement.Attributes["word"].InnerText] = highlightColor; } } foreach (XmlElement elementsByTagName1 in el.GetElementsByTagName("Span")) { this.Spans.Add(new Span(elementsByTagName1)); } foreach (XmlElement xmlElement1 in el.GetElementsByTagName("MarkPrevious")) { PrevMarker prevMarker = new PrevMarker(xmlElement1); this.prevMarkers[prevMarker.What] = prevMarker; } foreach (XmlElement elementsByTagName2 in el.GetElementsByTagName("MarkFollowing")) { NextMarker nextMarker = new NextMarker(elementsByTagName2); this.nextMarkers[nextMarker.What] = nextMarker; } }
public HighlightRuleSet(XmlElement el) { XmlNodeList nodes; if (el.Attributes["name"] != null) { Name = el.Attributes["name"].InnerText; } if (el.HasAttribute("escapecharacter")) { escapeCharacter = el.GetAttribute("escapecharacter")[0]; } if (el.Attributes["reference"] != null) { reference = el.Attributes["reference"].InnerText; } if (el.Attributes["ignorecase"] != null) { ignoreCase = Boolean.Parse(el.Attributes["ignorecase"].InnerText); } for (int i = 0; i < Delimiters.Length; ++i) { delimiters[i] = false; } if (el["Delimiters"] != null) { string delimiterString = el["Delimiters"].InnerText; foreach (char ch in delimiterString) { delimiters[(int)ch] = true; } } // Spans = new LookupTable(!IgnoreCase); keyWords = new LookupTable(!IgnoreCase); prevMarkers = new LookupTable(!IgnoreCase); nextMarkers = new LookupTable(!IgnoreCase); nodes = el.GetElementsByTagName("KeyWords"); foreach (XmlElement el2 in nodes) { HighlightColor color = new HighlightColor(el2); XmlNodeList keys = el2.GetElementsByTagName("Key"); foreach (XmlElement node in keys) { keyWords[node.Attributes["word"].InnerText] = color; } } nodes = el.GetElementsByTagName("Span"); foreach (XmlElement el2 in nodes) { Spans.Add(new Span(el2)); /* * Span span = new Span(el2); * Spans[span.Begin] = span;*/ } nodes = el.GetElementsByTagName("MarkPrevious"); foreach (XmlElement el2 in nodes) { PrevMarker prev = new PrevMarker(el2); prevMarkers[prev.What] = prev; } nodes = el.GetElementsByTagName("MarkFollowing"); foreach (XmlElement el2 in nodes) { NextMarker next = new NextMarker(el2); nextMarkers[next.What] = next; } }
public HighlightRuleSet(XmlElement el) { XmlNodeList nodes; if (el.Attributes["name"] != null) { Name = el.Attributes["name"].InnerText; } if (el.HasAttribute("escapecharacter")) { escapeCharacter = el.GetAttribute("escapecharacter")[0]; } if (el.Attributes["reference"] != null) { reference = el.Attributes["reference"].InnerText; } if (el.Attributes["ignorecase"] != null) { ignoreCase = Boolean.Parse(el.Attributes["ignorecase"].InnerText); } for (int i = 0; i < Delimiters.Length; ++i) { delimiters[i] = false; } if (el["Delimiters"] != null) { string delimiterString = el["Delimiters"].InnerText; foreach (char ch in delimiterString) { delimiters[(int)ch] = true; } } // Spans = new LookupTable(!IgnoreCase); keyWords = new LookupTable(!IgnoreCase); prevMarkers = new LookupTable(!IgnoreCase); nextMarkers = new LookupTable(!IgnoreCase); nodes = el.GetElementsByTagName("KeyWords"); foreach (XmlElement el2 in nodes) { HighlightColor color = new HighlightColor(el2); XmlNodeList keys = el2.GetElementsByTagName("Key"); foreach (XmlElement node in keys) { keyWords[node.Attributes["word"].InnerText] = color; } } nodes = el.GetElementsByTagName("Span"); foreach (XmlElement el2 in nodes) { Spans.Add(new Span(el2)); /* Span span = new Span(el2); Spans[span.Begin] = span;*/ } nodes = el.GetElementsByTagName("MarkPrevious"); foreach (XmlElement el2 in nodes) { PrevMarker prev = new PrevMarker(el2); prevMarkers[prev.What] = prev; } nodes = el.GetElementsByTagName("MarkFollowing"); foreach (XmlElement el2 in nodes) { NextMarker next = new NextMarker(el2); nextMarkers[next.What] = next; } }
public HighlightRuleSet(XmlElement el) { if (el.Attributes["name"] != null) { Name = el.Attributes["name"].InnerText; } if (el.HasAttribute("escapecharacter")) { EscapeCharacter = el.GetAttribute("escapecharacter")[index : 0]; } if (el.Attributes["reference"] != null) { Reference = el.Attributes["reference"].InnerText; } if (el.Attributes["ignorecase"] != null) { IgnoreCase = bool.Parse(el.Attributes["ignorecase"].InnerText); } for (var i = 0; i < Delimiters.Length; ++i) { Delimiters[i] = false; } if (el["Delimiters"] != null) { var delimiterString = el["Delimiters"].InnerText; foreach (var ch in delimiterString) { Delimiters[ch] = true; } } // Spans = new LookupTable(!IgnoreCase); KeyWords = new LookupTable(!IgnoreCase); PrevMarkers = new LookupTable(!IgnoreCase); NextMarkers = new LookupTable(!IgnoreCase); var nodes = el.GetElementsByTagName("KeyWords"); foreach (XmlElement el2 in nodes) { var color = new HighlightColor(el2); var keys = el2.GetElementsByTagName("Key"); foreach (XmlElement node in keys) { KeyWords[node.Attributes["word"].InnerText] = color; } } nodes = el.GetElementsByTagName("Span"); foreach (XmlElement el2 in nodes) { Spans.Add(new Span(el2)); } /* * Span span = new Span(el2); * Spans[span.Begin] = span;*/ nodes = el.GetElementsByTagName("MarkPrevious"); foreach (XmlElement el2 in nodes) { var prev = new PrevMarker(el2); PrevMarkers[prev.What] = prev; } nodes = el.GetElementsByTagName("MarkFollowing"); foreach (XmlElement el2 in nodes) { var next = new NextMarker(el2); NextMarkers[next.What] = next; } }
/// <summary> /// pushes the curWord string on the word list, with the /// correct color. /// </summary> void PushCurWord(IDocument document, ref HighlightColor markNext, List <TextWord> words) { // Svante Lidman : Need to look through the next prev logic. if (currentLength > 0) { if (words.Count > 0 && activeRuleSet != null) { TextWord prevWord = null; int pInd = words.Count - 1; while (pInd >= 0) { if (!((TextWord)words[pInd]).IsWhiteSpace) { prevWord = (TextWord)words[pInd]; if (prevWord.HasDefaultColor) { PrevMarker marker = (PrevMarker)activeRuleSet.PrevMarkers[document, currentLine, currentOffset, currentLength]; if (marker != null) { prevWord.SyntaxColor = marker.Color; // document.Caret.ValidateCaretPos(); // document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, document.GetLineNumberForOffset(document.Caret.Offset))); } } break; } pInd--; } } if (inSpan) { HighlightColor c = null; bool hasDefaultColor = true; if (activeSpan.Rule == null) { c = activeSpan.Color; } else { c = GetColor(activeRuleSet, document, currentLine, currentOffset, currentLength); hasDefaultColor = false; } if (c == null) { c = activeSpan.Color; if (c.Color == Color.Transparent) { c = this.DefaultTextColor; } hasDefaultColor = true; } words.Add(new TextWord(document, currentLine, currentOffset, currentLength, markNext != null ? markNext : c, hasDefaultColor)); } else { HighlightColor c = markNext != null ? markNext : GetColor(activeRuleSet, document, currentLine, currentOffset, currentLength); if (c == null) { words.Add(new TextWord(document, currentLine, currentOffset, currentLength, this.DefaultTextColor, true)); } else { words.Add(new TextWord(document, currentLine, currentOffset, currentLength, c, false)); } } if (activeRuleSet != null) { NextMarker nextMarker = (NextMarker)activeRuleSet.NextMarkers[document, currentLine, currentOffset, currentLength]; if (nextMarker != null) { if (nextMarker.MarkMarker && words.Count > 0) { TextWord prevword = ((TextWord)words[words.Count - 1]); prevword.SyntaxColor = nextMarker.Color; } markNext = nextMarker.Color; } else { markNext = null; } } currentOffset += currentLength; currentLength = 0; } }
private void PushCurWord(IDocument document, ref HighlightColor markNext, List <TextWord> words) { if (this.currentLength > 0) { if (words.Count > 0 && this.activeRuleSet != null) { TextWord item = null; int count = words.Count - 1; while (count >= 0) { if (words[count].IsWhiteSpace) { count--; } else { item = words[count]; if (!item.HasDefaultColor) { break; } PrevMarker prevMarker = (PrevMarker)this.activeRuleSet.PrevMarkers[document, this.currentLine, this.currentOffset, this.currentLength]; if (prevMarker == null) { break; } item.SyntaxColor = prevMarker.Color; break; } } } if (!this.inSpan) { HighlightColor highlightColor = (markNext != null ? markNext : this.GetColor(this.activeRuleSet, document, this.currentLine, this.currentOffset, this.currentLength)); if (highlightColor != null) { words.Add(new TextWord(document, this.currentLine, this.currentOffset, this.currentLength, highlightColor, false)); } else { words.Add(new TextWord(document, this.currentLine, this.currentOffset, this.currentLength, this.DefaultTextColor, true)); } } else { HighlightColor color = null; bool flag = true; if (this.activeSpan.Rule != null) { color = this.GetColor(this.activeRuleSet, document, this.currentLine, this.currentOffset, this.currentLength); flag = false; } else { color = this.activeSpan.Color; } if (color == null) { color = this.activeSpan.Color; if (color.Color == Color.Transparent) { color = this.DefaultTextColor; } flag = true; } words.Add(new TextWord(document, this.currentLine, this.currentOffset, this.currentLength, (markNext != null ? markNext : color), flag)); } if (this.activeRuleSet != null) { NextMarker nextMarker = (NextMarker)this.activeRuleSet.NextMarkers[document, this.currentLine, this.currentOffset, this.currentLength]; if (nextMarker == null) { markNext = null; } else { if (nextMarker.MarkMarker && words.Count > 0) { TextWord textWord = words[words.Count - 1]; textWord.SyntaxColor = nextMarker.Color; } markNext = nextMarker.Color; } } this.currentOffset += this.currentLength; this.currentLength = 0; } }