add colours e.g. fmt::colour(fmt::red)

This commit is contained in:
Pepe 2014-02-15 23:42:09 +00:00
parent affa794794
commit 360e0f7602
2 changed files with 25 additions and 2 deletions

View File

@ -423,6 +423,9 @@ void fmt::BasicFormatter<Char>::DoFormat() {
next_arg_index_ = 0;
const Char *s = start;
BasicWriter<Char> &writer = *writer_;
// fmt::colour(fmt::Red);
while (*s) {
Char c = *s++;
if (c != '{' && c != '}') continue;
@ -727,3 +730,11 @@ template void fmt::BasicFormatter<wchar_t>::CheckSign(
const wchar_t *&s, const Arg &arg);
template void fmt::BasicFormatter<wchar_t>::DoFormat();
void fmt::colour(Colours col)
{
printf("\033[0;%dm",col);
}

View File

@ -910,6 +910,14 @@ void FormatCustomArg(
the output is sent to a :cpp:class:`fmt::Writer` object.
\endrst
*/
enum Colours{black=30,red,green,yellow,blue,Magenta,cyan,white};
void colour(Colours);
template <typename Char>
class BasicFormatter {
private:
@ -1359,8 +1367,12 @@ class Write {
inline Formatter<Write> Print(StringRef format) {
Formatter<Write> f(format);
return f;
}
}
}//end namespace internal (?)
}//end namespace format (?)
#ifdef FMT_GCC_DIAGNOSTIC
# pragma GCC diagnostic pop