ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.79k stars 2.54k forks source link

Error colors in a dark terminal #21389

Closed skiz closed 1 month ago

skiz commented 1 month ago

Zig Version

0.14.0-dev.1510+fb0028a0d

Steps to Reproduce and Observed Behavior

Whenever I receive a compiler error, it's extremely painful to read the actual error line.

This is using the default "Basic" terminal theme on Mac.

Dim Red is a poor choice on a dark terminal. I think most people would actually prefer standard red for error text.

Screenshot 2024-09-11 at 9 34 29 PM

Expected Behavior

I would expect that the errors be readable on a default terminal session, and have the colors configurable via environment variables.

chrboesch commented 1 month ago

The colors in a terminal emulator are usually defined in the configuration for that terminal. For example, in Kitty (also available on a Mac), you define colors 1-15 in kitty.conf or select a theme from Kitty. Then when you call a color from Zig, like we do in Ziglings (as in your example), the text will be displayed exactly as you defined it. Please try that with Kitty or another modern TE.

chrboesch commented 1 month ago

Addendum: In Ziglings we send the escape sequence \x1b[31m for the color red to the terminal. In kitty.conf you define color1 #xyz.. for red. If you change that to color1 #9ece6a, for example, you will see the error messages in green. Not what you want. But there is a very good tool on the web that allows you to fine-tune your favorite color: ColorHexa

squeek502 commented 1 month ago

Those colors aren't coming from Zig, they are from the build.zig of Ziglings.