IDEA Run/Debug Console not displaying RGB Ansi codes correctly.

Answered

 I made a demo program to test the ANSI RGB color code and print all 256 possibilities of pure blue colors by changing the blue value and keeping r and g to 0.

When I run it with Git Bash (MINGW64) console, the color displayed correctly. However, when I was trying to run it on the default IDEA run and debug console, it didn't recognize it as an RGB code. Instead, it only recognized it as a regular ANSI color preset code.

 

Note: The ANSI RGB color code is NOT ANSI color preset codes like:

String RED = "\033[31m";

which 31 is the preset code of red, but I am actually using the customized RGB code like:

Ex. A nice orange color would be "\033[38;2;255;178;4m" 
which "\033[38;2;" is the prefix for RGB
and after it is the red green and blue values separated by ";"
and "m" is the suffix for SGR (Select Graphic Rendition).

see https://en.wikipedia.org/wiki/ANSI_escape_code for more details

But the IDEA consoles only read the value before "m", so recognized this light blue code as "\033[ignored;4m", so it showed the preset for 4m which is the format  "Underline."

I already tried Grep Console and it still didn't work. Is there any fix for this?

 

Testing Code:

public class BlueTest
{
public static void main(String[] args)
{
for (int i = 0; i < 256; i += 1)
{
System.out.print(String.format(" \u001b[38;2;0;0;%sm %s \u001b[0m ", i, i));
}
}
}

 

Screenshots:

IDEA:



 

Git Bash (MINGW64):

 

 

2
5 comments

Thanks, @Serge Baranov,

 

But is there a solution to this limitation? For example is it possible to replace the default run / debug console to a different console program than the integrated IDEA console?

0

No solution right now.

0

Theres a coloring plugin https://github.com/krasa/GrepConsole/issues/119 but it does not support ANSI colors at the moment.

It would be very cool if intellij can handle this by itself.

0

Please sign in to leave a comment.