Optionally colorful errors

This commit is contained in:
Robert Bendun 2022-05-29 23:29:37 +02:00
parent 96378a16c1
commit 3c4da4a226

45
src/pretty.cc Normal file
View File

@ -0,0 +1,45 @@
#include <musique.hh>
namespace starters
{
static std::string_view Error;
static std::string_view Path;
static std::string_view Comment;
static std::string_view End;
}
std::ostream& pretty::begin_error(std::ostream& os)
{
return os << starters::Error;
}
std::ostream& pretty::begin_path(std::ostream& os)
{
return os << starters::Path;
}
std::ostream& pretty::begin_comment(std::ostream& os)
{
return os << starters::Comment;
}
std::ostream& pretty::end(std::ostream& os)
{
return os << starters::End;
}
void pretty::terminal_mode()
{
starters::Error = "\x1b[31;1m";
starters::Path = "\x1b[34;1m";
starters::Comment = "\x1b[30;1m";
starters::End = "\x1b[0m";
}
void pretty::no_color_mode()
{
starters::Error = {};
starters::Path = {};
starters::Comment = {};
starters::End = {};
}