Support attaching format information to selected color variables

This commit is contained in:
Andrzej Rybczak
2016-12-22 16:31:41 +01:00
parent 9c13827b62
commit a488c2d89d
22 changed files with 492 additions and 175 deletions

View File

@@ -487,14 +487,24 @@ template <typename T> void ShowTime(T &buf, size_t length, bool short_names)
buf << length << (short_names ? "s" : (length == 1 ? " second" : " seconds"));
}
template <typename BufferT> void ShowTag(BufferT &buf, const std::string &tag)
template <typename BufferT>
void ShowTag(BufferT &buf, const std::string &tag)
{
if (tag.empty())
buf << Config.empty_tags_color << Config.empty_tag << NC::Color::End;
buf << Config.empty_tags_color
<< Config.empty_tag
<< NC::FormattedColor::End(Config.empty_tags_color);
else
buf << tag;
}
inline NC::Buffer ShowTag(const std::string &tag)
{
NC::Buffer result;
ShowTag(result, tag);
return result;
}
inline const char *withErrors(bool success)
{
return success ? "" : " " "(with errors)";