void textView_VisualLineConstructionStarting(object sender, VisualLineConstructionStartEventArgs e) { IHighlighter highlighter = ((TextView)sender).Services.GetService(typeof(IHighlighter)) as IHighlighter; if (highlighter != null) { // Force update of highlighting state up to the position where we start generating visual lines. // This is necessary in case the document gets modified above the FirstLineInView so that the highlighting state changes. // We need to detect this case and issue a redraw (through TextViewDocumentHighligher.OnHighlightStateChanged) // before the visual line construction reuses existing lines that were built using the invalid highlighting state. highlighter.GetSpanStack(e.FirstLineInView.LineNumber - 1); } }
public IEnumerable <string> GetSpanColorNamesFromLineStart(int lineNumber) { if (highlighter != null) { // delayed evaluation doesn't cause a problem here: GetSpanStack is called immediately, // only the where/select portian is evaluated later. But that won't be a problem because the // HighlightingSpan instance shouldn't change once it's in use. return(from span in highlighter.GetSpanStack(lineNumber - 1) where span.SpanColor != null && span.SpanColor.Name != null select span.SpanColor.Name); } else { return(Enumerable.Empty <string>()); } }
/// <inheritdoc/> protected override void Colorize(ITextRunConstructionContext context) { this.lastColorizedLine = null; base.Colorize(context); if (this.lastColorizedLine != context.VisualLine.LastDocumentLine) { IHighlighter highlighter = context.TextView.Services.GetService(typeof(IHighlighter)) as IHighlighter; if (highlighter != null) { // In some cases, it is possible that we didn't highlight the last document line within the visual line // (e.g. when the line ends with a fold marker). // But even if we didn't highlight it, we'll have to update the highlighting state for it so that the // proof inside TextViewDocumentHighlighter.OnHighlightStateChanged holds. highlighter.GetSpanStack(context.VisualLine.LastDocumentLine.LineNumber); } } this.lastColorizedLine = null; }
public ICSharpCode.AvalonEdit.Utils.ImmutableStack <HighlightingSpan> GetSpanStack(int lineNumber) { return(baseHighlighter.GetSpanStack(lineNumber)); }