Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong usage of ANSI terminal colors #417

Open
peterpp opened this issue Jan 2, 2020 · 2 comments
Open

Wrong usage of ANSI terminal colors #417

peterpp opened this issue Jan 2, 2020 · 2 comments

Comments

@peterpp
Copy link

peterpp commented Jan 2, 2020

Version: 1.7.2, 2.0.2, 2.3.1

By default, tester output in terminal is colored. But those colors are used wrongly.

First of all, "bright" version of colors can be interpreted as bold text with "basic" color. So color "gray" as defined in Dumper.php can be displayed as bold black. Therefore you can't use "gray" to look texts with less importance.

Than you can't use "white" as font text because with standard ANSI colors and white terminal background, these texts will be barely visible. "white" is usable only together with colored background.

I played with output and this is my suggestion to fix it (all in Dumper.php):

  • replace ($item['file'] === $testFile ? self::color('white') : '') with ($item['file'] === $testFile ? self::color('navy') : '') to highlight file path with row number
  • replace self::color('white', $message) with self::color(null, $message)
  • replace self::color('white') with self::color()
  • replace self::color('gray') with self::color()
@dg
Copy link
Member

dg commented Jan 2, 2020

Do you mean terminals that understand bright as bold?

@peterpp
Copy link
Author

peterpp commented Jan 2, 2020

Of course. Standard terminal on macOS (and also terminal integrated in PhpStorm).

Standard terminal:
Screen Shot 2020-01-02 at 21 38 52

Standard terminal with "Use bright colors for bold text" - the result is even worse and practically not usable:
Screen Shot 2020-01-02 at 21 39 45

Colors turned off in terminal – nearly everything is bold, not ideal:
Screen Shot 2020-01-02 at 21 50 26

With my changes and bold instead of bright:
Screen Shot 2020-01-02 at 21 43 22

With my changes and colors off:
Screen Shot 2020-01-02 at 21 51 32

Finally, yellow color for displaying values is perfect with dark terminal theme, but not very readable with white background. However, I prefer using bold font instead of bright colors.

If I understand it correctly, bright colors are just highlighted version of standard colors and the logical reason for their usage is to make text more visible or different in some way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants