mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 19:10:11 +08:00
feat: add runtime colorize flag
This commit is contained in:
@@ -419,7 +419,8 @@ struct region final : public region_base
|
|||||||
// to show a better error message.
|
// to show a better error message.
|
||||||
inline std::string format_underline(const std::string& message,
|
inline std::string format_underline(const std::string& message,
|
||||||
const std::vector<std::pair<region_base const*, std::string>>& reg_com,
|
const std::vector<std::pair<region_base const*, std::string>>& reg_com,
|
||||||
const std::vector<std::string>& helps = {})
|
const std::vector<std::string>& helps = {},
|
||||||
|
const bool colorize = TOML11_COLORED_MESSAGE_ACTIVATED)
|
||||||
{
|
{
|
||||||
assert(!reg_com.empty());
|
assert(!reg_com.empty());
|
||||||
|
|
||||||
@@ -434,9 +435,10 @@ inline std::string format_underline(const std::string& message,
|
|||||||
|
|
||||||
std::ostringstream retval;
|
std::ostringstream retval;
|
||||||
|
|
||||||
#ifdef TOML11_COLORIZE_ERROR_MESSAGE
|
if(colorize)
|
||||||
|
{
|
||||||
retval << color::colorize; // turn on ANSI color
|
retval << color::colorize; // turn on ANSI color
|
||||||
#endif
|
}
|
||||||
|
|
||||||
retval << color::bold << color::red << "[error] " << color::reset
|
retval << color::bold << color::red << "[error] " << color::reset
|
||||||
<< color::bold << message << color::reset << '\n';
|
<< color::bold << message << color::reset << '\n';
|
||||||
|
Reference in New Issue
Block a user