fisheva / Eva-Theme

A comfortable and semantic theme.
https://marketplace.visualstudio.com/items?itemName=fisheva.eva-theme
MIT License
452 stars 38 forks source link

Colors in integrated terminal #58

Closed pespinho closed 2 years ago

pespinho commented 3 years ago

Hello fisheva.

I have found a problem with the colors of the integrated terminal while using the extension.

The problem exists for both light and dark themes and I don't know if it is fixable since, as far as I could tell, it also exists when using some other built-in themes like Solarized Dark and Solarized Light.

The problem occurred when programming a console application using .NET 5.0 in C#.

When trying to output a text with the color ConsoleColor.Yellow on the terminal, the text was displayed in red(ish). This prompted me to investigate further and I found some code (by bradwilson) that tested all combinations of ConsoleColor for background and foreground.

The results can be seen in the screenshots below for the Eva Dark Bold theme and for the standard Dark+ theme. You can see how many colors are completely different than expected.

Screenshot

Dark+ (Expected colors):

image

Eva Dark Bold:

image

Code Snippet

Code in C#:

using System;
using System.Linq;

namespace colors
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine();

            var colors = Enum.GetValues(typeof(ConsoleColor)).Cast<ConsoleColor>().ToList();
            foreach (var fore in colors)
            {
                foreach (var back in colors)
                {
                    Console.ForegroundColor = fore;
                    Console.BackgroundColor = back;
                    Console.Write(" *** ");

                    Console.ResetColor();
                    Console.Write("  ");
                }

                Console.WriteLine();
            }

            Console.WriteLine();
        }
    }
}
pespinho commented 3 years ago

I think the problem is how the ANSI colors are defined for the theme. As far as I understand, looking here and here, the default themes do not define the ANSI colors.

If we were to define the colors as shown in my screenshot when using the Dark+ theme, I think the definition should be as follows:

"terminal.ansiBlack": "#000000",
"terminal.ansiBlue": "#2473C8",
"terminal.ansiBrightBlack": "#666666",
"terminal.ansiBrightBlue": "#3B8DEA",
"terminal.ansiBrightCyan": "#29B7DB",
"terminal.ansiBrightGreen": "#23D18B",
"terminal.ansiBrightMagenta": "#D670D6",
"terminal.ansiBrightRed": "#F14C4C",
"terminal.ansiBrightWhite": "#E5E5E5",
"terminal.ansiBrightYellow": "#F5F543",
"terminal.ansiCyan": "#11A7CD",
"terminal.ansiGreen": "#0DBC79",
"terminal.ansiMagenta": "#BC3FBC",
"terminal.ansiRed": "#CD3131",
"terminal.ansiWhite": "#E5E5E5",
"terminal.ansiYellow": "#E5E510",

What do you think?

pespinho commented 3 years ago

Just removing the terminal.ansi... entries from the json files, solved the problem for me.

image
pespinho commented 2 years ago

Another possibility can be using a mixture of the colors that were already used with few new colors to match the idea behind the colors. For example, this colors

"terminal.ansiBlack": "#000000",
"terminal.ansiBlue": "#598def",
"terminal.ansiBrightBlack": "#666666",
"terminal.ansiBrightBlue": "#6495ee",
"terminal.ansiBrightCyan": "#56b7c3",
"terminal.ansiBrightGreen": "#98c379",
"terminal.ansiBrightMagenta": "#ff6ab3",
"terminal.ansiBrightRed": "#f14c4c",
"terminal.ansiBrightWhite": "#E5E5E5",
"terminal.ansiBrightYellow": "#e4bf7f",
"terminal.ansiCyan": "#50b1BD",
"terminal.ansiGreen": "#3ec33e",
"terminal.ansiMagenta": "#f02b77",
"terminal.ansiRed": "#e51400",
"terminal.ansiWhite": "#E5E5E5",
"terminal.ansiYellow": "#ff8a4c",

result in this pallet of colors:

image

This could help maintaining the style of the theme.

fisheva commented 2 years ago

Sorry to reply late.

Very thank you for your detailed problem description and tests! They're really very help! Terminal has always been like a black box to me. According to your problem description and the screenshots provided, I infer that they print in turn:

terminal.ansiBlack,
terminal.ansiBlue,
terminal.ansiGreen,
terminal.ansiCyan,
terminal.ansiRed,
terminal.ansiMagenta,
terminal.ansiYellow,
terminal.ansiWhite,

terminal.ansiBrightBlack,
terminal.ansiBrightBlue,
terminal.ansiBrightGreen,
terminal.ansiBrightCyan,
terminal.ansiBrightRed,
terminal.ansiBrightMagenta,
terminal.ansiBrightYellow,
terminal.ansiBrightWhite,

Now we know that these APIs control not only the default text color or text background-color in terminal, but also the output text color of operations, such as consolecolor.Yellow. Therefore, we need to try to make the color of each API match the color system described by its words. For example:

consolecolor.Yellow: output some yellow text. consolecolor.Red: output some red text. consolecolor.White: output some white text. ...

I have reset their colors, please update Eva Theme to the latest version. Can you remake two comparison pictures (default Dark+ & Eva Dark, default Light+ & Eva Light) like this for me? I tried to run your C# code on my computer, but failed. Very thanks! 20210802103839

When you remade those two pictures, you will see, terminal.ansiBrightWhite is a special one. It doesn't match the color system described by its word(It's not a white color, but gray, in Eva Light). Because of the following picture comes from issue 28. 123

terminal.ansiBrightWhite control the white color file directory text in the picture. In order to make these text more visible, I set terminal.ansiBrightWhite to the color of comment text. In the furture, other APIs may be changed for similar reasons too.

At last, can you test which API color does consolecolor.White output in Eva Light, terminal.ansiWhite(white,#FFF) or terminal.ansiBrightWhite(gray,#AAADB4) ? Thanks!

Since it is difficult to reproduce the text encountered by others in terminal, the API color setting of terminal has always been the place with the most user feedback issues. Please allow me to post this reply in Chinese below to facilitate other users to read and understand the difficulties of terminal setting in the future.

fisheva commented 2 years ago

非常感谢您对问题的详细描述和测试!这真的很有帮助!终端对我来说一直像个黑盒。根据您的问题描述和提供的屏幕截图,我推断它们依次打印:

terminal.ansiBlack,
terminal.ansiBlue,
terminal.ansiGreen,
terminal.ansiCyan,
terminal.ansiRed,
terminal.ansiMagenta,
terminal.ansiYellow,
terminal.ansiWhite,

terminal.ansiBrightBlack,
terminal.ansiBrightBlue,
terminal.ansiBrightGreen,
terminal.ansiBrightCyan,
terminal.ansiBrightRed,
terminal.ansiBrightMagenta,
terminal.ansiBrightYellow,
terminal.ansiBrightWhite,

现在我们知道,这些API不仅控制终端中的默认文本颜色或文字背景色,还控制类似consolecolor.Yellow这种操作输出的文本色。因此,我们需要尽可能使每个API的颜色与其文字描述的色系相匹配。例如:

consolecolor.Yellow:输出一些黄色文字。

consolecolor.Red:输出一些红色文字。

consolecolor.White:输出一些白色文字。 ...

我重新设置了它们的颜色, 请将Eva Theme更新至最新版本。您能帮我再做两张像这样的对比图片(default Dark+ & Eva Dark, default Light+ & Eva Light)吗?我尝试在我的计算机上运行您的C#代码,但失败了。非常感谢! 20210802103839

当你重新制作这二张图片时,你会看到,terminal.ansiBrightWhite比较特殊:它与它的文字所描述的色系不匹配(在Eva Light下,它不是白色,而是灰色),因为来自issue 28的下图。 123

terminal.ansibrightwite控制图片中白色的文件目录文字。为了使这些文字看得更清楚,我将terminal.ansibrightwite设置成注释文本的颜色。今后,其他API也可能因类似原因而更改。

最后请帮我测试下consolecolor.White在Eva Light下输出的是哪种API颜色、terminal.ansiWhite(白色,#FFF)还是terminal.ansiBrightWhite(灰色,#AAADB4)?感谢!

pespinho commented 2 years ago

Hello, fisheva!

Thank you very much for answering here and taking the time to fix the issue.

I reran the tests and I think it yielded now a satisfactory result:

Dark+:

image

Eva Dark Bold:

image

Light+:

image

Eva Light Bold:

image

What do you think?

pespinho commented 2 years ago

Now, looking to it again, I think the ansiWhite color could be darker in the light theme and the ansiBrightWhite could be a lot more like white in the dark theme. Don't you think?

fisheva commented 2 years ago

Sorry for the late reply. I was too busy these days.

Here are the pictures of all colors of the current terminal (made by PS with the pictures you provided, thanks again!).

Eva Dark Eva Dark

Eva Light Eva Light

Compared with the above, 1, terminal.ansiBrightBlack and terminal.ansiBrightWhite are exchanged in both Eva Dark & Light. (As you wish) 2, terminal.ansiBlack and terminal.ansiWhite are exchanged in Eva Light.

The reson of 2 is, I think the visibility of #000 in Eva Light is equal to that of #FFF in Eva Dark. The same to #FFF in Eva Light and #000 in Eva Dark.