diff --git a/src/Color.cpp b/src/Color.cpp index e3b3f8a32..b16db5892 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -418,18 +418,35 @@ std::string Color::colorize (const std::string& input) // 256 color if (value & _COLOR_256) { + bool needTerminator = false; + if (value & _COLOR_UNDERLINE) + { result << "\033[4m"; + needTerminator = true; + } if (!(value & _COLOR_NOFG)) + { result << "\033[38;5;" << (value & _COLOR_FG) << "m"; + needTerminator = true; + } if (!(value & _COLOR_NOBG)) + { result << "\033[48;5;" << ((value & _COLOR_BG) >> 8) << "m"; + needTerminator = true; + } + + result << input; + if (needTerminator) + result << "\033[0m"; + + return result.str (); } // 16 color - else + if (value != (_COLOR_NOFG | _COLOR_NOBG)) { result << "\033["; @@ -457,11 +474,11 @@ std::string Color::colorize (const std::string& input) result << (29 + (value & _COLOR_FG)); } - result << "m"; + result << "m" << input << "\033[0m"; + return result.str (); } - result << input << "\033[0m"; - return result.str (); + return input; } ////////////////////////////////////////////////////////////////////////////////