示例#1
0
 private List <LineSpan> GetHighlightedSpans(long startOffset, long endOffset)
 {
     foreach (Highlighter highlighter in _highlighters)
     {
         if (highlighter.Intersects(startOffset, endOffset))
         {
             var entireLine = new LineSpan(startOffset, endOffset, SystemColors.WindowText, SystemColors.Window, true);
             return(BreakIntoHighlightedSpans(entireLine));
         }
     }
     return(null);
 }
示例#2
0
        private List <LineSpan> BreakIntoHighlightedSpans(LineSpan lineSpan)
        {
            List <LineSpan> result = BreakIntoSpans(_highlighters[0], lineSpan);

            for (int i = 1; i < _highlighters.Count; i++)
            {
                var curHighlighter = _highlighters[i];
                var nextResult     = new List <LineSpan>();
                result.ForEach(span => nextResult.AddRange(BreakIntoSpans(curHighlighter, span)));
                result = nextResult;
            }
            return(result);
        }
示例#3
0
        private static List <LineSpan> BreakIntoSpans(Highlighter highlighter, LineSpan span)
        {
            var result = new List <LineSpan>();

            if (highlighter.Intersects(span.Start, span.End))
            {
                if (highlighter.StartOffset > span.Start)
                {
                    result.Add(new LineSpan(span.Start, highlighter.StartOffset, span.TextColor, span.BackgroundColor, true));
                }
                result.Add(new LineSpan(Math.Max(span.Start, highlighter.StartOffset), Math.Min(span.End, highlighter.EndOffset),
                                        highlighter.TextColor.HasValue ? highlighter.TextColor.Value : span.TextColor,
                                        highlighter.BackgroundColor.HasValue ? highlighter.BackgroundColor.Value : span.BackgroundColor, false));
                if (highlighter.EndOffset < span.End)
                {
                    result.Add(new LineSpan(highlighter.EndOffset, span.End, span.TextColor, span.BackgroundColor, true));
                }
            }
            else
            {
                result.Add(span);
            }
            return(result);
        }
示例#4
0
 private List<LineSpan> GetHighlightedSpans(long startOffset, long endOffset)
 {
     foreach (Highlighter highlighter in _highlighters)
     {
         if (highlighter.Intersects(startOffset, endOffset))
         {
             var entireLine = new LineSpan(startOffset, endOffset, SystemColors.WindowText, SystemColors.Window, true);
             return BreakIntoHighlightedSpans(entireLine);
         }
     }
     return null;
 }
示例#5
0
 private List<LineSpan> BreakIntoHighlightedSpans(LineSpan lineSpan)
 {
     List<LineSpan> result = BreakIntoSpans(_highlighters[0], lineSpan);
     for (int i = 1; i < _highlighters.Count; i++)
     {
         var curHighlighter = _highlighters[i];
         var nextResult = new List<LineSpan>();
         result.ForEach(span => nextResult.AddRange(BreakIntoSpans(curHighlighter, span)));
         result = nextResult;
     }
     return result;
 }
示例#6
0
 private static List<LineSpan> BreakIntoSpans(Highlighter highlighter, LineSpan span)
 {
     var result = new List<LineSpan>();
     if (highlighter.Intersects(span.Start, span.End))
     {
         if (highlighter.StartOffset > span.Start)
         {
             result.Add(new LineSpan(span.Start, highlighter.StartOffset, span.TextColor, span.BackgroundColor, true));
         }
         result.Add(new LineSpan(Math.Max(span.Start, highlighter.StartOffset), Math.Min(span.End, highlighter.EndOffset),
             highlighter.TextColor.HasValue ? highlighter.TextColor.Value : span.TextColor,
             highlighter.BackgroundColor.HasValue ? highlighter.BackgroundColor.Value : span.BackgroundColor, false));
         if (highlighter.EndOffset < span.End)
         {
             result.Add(new LineSpan(highlighter.EndOffset, span.End, span.TextColor, span.BackgroundColor, true));
         }
     }
     else
         result.Add(span);
     return result;
 }