xtd.console - Reference Guide  0.0.1
Modern c++17 library to manage terminal on Windows, macOS and Linux.

§ background_color() [2/2]

template<class Char >
static bool xtd::basic_console< Char >::background_color ( console_color  color)
inlinestaticnoexcept

Sets the background color of the console.

Parameters
colorAconsole_color that specifies the background color of the console; that is, the color that appears behind each character.
Returns
false if the color specified in a set operation is not a valid member of console_color or I/O error occurred; otherise true.
Remarks
A change to the background_color method affects only output that is written to individual character cells after the background color is changed. To change the background color of the console window as a whole, set the BackgroundColor property and call the Clear method. The following example provides an illustration.
Example
The following example saves the values of the console_color enumeration to an array and stores the current values of the background_color and foreground_color properties to variables. It then changes the foreground color to each color in the console_color enumeration except to the color that matches the current background, and it changes the background color to each color in the console_color enumeration except to the color that matches the current foreground. (If the foreground color is the same as the background color, the text isn't visible.) Finally, it calls the reset_color method to restore the original console colors.