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); }
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); }
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); }
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; }
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; }
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; }