microsoft / microsoft/terminal
Faint attribute works backwards in Light themes
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
### Windows Terminal version
1.20.231215001-llm, and 1.19.3172.0, and 1.18.3181.0
### Windows build number
Windows 10 Pro, 22H2, 19045.3803
### Other Software
_No response_
### Steps to reproduce
The SGR `2m` (Faint) attribute blends with Black, making it work backwards from its name in Light themes, where the default background color is white (or whitish).
It should instead blend with the current background color. Or an argument could be made for it to blend with the default background color.
(I recognize there's a possibility that it's intentionally matching behavior of bugs in other terminals for compatibility purposes, e.g. for compatibility with some Linux terminals.)
### Repro Steps
1. Download this file: [faint_sample.txt](https://github.com/microsoft/terminal/files/13756659/faint_sample.txt)
2. Launch Windows Terminal.
3. Open or select a tab that uses a Light theme, i.e. a theme where the default background color is white (or whitish).
4. Optionally change the font weight to Bold to make it easier to see the color problems.
5. Run `type %USERPROFILE%\Downloads\faint_sample.txt`
### Why This Matters
Most "Light" themes use the same color layout as "Dark" themes (i.e. `30m`..`37m` being defined as darker than `90m`..`97m`). Given that, the only way for an app to "support Light themes" is to either bypass the terminal theme entirely (require users to customize each app's colors separately in addition to customizing the terminal colors), or to only use non-color attributes like `1m` (bold), `2m` (faint), `3m` (italic), `4m` (underline).
I was trying to find a way to not require users to configure every single color individually. I expected `2m` (Faint) to actually produce faint text, i.e. lower contrast versus the background.
As things stand, apps cannot use `2m` (Faint) if they want to behave reasonably when a Light theme is active. Combined with the fact that most Light themes are defined backwards with respect to contrast, and it means the only feasible option seems to be requiring users to manually configure the app colors if the users wants to use a Light theme.
**This is related to #10639; if `GetConsoleScreenBufferEx()` returned the actual current color table, then at least an app could check whether the current theme is Light or Dark, and automatically pick colors with appropriate contrast.**
Trying `2m` was a desperate attempt on my part to find some way to control contrast reliably. What's really needed is for `GetConsoleScreenBufferEx()` to return the actual color table. Or to have some way (any way) to programmatically detect Light themes versus Dark themes in the terminal. There is currently no way to do that. And so there's no way for a program to automatically achieve appropriate contrast; the user has to do it manually (which is extra challenging if a user has a Light theme in some terminal profiles, but a Dark theme in others). Several users have complained to me about color contrast in my app in Light themes, because they don't want to have to configure anything other than the terminal color theme itself. But it's currently out of my hands; it's a limitation in Windows Terminal and/or the Linux "status quo".
### Expected Behavior
_No response_
### Actual Behavior

The `2m Faint` text is always the darkest of the three in each line of output from the sample file. Which against a White background makes it effectively "intense/bold" instead of "faint". In a Light them, the actual effect is opposite from what the name of the attribute claims.
**Expected Behavior:** The `2m Faint` text should be fainter than the other text, so instead of blending with Black, it should blend with White (i.e. the current background; or an argument could be made for it to blend with the default background).
Contributor guide
Research direction
Reproduce the issue with faint_sample.txt in a Light theme using `type %USERPROFILE%\Downloads\faint_sample.txt`, then search the Windows Terminal C++ sources for handling of SGR `2m` (Faint). Compare the rendering against the current or default background color; done means faint text has lower contrast in Light themes without breaking the documented behavior in other themes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100