shared/pretty-print: print color sequence only when needed
Follow-up for 71cb203a6e
This commit is contained in:
@@ -465,7 +465,7 @@ int terminal_tint_color(double hue, char **ret) {
|
||||
|
||||
void draw_progress_bar(const char *prefix, double percentage) {
|
||||
|
||||
fputs("\r", stderr);
|
||||
fputc('\r', stderr);
|
||||
if (prefix)
|
||||
fputs(prefix, stderr);
|
||||
|
||||
@@ -474,12 +474,12 @@ void draw_progress_bar(const char *prefix, double percentage) {
|
||||
size_t prefix_length = strlen_ptr(prefix);
|
||||
size_t length = cols > prefix_length + 6 ? cols - prefix_length - 6 : 0;
|
||||
|
||||
fputs(ansi_highlight_green(), stderr);
|
||||
|
||||
if (length > 5 && percentage >= 0.0 && percentage <= 100.0) {
|
||||
size_t p = (size_t) (length * percentage / 100.0);
|
||||
bool separator_done = false;
|
||||
|
||||
fputs(ansi_highlight_green(), stderr);
|
||||
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
|
||||
if (i <= p) {
|
||||
|
||||
Reference in New Issue
Block a user