diff options
author | Colin Walters <walters@verbum.org> | 2017-12-12 14:10:47 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2017-12-12 15:24:42 -0500 |
commit | bb7dd4dd085d0e1805a39478cac437d35313d22b (patch) | |
tree | c0a78d0d160f2a754350fe373de735e3270334ca | |
parent | a8f96bd5f7e5a0cec6e4c40774e0eea99d0bd0c8 (diff) | |
download | libglnx-bb7dd4dd085d0e1805a39478cac437d35313d22b.tar.gz |
console: Limit progress bar to 20 columns max
IMO, it looks bad to have a really big progress bar. I personally usually work
on a 27" monitor with maximized terminals.
-rw-r--r-- | glnx-console.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/glnx-console.c b/glnx-console.c index 3874765..8654c7b 100644 --- a/glnx-console.c +++ b/glnx-console.c @@ -29,6 +29,13 @@ #include <errno.h> #include <sys/ioctl.h> +/* For people with widescreen monitors and maximized terminals, it looks pretty + * bad to have an enormous progress bar. For much the same reason as web pages + * tend to have a maximum width; + * https://ux.stackexchange.com/questions/48982/suggest-good-max-width-for-fluid-width-design + */ +#define MAX_PROGRESSBAR_COLUMNS 20 + static char *current_text = NULL; static gint current_percent = -1; static gboolean locked; @@ -232,7 +239,7 @@ text_percent_internal (const char *text, else { const guint textlen = MIN (input_textlen, ncolumns - bar_min); - const guint barlen = ncolumns - (textlen + 1);; + const guint barlen = MIN (MAX_PROGRESSBAR_COLUMNS, ncolumns - (textlen + 1)); if (textlen > 0) { @@ -245,7 +252,7 @@ text_percent_internal (const char *text, 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; + const guint spacelen = bar_internal_len - eqlen; fputc ('[', stdout); printpad (equals, n_equals, eqlen); |