From 4c5076f263cebe4f6a7ba85e79f0ebdbefe8e823 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 13 Nov 2019 18:01:47 +0900 Subject: [PATCH] feat: add runtime colorize flag --- toml/region.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/toml/region.hpp b/toml/region.hpp index 73fc076..7a55cfb 100644 --- a/toml/region.hpp +++ b/toml/region.hpp @@ -419,7 +419,8 @@ struct region final : public region_base // to show a better error message. inline std::string format_underline(const std::string& message, const std::vector>& reg_com, - const std::vector& helps = {}) + const std::vector& helps = {}, + const bool colorize = TOML11_COLORED_MESSAGE_ACTIVATED) { assert(!reg_com.empty()); @@ -434,9 +435,10 @@ inline std::string format_underline(const std::string& message, std::ostringstream retval; -#ifdef TOML11_COLORIZE_ERROR_MESSAGE - retval << color::colorize; // turn on ANSI color -#endif + if(colorize) + { + retval << color::colorize; // turn on ANSI color + } retval << color::bold << color::red << "[error] " << color::reset << color::bold << message << color::reset << '\n';