mirror of
https://github.com/flatpak/flatpak.git
synced 2026-03-28 03:45:10 -04:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user