<p dir="auto">Right now, every time Renderer needs to switch the brush colors, it does the following:</p>
<ol dir="auto">
<li>get the <code class="notranslate">TextColor</code> from the attribute run</li>
<li>get the RGB value of the color from the color table</li>
<li>pass that to <code class="notranslate">Engine::UpdateDrawingBrushes</code></li>
</ol>
<p dir="auto">Step 2 is lossy, and is the source of a class of bugs I'll call "ConPTY narrowing" bugs. In addition, there's a step where <code class="notranslate">VtEngine</code> needs to <em>know the color table</em> to do a translation from RGB back into indexed color.</p>
<p dir="auto"><strong>"narrowing" bugs</strong></p>
<table role="table">
<thead>
<tr>
<th>application output</th>
<th>conpty sends</th>
<th>why</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="notranslate">\e[38;2;22;198;12m</code></td>
<td><code class="notranslate">\e[92m</code></td>
<td>RGB(22, 198, 12) matches color index 10 in Campbell</td>
</tr>
<tr>
<td><code class="notranslate">\e[38;5;127m</code></td>
<td><code class="notranslate">\e[38;2;175;0;175m</code></td>
<td>the xterm-256color color palette gets translated into RGB because Campbell only covers 0-16</td>
</tr>
<tr>
<td><code class="notranslate">\e[38;2;12;12;12m</code></td>
<td><code class="notranslate">\e[30m</code></td>
<td>RGB(12, 12, 12) matches index 0 in Campbell <em>and index 0 is the default color</em> (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="372725082" data-permission-text="Title is private" data-url="https://github.com/microsoft/terminal/issues/293" data-hovercard-type="issue" data-hovercard-url="/microsoft/terminal/issues/293/hovercard" href="https://github.com/microsoft/terminal/issues/293">#293</a>)</td>
</tr>
</tbody>
</table>
<p dir="auto">If Renderer passed the TextColor directly to the Engine, Xterm256Engine could pass through all indexed colors unchanged, and XtermEngine and WinTelnetEngine could flatten to the 16-color space.</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="502958810" data-permission-text="Title is private" data-url="https://github.com/microsoft/terminal/issues/3076" data-hovercard-type="issue" data-hovercard-url="/microsoft/terminal/issues/3076/hovercard" href="https://github.com/microsoft/terminal/issues/3076">#3076</a> is caused by us doing early unpacking of colors and boldness; deferring until later will yield an improvement in preservation of underline status.</li>
</ul>
<p dir="auto">Pressing the settings-button does not open the settings tab. Instead it opens a .json file in Visual Studio 2019.<br>
OS: Windows 10 Pro 1903 (Build 18362.418)<br>
Windows Terminal Version 0.5.2762.0</p>