ANSI/VT transparent and black background mismatch #5460

Open
opened 2026-01-31 00:13:55 +00:00 by claunia · 0 comments
Owner

Originally created by @PhMajerus on GitHub (Dec 8, 2019).

Tested on Windows Terminal 0.7.3382.0 from Store on Windows 10 1909 build 18363.476.
CUI App is my ActiveScript Shell, but only used because it makes it easy to send full strings to the Console API and JavaScript is easy for most to read, the problem seems to be with the rendering, or with the way conhost stores and retrieves cells colors.

ANSI VT has codes to set foreground and background colors, and codes to use default foreground and background colors (39, 49).
Windows Terminal has a nice transparency effect when the default background is used that makes it use Acrylic translucency.
The problem is that the terminal seems to lose track of what has been output as black (30 or 40) when it is the cell's background color and what has been output as default background color (49).

Writing something with a black background, using color 40 (or 30 and reversed using 7), the expectation is to have that color show as black, transparency should be achieved only by color 49.
This is important when doing ANSI-art and for consistency.
However, it seems the current implementation doesn't keep track of default colors 39 and 49, and instead assumes all cells with color 40 as their background to be the default background color or transparent, basically converting it to 49.
It also converts the other way around, using transparent (49) reversed should show the text as transparent, but instead converts it to black (30).

Reversed black vs transparent

Let me know if my explanations aren't clear enough or if you really need a Win32 API repro.

Originally created by @PhMajerus on GitHub (Dec 8, 2019). Tested on Windows Terminal 0.7.3382.0 from Store on Windows 10 1909 build 18363.476. CUI App is my ActiveScript Shell, but only used because it makes it easy to send full strings to the Console API and JavaScript is easy for most to read, the problem seems to be with the rendering, or with the way conhost stores and retrieves cells colors. ANSI VT has codes to set foreground and background colors, and codes to use default foreground and background colors (39, 49). Windows Terminal has a nice transparency effect when the default background is used that makes it use Acrylic translucency. The problem is that the terminal seems to lose track of what has been output as black (30 or 40) when it is the cell's background color and what has been output as default background color (49). Writing something with a black background, using color 40 (or 30 and reversed using 7), the expectation is to have that color show as black, transparency should be achieved only by color 49. This is important when doing ANSI-art and for consistency. However, it seems the current implementation doesn't keep track of default colors 39 and 49, and instead assumes all cells with color 40 as their background to be the default background color or transparent, basically converting it to 49. It also converts the other way around, using transparent (49) reversed should show the text as transparent, but instead converts it to black (30). ![Reversed black vs transparent](https://user-images.githubusercontent.com/25664275/70388982-aff5ff00-19b9-11ea-98e6-3d7c3e922e93.png) Let me know if my explanations aren't clear enough or if you really need a Win32 API repro.
claunia added the Resolution-Duplicate label 2026-01-31 00:13:55 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5460