microsoft/Terminal

Refine customization around text color adjustment

Open

#14.940 aperta il 2 mar 2023

Vedi su GitHub
 (19 commenti) (2 reazioni) (0 assegnatari)C++ (3212 fork)batch import
Area-SettingsHelp WantedIssue-BugIssue-TaskProduct-Terminal

Metriche repository

Star
 (35.764 star)
Metriche merge PR
 (Merge medio 27g 19h) (24 PR mergiate in 30 g)

Descrizione

Windows Terminal version

1.16.10262.0

Windows build number

10.0.22000.0

Other Software

Inside WSL

Steps to reproduce

Running the following shell script:

T='●●●'
echo -e "\n                 40m     41m     42m     43m\
     44m     45m     46m     47m";
for FGs in '    m' '   1m' '  30m' '1;30m' '  31m' '1;31m' '  32m' \
           '1;32m' '  33m' '1;33m' '  34m' '1;34m' '  35m' '1;35m' \
           '  36m' '1;36m' '  37m' '1;37m';
  do FG=${FGs// /}
  echo -en " $FGs \033[$FG  $T  "
  for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
    do echo -en "$EINS \033[$FG\033[$BG  $T  \033[0m";
  done

Expected Behavior

Colors in VS Code terminal look like this (all combinations are readable): image

Actual Behavior

In the Terminal app, things are worse: image

I tried changing color schemes to no avail. Changing "Automatically adjust lightness of indistinguishable text" setting doesn't seem to have any effect either.

2023-03-06 UPDATE

Investigation Into VS Code Inner Workings

The contrast adjustment in VS Code terminal is set by terminal.integrated.minimumContrastRatio in settings. Mentioned in the docs a11y section: .../editor/accessibility#_terminal-accessibility - number between 1 and 21 with 4.5 as a default.

Actually, makes perfect sense it being an accessibility feature. With normal vision some bg/fg combinations are annoyingly hard to process. For a person with even mild colorblindness they could be completely unreadable.

The travel path for the minimum contrast value is:

Most of the math is in there. I haven't found the place where background colors are adjusted (they are clearly darkened a bit).

Reasons to Reuse it for the Terminal App

  • Consistency with the other MS app, people that use the setting in one app may look for the same setting in the other;
  • Good for a11y (the current adjustment algorithm just isn't aggressive enough, since even with normal vision it's hardly noticeable).

Also, it would be really cool to have an option for the Terminal app to outright pick up VS Code settings (color scheme, minimum contrast, font family, font size, keybindings, etc...), but that is certainly a scope creep in the context of this issue.

Guida contributor