[libglnx] text_percent_internal: only pad right in the text case
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libglnx] text_percent_internal: only pad right in the text case
- Date: Tue, 10 May 2016 18:12:26 +0000 (UTC)
commit 40ef5f7400d4f8eed6a8f834917008b33ad4fb4e
Author: Jonathan Lebon <jlebon redhat com>
Date: Tue May 10 11:59:17 2016 -0400
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.
glnx-console.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/glnx-console.c b/glnx-console.c
index bbcfe73..d40702e 100644
--- a/glnx-console.c
+++ b/glnx-console.c
@@ -221,20 +221,22 @@ text_percent_internal (const char *text,
if (percentage == -1)
{
+ const guint spacelen = ncolumns - input_textlen;
fwrite (text, 1, input_textlen, stdout);
+ printpad (spaces, n_spaces, spacelen);
}
else
{
const guint textlen = MIN (input_textlen, ncolumns - bar_min);
const guint barlen = ncolumns - (textlen + 1);;
-
+
if (textlen > 0)
{
fwrite (text, 1, textlen, stdout);
fputc (' ', stdout);
}
-
- {
+
+ {
const guint nbraces = 2;
const guint textpercent_len = 5;
const guint bar_internal_len = barlen - nbraces - textpercent_len;
@@ -247,10 +249,6 @@ text_percent_internal (const char *text,
fputc (']', stdout);
fprintf (stdout, " %3d%%", percentage);
}
-
- { const guint spacelen = ncolumns - textlen - barlen;
- printpad (spaces, n_spaces, spacelen);
- }
}
fflush (stdout);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]