コード例 #1
0
 void PushColor(HighlightingColor color)
 {
     if (highlightedLine == null)
         return;
     if (color == null) {
         highlightedSectionStack.Push(null);
     } else if (lastPoppedSection != null && lastPoppedSection.Color == color
                && lastPoppedSection.Offset + lastPoppedSection.Length == position + lineStartOffset)
     {
         highlightedSectionStack.Push(lastPoppedSection);
         lastPoppedSection = null;
     } else {
         HighlightedSection hs = new HighlightedSection {
             Offset = position + lineStartOffset,
             Color = color
         };
         highlightedLine.Sections.Add(hs);
         highlightedSectionStack.Push(hs);
         lastPoppedSection = null;
     }
 }
コード例 #2
0
 void ResetColorStack()
 {
     Debug.Assert(position == 0);
     lastPoppedSection = null;
     if (highlightedLine == null) {
         highlightedSectionStack = null;
     } else {
         highlightedSectionStack = new Stack<HighlightedSection>();
         foreach (HighlightingSpan span in spanStack.Reverse()) {
             PushColor(span.SpanColor);
         }
     }
 }
コード例 #3
0
 void PopColor()
 {
     if (highlightedLine == null)
         return;
     HighlightedSection s = highlightedSectionStack.Pop();
     if (s != null) {
         s.Length = (position + lineStartOffset) - s.Offset;
         if (s.Length == 0)
             highlightedLine.Sections.Remove(s);
         else
             lastPoppedSection = s;
     }
 }