Skip to content
Snippets Groups Projects
Commit 40ef5f74 authored by Jonathan Lebon's avatar Jonathan Lebon
Browse files

text_percent_internal: only pad right in the text case

Padding in the percentage case was useless (and actually didn't work
properly) since all the real estate is taken up by the text and the bar.
We only need padding in the text case, in case the new string is
shorter.
parent 3d162e77
No related branches found
No related tags found
No related merge requests found
...@@ -221,20 +221,22 @@ text_percent_internal (const char *text, ...@@ -221,20 +221,22 @@ text_percent_internal (const char *text,
if (percentage == -1) if (percentage == -1)
{ {
const guint spacelen = ncolumns - input_textlen;
fwrite (text, 1, input_textlen, stdout); fwrite (text, 1, input_textlen, stdout);
printpad (spaces, n_spaces, spacelen);
} }
else else
{ {
const guint textlen = MIN (input_textlen, ncolumns - bar_min); const guint textlen = MIN (input_textlen, ncolumns - bar_min);
const guint barlen = ncolumns - (textlen + 1);; const guint barlen = ncolumns - (textlen + 1);;
if (textlen > 0) if (textlen > 0)
{ {
fwrite (text, 1, textlen, stdout); fwrite (text, 1, textlen, stdout);
fputc (' ', stdout); fputc (' ', stdout);
} }
{ {
const guint nbraces = 2; const guint nbraces = 2;
const guint textpercent_len = 5; const guint textpercent_len = 5;
const guint bar_internal_len = barlen - nbraces - textpercent_len; const guint bar_internal_len = barlen - nbraces - textpercent_len;
...@@ -247,10 +249,6 @@ text_percent_internal (const char *text, ...@@ -247,10 +249,6 @@ text_percent_internal (const char *text,
fputc (']', stdout); fputc (']', stdout);
fprintf (stdout, " %3d%%", percentage); fprintf (stdout, " %3d%%", percentage);
} }
{ const guint spacelen = ncolumns - textlen - barlen;
printpad (spaces, n_spaces, spacelen);
}
} }
fflush (stdout); fflush (stdout);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment