Refactored color output of headings.

This commit is contained in:
2016-06-14 17:11:45 +02:00
parent 583ec78eef
commit 1e21457efb
3 changed files with 66 additions and 40 deletions

View File

@@ -39,9 +39,6 @@ class TranslatorASP
void translateLiteral(const Expression &literal) const;
void translatePredicate(const expressions::Predicate &predicate) const;
void printHeading1(const std::string &heading) const;
void printHeading2(const std::string &heading) const;
const Description &m_description;
utils::LogStream &m_outputStream;
};

View File

@@ -81,9 +81,9 @@ inline LogStream &operator<<(LogStream &stream, const ResetFormat &)
////////////////////////////////////////////////////////////////////////////////////////////////////
struct Keyword
struct Token
{
Keyword(const std::string &name)
Token(const std::string &name)
: name(name)
{
}
@@ -93,6 +93,16 @@ struct Keyword
////////////////////////////////////////////////////////////////////////////////////////////////////
struct Keyword: public Token
{
Keyword(const std::string &name)
: Token(name)
{
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////
inline LogStream &operator<<(LogStream &stream, const Keyword &keyword)
{
return (stream
@@ -103,14 +113,12 @@ inline LogStream &operator<<(LogStream &stream, const Keyword &keyword)
////////////////////////////////////////////////////////////////////////////////////////////////////
struct Variable
struct Variable: public Token
{
Variable(const std::string &name)
: name(name)
: Token(name)
{
}
const std::string &name;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -123,6 +131,50 @@ inline LogStream &operator<<(LogStream &stream, const Variable &variable)
<< utils::ResetFormat());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
struct Heading1: public Token
{
Heading1(const std::string &name)
: Token(name)
{
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////
inline LogStream &operator<<(LogStream &stream, const Heading1 &heading1)
{
return (stream
<< utils::Format(utils::Color::Blue, utils::FontWeight::Bold)
<< "%---------------------------------------" << std::endl
<< "% " << heading1.name << std::endl
<< "%---------------------------------------"
<< utils::ResetFormat()
<< std::endl);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
struct Heading2: public Token
{
Heading2(const std::string &name)
: Token(name)
{
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////
inline LogStream &operator<<(LogStream &stream, const Heading2 &heading2)
{
return (stream
<< utils::Format(utils::Color::Blue, utils::FontWeight::Bold)
<< "% " << heading2.name
<< utils::ResetFormat());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}