summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2016-05-01 14:04:37 -0400
committerColin Walters <walters@verbum.org>2016-05-01 14:22:25 -0400
commit47ddbfa56341df3a9453854e1101e1c2f2359ddb (patch)
tree984e1fce8040986f440c660bd7a33ba567a57dd9
parent69d8a597f768f811f7c924a784af834f637eeb20 (diff)
downloadlibglnx-47ddbfa56341df3a9453854e1101e1c2f2359ddb.tar.gz
console: Fix glnx_console_text
Not sure if it ever worked. We need to not print the bars, etc.
-rw-r--r--glnx-console.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/glnx-console.c b/glnx-console.c
index 016f62c..bbcfe73 100644
--- a/glnx-console.c
+++ b/glnx-console.c
@@ -188,8 +188,6 @@ text_percent_internal (const char *text,
const guint ncolumns = glnx_console_columns ();
const guint bar_min = 10;
const guint input_textlen = text ? strlen (text) : 0;
- guint textlen;
- guint barlen;
if (text && !*text)
text = NULL;
@@ -221,32 +219,39 @@ text_percent_internal (const char *text,
(void) fwrite (beginbuf, 1, sizeof (beginbuf), stdout);
}
- textlen = MIN (input_textlen, ncolumns - bar_min);
- barlen = ncolumns - (textlen + 1);
-
- if (textlen > 0)
+ if (percentage == -1)
{
- fwrite (text, 1, textlen, stdout);
- fputc (' ', stdout);
+ fwrite (text, 1, input_textlen, stdout);
}
+ 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;
- const guint eqlen = bar_internal_len * (percentage / 100.0);
- const guint spacelen = bar_internal_len - eqlen;
-
- fputc ('[', stdout);
- printpad (equals, n_equals, eqlen);
- printpad (spaces, n_spaces, spacelen);
- fputc (']', stdout);
- fprintf (stdout, " %3d%%", percentage);
- }
+ {
+ const guint nbraces = 2;
+ const guint textpercent_len = 5;
+ const guint bar_internal_len = barlen - nbraces - textpercent_len;
+ const guint eqlen = bar_internal_len * (percentage / 100.0);
+ const guint spacelen = bar_internal_len - eqlen;
+
+ fputc ('[', stdout);
+ printpad (equals, n_equals, eqlen);
+ printpad (spaces, n_spaces, spacelen);
+ fputc (']', stdout);
+ fprintf (stdout, " %3d%%", percentage);
+ }
- { const guint spacelen = ncolumns - textlen - barlen;
- printpad (spaces, n_spaces, spacelen);
- }
+ { const guint spacelen = ncolumns - textlen - barlen;
+ printpad (spaces, n_spaces, spacelen);
+ }
+ }
fflush (stdout);
}