]> git.ipfire.org Git - pakfire.git/commitdiff
progressbar: Remove bar when finished to not clutter the terminal
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 21 Apr 2021 15:24:15 +0000 (15:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 21 Apr 2021 15:24:15 +0000 (15:24 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/progressbar.c

index 6e55e6989d62f7635bec464d928adea66ac63405..bbb8c1bc91533b5658a3dbccae16b92f06ece1eb 100644 (file)
@@ -458,6 +458,15 @@ static const char* pakfire_progressbar_bar(struct pakfire_progressbar* p,
        if (width >= sizeof(widget->buffer) || width < 2)
                return NULL;
 
+       // Remove the bar when we are finished so that the terminal is not so cluttered
+       if (p->status == PAKFIRE_PROGRESSBAR_FINISHED) {
+               for (unsigned int i = 0; i < width; i++)
+                       widget->buffer[i] = ' ';
+               widget->buffer[width] = '\0';
+
+               return widget->buffer;
+       }
+
        unsigned int fill = 0;
 
        if (p->value_max)