Colorful.Console icon indicating copy to clipboard operation
Colorful.Console copied to clipboard

First WriteWithGradient() replaces all colors in console

Open lvj opened this issue 5 years ago • 5 comments

Version 1.2.10 When using multiple times WriteWithGradient(), console takes colors of 1st call, for example:

 ConsAscii.WriteWithGradient(threed.ToAscii("Blu->Viol").ToString(), Color.Blue, Color.Violet, 16);
ConsAscii.WriteWithGradient(bloody.ToAscii("Viol->Red").ToString(), Color.Violet, Color.Red, 14);
ConsAscii.WriteWithGradient(ansireg.ToAscii("Red->Yellow").ToString(), Color.Red, Color.Yellow, 16);

makes console Violet.

When using ReplaceAllColorsWithDefaults(); after any WriteWithGradient() call excluding last one, it resets colors but still the whole console is of last WriteWithGradient() color before replace.

Using ReplaceAllColorsWithDefaults(); make other output ok but messes whole WriteWithGradient() output.

Also it seems that it is outputting correct colors and then it changes whole console to first call before ReplaceAllColorsWithDefaults();

Without reset: No reset

Reset afert 1st call Reset after 1st call

Reset afert 2nd call Reset after 2nd call

Reset afert 3rd and last call - Colorful messed but Serilog afterwards looks ok Reset after 3rd call

Screenshot taken during outputting* Screenshot taken during outputting

lvj avatar Feb 06 '20 22:02 lvj

me too i am getting the same issue as you!!

(EDIT) I found a fix for that by using Console.ReplaceAllColorsWithDefaults()

nk34player avatar Jun 23 '20 13:06 nk34player

I think the problem is how Windows handles Console colors. They only allow for 16 colors per Console session as far as I know. So when you'd change them to something else, the ones already written will also change.

Z3RYX avatar Jun 25 '20 06:06 Z3RYX

Console.ReplaceAllColorsWithDefaults() is a temporary fix, but it breaks the previous text colors, any update for this?

ghost avatar Mar 15 '21 23:03 ghost

Change Foreground color of console ex: Console.ForegroundColor = Color.WhiteSmoke;

ghost avatar May 07 '21 23:05 ghost

anyone better fix?

fknMega avatar May 19 '21 20:05 fknMega