diff --git a/include/internal/catch_console_colour_impl.hpp b/include/internal/catch_console_colour_impl.hpp index 1830e182..db9d9305 100644 --- a/include/internal/catch_console_colour_impl.hpp +++ b/include/internal/catch_console_colour_impl.hpp @@ -83,11 +83,48 @@ namespace Catch { #else +#include + namespace Catch { - TextColour::TextColour( Colours ){} - TextColour::~TextColour(){} - void TextColour::set( Colours ){} - + + TextColour::TextColour( Colours colour ) { + if( colour ) + set( colour ); + } + + TextColour::~TextColour() { + set( TextColour::None ); + } + + void TextColour::set( Colours colour ) { + if( isatty( fileno(stdout) ) ) + switch( colour ) { + case TextColour::FileName: + std::cout << "\e[1m"; // bold + break; + case TextColour::ResultError: + std::cout << "\e[1;31m"; // bright red + break; + case TextColour::ResultSuccess: + std::cout << "\e[1;32m"; // bright green + break; + case TextColour::Error: + std::cout << "\e[0;31m"; // dark red + break; + case TextColour::Success: + std::cout << "\e[0;32m"; // dark green + break; + case TextColour::OriginalExpression: + std::cout << "\e[0;36m"; // cyan + break; + case TextColour::ReconstructedExpression: + std::cout << "\e[0;33m"; // yellow + break; + default: + std::cout << "\e[0m"; // reset + } + } + } // end namespace Catch #endif