How to customize the line height of text sent on the Output window?

Lilo 20 Reputation points
2025-04-15T01:43:14.8866667+00:00

I’m trying to use ILineTransformSourceProvider to customize the height of the lines sent on the “Output” window:

internal class LineTransformSource : ILineTransformSource
{
   public LineTransformSource()
   {
   }

   LineTransform ILineTransformSource.GetLineTransform(ITextViewLine line, double yPosition, ViewRelativePosition placement)
   {
      var lineNumber = line. Snapshot.GetLineFromPosition(line. Start.Position). LineNumber;
      return new LineTransform(0, 0, 1.0)
   }
}

[Export(typeof(ILineTransformSourceProvider))]
[
    //ContentType("any"),  // detects everything less the output window
    ContentType("C/C++"),  // works correctly
    ContentType("output"), // the class never get called
]
//[TextViewRole(PredefinedTextViewRoles.Document)]
internal class LineTransformSourceProvider : ILineTransformSourceProvider
{
   [Import]
   public ITextDocumentFactoryService TextDocumentFactory { get; set; }

   [Import]
   internal SVsServiceProvider ServiceProvider = null;

   ILineTransformSource ILineTransformSourceProvider.Create(IWpfTextView view)
   {
      return new LineTransformSource();
   }
} 

The LineTransformSourceProvider class is not getting called for the “output” content type, it works with any other window like a .h or .cpp files.

An example of what I’m trying to achieve, modifying the line heights on a .cpp file:devenv_o0sO1MgQZA “Output Window” I’m referring to this window where you can output debug datadevenv_rDMUdBZsYn ContentType("output") seems to be the correct “content type”, I’m using IViewTaggerProvider and it does work correctly, just LineTransformSourceProvider that never get called for the “output” content type.

[Export(typeof(IViewTaggerProvider))]
[ContentType("output")]
[TagType(typeof(ClassificationTag))]
internal class ColorTaggerProvider : IViewTaggerProvider
{
    [Import]
    internal IClassificationTypeRegistryService _classificationTypeRegistry = null;
    [Import]
    internal IClassificationFormatMapService _formatMapService = null;

    public ITagger<T> CreateTagger<T>(ITextView view, ITextBuffer buffer) where T : ITag
    {
        return new OutputWindowColorTagger(view, buffer, _classificationTypeRegistry, _formatMapService) as ITagger<T>;
    }
}

If it’s not a bug and the “output” window doesn’t work with ILineTransformSourceProvider how else, I could modify the height of the text lines send there?

I’m testing this Visual Studio extension on VS22 17.14.0 Preview 2.0 (latest version as today)

Developer technologies | Visual Studio | Extensions
{count} votes

Accepted answer
  1. gekka 12,206 Reputation points MVP Volunteer Moderator
    2025-04-15T23:38:19.0033333+00:00
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.ComponentModel.Composition;
    using Microsoft.VisualStudio.Text.Editor;
    using Microsoft.VisualStudio.Utilities;
    using Microsoft.VisualStudio.Text.Formatting;
    
    [Export(typeof(ILineTransformSourceProvider))]
    [TextViewRole(PredefinedTextViewRoles.Interactive)] // <----- This attribute is required
    [ContentType("Output")]
    //[ContentType("BuildOutput")]
    //[ContentType("BuildOrderOutput")]
    //[ContentType("DebugOutput")]
    //[ContentType("TestsOutput")]
    internal class OutputTransformSourceProvider : ILineTransformSourceProvider, ILineTransformSource
    {
        public ILineTransformSource Create(IWpfTextView textView)
        {
            System.Diagnostics.Debug.WriteLine(textView.TextDataModel.ContentType.TypeName);
            return this;
        }
    
    
        public LineTransform GetLineTransform(ITextViewLine line, double yPosition, ViewRelativePosition placement)
        {
            return new LineTransform(10, 10, 1);
        }
    }
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Morgan 0 Reputation points
    2025-04-19T08:25:34.1433333+00:00

    im not really sure of how to do it but try this

    : class Myclass { public: Myclass(); void helloworld(); };

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.