[libglnx] console: Limit progress bar to 20 columns max



commit bb7dd4dd085d0e1805a39478cac437d35313d22b
Author: Colin Walters <walters verbum org>
Date:   Tue Dec 12 14:10:47 2017 -0500

    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.

 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]