Bit more color

This commit is contained in:
Marcus Holland-Moritz 2020-12-14 21:35:50 +01:00
parent 4da9055cfb
commit d48dcc0604
3 changed files with 11 additions and 1 deletions

View File

@ -50,4 +50,7 @@ bool stream_is_fancy_terminal(std::ostream& os);
char const* terminal_color(termcolor color);
std::string
terminal_colored(std::string text, termcolor color, bool enable = true);
} // namespace dwarfs

View File

@ -155,7 +155,8 @@ void console_writer::update(const progress& p, bool last) {
switch (mode_) {
case NORMAL:
if (fancy) {
oss << p.status(width_) << newline;
oss << terminal_colored(p.status(width_), termcolor::BOLD_CYAN, color_)
<< newline;
}
oss << p.dirs_scanned << " dirs, " << p.links_scanned << "/"

View File

@ -69,4 +69,10 @@ char const* terminal_color(termcolor color) {
return colors.at(static_cast<size_t>(color));
}
std::string terminal_colored(std::string text, termcolor color, bool enable) {
return enable
? terminal_color(color) + text + terminal_color(termcolor::NORMAL)
: text;
}
} // namespace dwarfs