I have a Java program that uses JLine2 to handle input and output on the console terminal. For aesthetic reasons this program works best if the background color of the terminal is white.
So, Is it possible to set the background color of the
I have a Java program that uses JLine2 to handle input and output on the console terminal. For aesthetic reasons this program works best if the background color of the terminal is white.
So, Is it possible to set the background color of the terminal from within java? Ideally using JLine, but I don't mind other solutions as long as they portable and not overly complex.
This is what I would like to do:
ConsoleReader console= new ConsoleReader();
console.getTerminal().setBackgroundColor("WHITE") // <- Ideally!
I would try with escape codes.
White background is
\e[107m, Black foreground
\e[30m, i.e. something like the following leads to black on white:
echo -e "\e[107m\e[30mTest String"
In Java you would a
System.out.println("\\e[107m\\e[30m") during startup of the application.
See List of ANSI color escape sequences and http://misc.flogisoft.com/bash/tip_colors_and_formatting for more details