60 [&name] ( std::pair<std::string, std::string>
const& elem ) {
78 [&name] ( std::pair<std::string, std::string>
const& elem ) {
143 if( foreground_ ==
"" ) {
165 if( background_ ==
"" ) {
199 std::vector<std::string> attribs;
202 attribs.push_back(
"1" );
211 return join( attribs,
";" );
236 if( attribs.size() > 0 ) {
252 if( attribs.size() > 0 ) {
286 throw std::out_of_range(
"No foreground color named " + name +
".");
303 {
"LightGray",
"37" },
304 {
"DarkGray",
"90" },
305 {
"LightRed",
"91" },
306 {
"LightGreen",
"92" },
307 {
"LightYellow",
"93" },
308 {
"LightBlue",
"94" },
309 {
"LightMagenta",
"95" },
310 {
"LightCyan",
"96" },
337 throw std::out_of_range(
"No background color named " + name +
".");
354 {
"LightGray",
"47" },
355 {
"DarkGray",
"100" },
356 {
"LightRed",
"101" },
357 {
"LightGreen",
"102" },
358 {
"LightYellow",
"103" },
359 {
"LightBlue",
"104" },
360 {
"LightMagenta",
"105" },
361 {
"LightCyan",
"106" },
384 out <<
"Bold: " << ( style.
bold() ?
"true" :
"false" ) <<
"\n";
static std::string get_attribute_string_(Style const &s)
Internal helper function that returns the attribute string of a Style based on its properties...
static bool is_background_color(std::string name)
Return true iff the given name is a background color name.
static std::string get_foreground_color_value(std::string name)
Return the color value string for a given foreground color name.
Simple text style class for colorized and bold output to a terminal.
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
std::ostream & operator<<(std::ostream &os, const Matrix< signed char > &matrix)
Template specialization for signed char, in order to print nicely.
std::string operator()(std::string const &text) const
Operator that returns a text with the current Style applied to it.
std::string join(T const &v, std::string const &delimiter=", ")
Return a string where the elements of a container v are joined using the string delimiter in between ...
std::string replace_all(std::string const &text, std::string const &search, std::string const &replace)
Return a copy of a string, where all occurrences of a search string are replaced by a replace string...
std::string to_bash_string(std::string const &text) const
Additional output function with the same purpose as operator().
std::string to_python_string(std::string const &text) const
Additional output function with the same purpose as operator().
std::string foreground_color() const
Provides some commonly used string utility functions.
bool equals_ci(std::string const &lhs, std::string const &rhs)
Compare two strings case insensitive.
static std::array< std::pair< std::string, std::string >, 17 >::const_iterator get_foreground_color_iterator(std::string name)
Internal helper function that returns an iterator into the foreground color list. ...
static bool is_foreground_color(std::string name)
Return true iff the given name is a foreground color name.
bool enabled() const
Return whether the Style is currently enabled.
Style & reset()
Reset the Style to use not colors and not bold.
static std::string get_background_color_value(std::string name)
Return the color value string for a given background color name.
static std::array< std::pair< std::string, std::string >, 17 >::const_iterator get_background_color_iterator(std::string name)
Internal helper function that returns an iterator into the background color list. ...
static const std::array< std::pair< std::string, std::string >, 17 > background_colors
List of all valid background color names and their color strings.
std::string background_color() const
static const std::array< std::pair< std::string, std::string >, 17 > foreground_colors
List of all valid foreground color names and their color strings.
bool bold() const
Return whether the Style uses bold.