Probably the simplest way to go is to set the background colour of your text with ANSI:
For instance using:
echo -e "e[37me[41m"
will give you blue text on a red background (you can use this to test the effect in dramatic, easy to see colours).
Whereas
echo -e "e[97me[40m"
will set the foreground to white and the background to black for the duration of your program.
If you find that you're getting a kind of ugly transition zone between your background colour and the terminal's just print a sufficient number of newlines to wipe the whole screen.
To use this in C, you'll obviously want printf
instead of echo
.
The wiki page on ANSI escape codes has additional information.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…