From 3f42cffbede610ff7fa5b4501cf0611ea4a3e735 Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Fri, 4 Dec 2020 23:26:27 +0100 Subject: [PATCH 01/20] Graphs of absolute width WIP This first commit showcases some basic functionality. It currently only works in text mode and with color disabled. For this to work: - I added an agflag (*a*bsolute *g*raph) which is for now always set to 1 (enabled) - I changed the signature of the print_bar method and their implementations to consume three doubles: the used & total space on this volume as well as the total space on the greatest volume - I added an maxfssize variable alongside the max variable that stores the greatest volume's total space which is calculated whenever the latter is updated (see util.c) Every other impl other than the one in text is simply a stub for now. --- src/dfc.c | 5 +++-- src/export/csv.c | 12 ++++++++---- src/export/display.h | 2 +- src/export/html.c | 26 +++++++++++++++----------- src/export/json.c | 8 +++++--- src/export/tex.c | 11 ++++++++--- src/export/text.c | 40 +++++++++++++++++++++++++++++----------- src/extern.h | 3 ++- src/util.c | 14 ++++++++++++++ src/util.h | 1 + 10 files changed, 86 insertions(+), 36 deletions(-) diff --git a/src/dfc.c b/src/dfc.c index d35a949..d632ecc 100644 --- a/src/dfc.c +++ b/src/dfc.c @@ -52,8 +52,9 @@ char g_unknown_str[] = "unknown"; char g_none_str[] = "none"; struct conf cnf; struct maxwidths max; +double maxfssize = 0; int aflag, bflag, cflag, dflag, eflag, fflag, hflag, iflag, lflag, mflag, - nflag, oflag, pflag, qflag, sflag, tflag, uflag, vflag, wflag; + nflag, oflag, pflag, qflag, sflag, tflag, uflag, vflag, wflag, agflag = 1; int Mflag, Tflag, Wflag; char unitflag; @@ -583,7 +584,7 @@ disp(struct list *lst, const char *fstfilter, const char *fsnfilter, } if (!bflag) - sdisp->print_bar(p->perctused); + sdisp->print_bar(p->used, p->total, maxfssize); /* %used */ sdisp->print_perct(p->perctused); diff --git a/src/export/csv.c b/src/export/csv.c index 94b4a12..d8eb19a 100644 --- a/src/export/csv.c +++ b/src/export/csv.c @@ -52,7 +52,7 @@ static void csv_disp_header(void); static void csv_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); -static void csv_disp_bar(double perct); +static void csv_disp_bar(double used, double size, double gsize); static void csv_disp_uat(double n, double perct, int req_width); static void csv_disp_fs(const char *fsname); static void csv_disp_type(const char *type); @@ -163,12 +163,16 @@ csv_disp_sum(double stot, double atot, double utot, double ifitot, double ifatot * Should display the nice usage bar but this makes no sense in CSV export * Therefore, this is a dummy function that does nothing when called from * dfc.c but it is required in order to avoid stupid checks in dfc.c - * @perct: is ignored + * @used: is ignored + * @size: is ignored + * @gsize: is ignored */ static void -csv_disp_bar(double perct) +csv_disp_bar(double used, double size, double gsize) { - (void)perct; + (void)used; + (void)size; + (void)gsize; /* DUMMY */ } diff --git a/src/export/display.h b/src/export/display.h index 7b981a5..3575188 100644 --- a/src/export/display.h +++ b/src/export/display.h @@ -44,7 +44,7 @@ struct display void (*print_header) (void); void (*print_sum) (double, double, double, double, double); - void (*print_bar) (double); + void (*print_bar) (double, double, double); void (*print_used) (double, double, int); void (*print_avail) (double, double, int); void (*print_total) (double, double, int); diff --git a/src/export/html.c b/src/export/html.c index 746a111..c3b227a 100644 --- a/src/export/html.c +++ b/src/export/html.c @@ -54,7 +54,7 @@ static void html_disp_deinit(void); static void html_disp_header(void); static void html_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); -static void html_disp_bar(double perct); +static void html_disp_bar(double used, double size, double gsize); static void html_disp_uat(double n, double perct, int req_width); static void html_disp_fs(const char *fsname); static void html_disp_type(const char *type); @@ -207,7 +207,7 @@ html_disp_sum(double stot, double atot, double utot, (void)puts("\t N/A"); if (!bflag) - html_disp_bar(ptot); + html_disp_bar(utot, stot, stot); html_disp_perct(ptot); @@ -238,11 +238,15 @@ html_disp_sum(double stot, double atot, double utot, * @perct: percentage value */ static void -html_disp_bar(double perct) +html_disp_bar(double used, double size, double gsize) { int barwidth = 100; /* In pixels */ int barheight = 25; /* In pixels */ - int size; + int barsize; + int perct = 0; // TODO + (void)used; + (void)size; + (void)gsize; (void)puts("\t "); @@ -254,24 +258,24 @@ html_disp_bar(double perct) "background-color:silver; float: left;\">\n", (int)perct*barwidth/100, barheight); } else { /* color */ - size = (perct < cnf.gmedium) ? (int)perct : cnf.gmedium; + barsize = (perct < cnf.gmedium) ? (int)perct : cnf.gmedium; (void)printf("\t \n", - size * barwidth / 100, barheight, cnf.hclow); + barsize * barwidth / 100, barheight, cnf.hclow); if (perct >= cnf.gmedium) { - size = (perct < cnf.ghigh) ? (int)perct : cnf.ghigh; - size -= cnf.gmedium; + barsize = (perct < cnf.ghigh) ? (int)perct : cnf.ghigh; + barsize -= cnf.gmedium; (void)printf("\t \n", - size * barwidth / 100, barheight, cnf.hcmedium); + barsize * barwidth / 100, barheight, cnf.hcmedium); } if (perct >= cnf.ghigh) { - size = (int)perct - cnf.ghigh; + barsize = (int)perct - cnf.ghigh; (void)printf("\t \n", - size * barwidth / 100, barheight, cnf.hchigh); + barsize * barwidth / 100, barheight, cnf.hchigh); } } (void)puts("\t "); diff --git a/src/export/json.c b/src/export/json.c index 9c460a6..66ac6b9 100644 --- a/src/export/json.c +++ b/src/export/json.c @@ -57,7 +57,7 @@ static void json_disp_deinit(void); static void json_disp_header(void); static void json_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); -static void json_disp_bar(double perct); +static void json_disp_bar(double used, double size, double gsize); static void json_disp_uat(double n, const char *key); static void json_disp_used(double used, double perct, int req_width); static void json_disp_avail(double avail, double perct, int req_width); @@ -145,9 +145,11 @@ json_disp_sum(double stot, double atot, double utot, double ifitot, double ifato } static void -json_disp_bar(double perct) +json_disp_bar(double used, double size, double gsize) { - (void)perct; + (void)used; + (void)size; + (void)gsize; /* DUMMY */ } diff --git a/src/export/tex.c b/src/export/tex.c index 438e29a..18481b8 100644 --- a/src/export/tex.c +++ b/src/export/tex.c @@ -54,7 +54,7 @@ static void tex_disp_deinit(void); static void tex_disp_header(void); static void tex_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); -static void tex_disp_bar(double perct); +static void tex_disp_bar(double used, double size, double gsize); static void tex_disp_uat(double n, double perct, int req_width); static void tex_disp_fs(const char *fsname); static void tex_disp_type(const char *type); @@ -185,7 +185,7 @@ tex_disp_sum(double stot, double atot, double utot, (void)printf(" & N/A"); if (!bflag) - tex_disp_bar(ptot); + tex_disp_bar(utot, stot, stot); tex_disp_perct(ptot); @@ -216,7 +216,7 @@ tex_disp_sum(double stot, double atot, double utot, * @perct: percentage value */ static void -tex_disp_bar(double perct) +tex_disp_bar(double used, double size, double gsize) { /* * It could be nice to have a non-ASCII graph bar but it requires TeX @@ -226,6 +226,11 @@ tex_disp_bar(double perct) int i, j; int barinc = 5; + int perct = 0; // TODO + (void)used; + (void)size; + (void)gsize; + (void)printf(" & "); /* option to display a wider bar */ diff --git a/src/export/text.c b/src/export/text.c index 2c33321..d779e5a 100644 --- a/src/export/text.c +++ b/src/export/text.c @@ -52,7 +52,7 @@ static void text_disp_header(void); static void text_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); -static void text_disp_bar(double perct); +static void text_disp_bar(double used, double size, double max); static void text_disp_uat(double n, double perct, int req_width); static void text_disp_fs(const char *fsname); static void text_disp_type(const char *type); @@ -167,7 +167,7 @@ text_disp_sum(double stot, double atot, double utot, reset_color(); if (!bflag) - text_disp_bar(ptot); + text_disp_bar(utot, stot, stot); text_disp_perct(ptot); @@ -191,12 +191,24 @@ text_disp_sum(double stot, double atot, double utot, /* * Display the nice usage bar - * @perct: percentage value + * @used: how much space is used on this volume + * @size: how much total space this volume has + * @gsize: how much total space the greatest volume has */ static void -text_disp_bar(double perct) +text_disp_bar(double used, double size, double gsize) { - int i, j; + int i; + double uperct, sperct; + if (agflag) { + // used percentage + uperct = used / gsize * 100; + // total percentage of the greatest volume + sperct = size / gsize * 100; + } else { + uperct = used / size * 100; + sperct = 100; + } int barinc = 5; /* option to display a wider bar */ @@ -208,31 +220,37 @@ text_disp_bar(double perct) (void)printf("["); if (!cflag) { - for (i = 0; i < perct; i += barinc) + for (i = 0; i < uperct; i += barinc) (void)printf("%c", cnf.gsymbol); - for (j = i; j < 100; j += barinc) + for (; i < sperct; i += barinc) (void)printf("-"); + + for (; i < 100; i += barinc) + (void)printf(" "); } else { /* color */ /* green */ (void)printf("\033[%d;%dm", cnf.font_type , cnf.clow); - for (i = 0; (i < cnf.gmedium) && (i < perct); i += barinc) + for (i = 0; (i < cnf.gmedium) && (i < uperct); i += barinc) (void)printf("%c", cnf.gsymbol); /* yellow */ (void)printf("\033[%d;%dm", cnf.font_type , cnf.cmedium); - for (; (i < cnf.ghigh) && (i < perct); i += barinc) + for (; (i < cnf.ghigh) && (i < uperct); i += barinc) (void)printf("%c", cnf.gsymbol); /* red */ (void)printf("\033[%d;%dm", cnf.font_type , cnf.chigh); - for (; (i < 100) && (i < perct); i += barinc) + for (; (i < sperct) && (i < uperct); i += barinc) (void)printf("%c", cnf.gsymbol); reset_color(); - for (j = i; j < 100; j += barinc) + for (; i < sperct; i += barinc) + (void)printf("-"); + + for (; i < 100; i += barinc) (void)printf("-"); } diff --git a/src/extern.h b/src/extern.h index 210a0a5..84224aa 100644 --- a/src/extern.h +++ b/src/extern.h @@ -125,10 +125,11 @@ extern struct conf cnf; /* struct to store maximum required widths (useful only in text export mode) */ extern struct maxwidths max; +extern double maxfssize; /* set flags for options */ extern int aflag, bflag, cflag, dflag, eflag, fflag, hflag, iflag, lflag, mflag, - nflag, oflag, pflag, qflag, sflag, tflag, uflag, vflag, wflag; + nflag, oflag, pflag, qflag, sflag, tflag, uflag, vflag, wflag, agflag; extern int Mflag, Tflag, Wflag; /* flag that determines which unit is in use (Ko, Mo, etc.) */ diff --git a/src/util.c b/src/util.c index 2d889f2..033438c 100644 --- a/src/util.c +++ b/src/util.c @@ -85,6 +85,17 @@ imax(int a, int b) return (a > b ? a : b); } +/* + * Return the larger of the two floating-point numbers + * @a: first element to compare + * @b: second element to compare + */ +double +dmax(double a, double b) +{ + return (a > b ? a : b); +} + /* * trim withespaces from the input string and returns it * @str: string that needs to be trimmed @@ -518,6 +529,7 @@ init_maxwidths(void) max.avinodes = iflag ? (int)strlen(_("AV.INODES")) + 1 : 0; max.mntdir = Mflag ? 0 : (int)strlen(_("MOUNTED ON")) + 1; max.mntopts = oflag ? (int)strlen(_("MOUNT OPTIONS")) + 1: 0; + maxfssize = 0; } /* @@ -599,6 +611,8 @@ update_maxwidth(struct fsmntinfo *fmi) max.nbinodes = imax(2 + count_digit(fmi->files), max.nbinodes); max.avinodes = imax(3 + count_digit(fmi->ffree), max.avinodes); } + + maxfssize = dmax(fmi->total, maxfssize); } /* diff --git a/src/util.h b/src/util.h index c6f1130..690787b 100644 --- a/src/util.h +++ b/src/util.h @@ -44,6 +44,7 @@ /* function declaration */ int imax(int a, int b); +double dmax(double a, double b); char * strtrim(char *str); char * shortenstr(char *str, int len); char * sanitizestr(const char *str); From bd3d617bd631e571fbe99087c1b10c9b77d7fb03 Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Fri, 4 Dec 2020 23:46:46 +0100 Subject: [PATCH 02/20] now also working with colors + fixed messed up widths --- src/export/text.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/export/text.c b/src/export/text.c index d779e5a..20b4cae 100644 --- a/src/export/text.c +++ b/src/export/text.c @@ -199,14 +199,14 @@ static void text_disp_bar(double used, double size, double gsize) { int i; - double uperct, sperct; + int uperct, sperct; if (agflag) { - // used percentage - uperct = used / gsize * 100; - // total percentage of the greatest volume - sperct = size / gsize * 100; + // used percentage on the current volume: + uperct = (int)(used * 100 / gsize); + // percentage of the current volume size on the greatest volume size: + sperct = (int)(size * 100 / gsize); } else { - uperct = used / size * 100; + uperct = (int)(used * 100 / size); sperct = 100; } int barinc = 5; @@ -251,7 +251,7 @@ text_disp_bar(double used, double size, double gsize) (void)printf("-"); for (; i < 100; i += barinc) - (void)printf("-"); + (void)printf(" "); } (void)printf("]"); From 5d603266967aaf0f15abf34aab8c114f43e055dc Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Fri, 4 Dec 2020 23:55:35 +0100 Subject: [PATCH 03/20] added an option to toggle the absolute graph view I decided to go with -A, it is off by default (default behaviour is the same as before) I also added documentation in the english man page and help text, translated versions still need to add documentation for this as I speak neither french nor dutch :) --- man/dfc.1 | 3 +++ src/dfc.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/man/dfc.1 b/man/dfc.1 index 340b1b6..615dab8 100644 --- a/man/dfc.1 +++ b/man/dfc.1 @@ -24,6 +24,9 @@ terminal width. If you want to override this behavior, use the "\-f" option. \-a Show all (do not omit any file system). .TP +\-A +The full graph width is proportional to the file system size. +.TP \-b Do not show the graph bar. .TP diff --git a/src/dfc.c b/src/dfc.c index d632ecc..bdb382b 100644 --- a/src/dfc.c +++ b/src/dfc.c @@ -54,7 +54,7 @@ struct conf cnf; struct maxwidths max; double maxfssize = 0; int aflag, bflag, cflag, dflag, eflag, fflag, hflag, iflag, lflag, mflag, - nflag, oflag, pflag, qflag, sflag, tflag, uflag, vflag, wflag, agflag = 1; + nflag, oflag, pflag, qflag, sflag, tflag, uflag, vflag, wflag, agflag; int Mflag, Tflag, Wflag; char unitflag; @@ -188,11 +188,14 @@ main(int argc, char *argv[]) /* Init default colors and symbol sign */ init_conf(&cnf); - while ((ch = getopt(argc, argv, "abc:de:fhilmMnop:q:st:Tu:vwW")) != -1) { + while ((ch = getopt(argc, argv, "aAbc:de:fhilmMnop:q:st:Tu:vwW")) != -1) { switch (ch) { case 'a': aflag = 1; break; + case 'A': + agflag = 1; + break; case 'b': bflag = 1; break; @@ -451,6 +454,7 @@ usage(int status) "[-u UNIT]\n" "Available options:\n" "\t-a\tprint all mounted filesystem\n" + "\t-A\tprint graphs of absolute width\n" "\t-b\tdo not show the graph bar\n" "\t-c\tchoose color mode. Read the manpage for " "details\n" From 5363a6d8e691ec7eac1b65e3b0230b91e2133483 Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 08:41:34 +0100 Subject: [PATCH 04/20] fix for the off percentages --- src/dfc.c | 2 +- src/export/text.c | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/dfc.c b/src/dfc.c index bdb382b..8b9e33c 100644 --- a/src/dfc.c +++ b/src/dfc.c @@ -588,7 +588,7 @@ disp(struct list *lst, const char *fstfilter, const char *fsnfilter, } if (!bflag) - sdisp->print_bar(p->used, p->total, maxfssize); + sdisp->print_bar(p->perctused, p->total, maxfssize); /* %used */ sdisp->print_perct(p->perctused); diff --git a/src/export/text.c b/src/export/text.c index 20b4cae..cd8e5ad 100644 --- a/src/export/text.c +++ b/src/export/text.c @@ -52,7 +52,7 @@ static void text_disp_header(void); static void text_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); -static void text_disp_bar(double used, double size, double max); +static void text_disp_bar(double perct, double size, double max); static void text_disp_uat(double n, double perct, int req_width); static void text_disp_fs(const char *fsname); static void text_disp_type(const char *type); @@ -191,23 +191,26 @@ text_disp_sum(double stot, double atot, double utot, /* * Display the nice usage bar - * @used: how much space is used on this volume + * @perct: usage percentage * @size: how much total space this volume has * @gsize: how much total space the greatest volume has */ static void -text_disp_bar(double used, double size, double gsize) +text_disp_bar(double perct, double size, double gsize) { int i; - int uperct, sperct; + double sperct, uperct; if (agflag) { - // used percentage on the current volume: - uperct = (int)(used * 100 / gsize); // percentage of the current volume size on the greatest volume size: - sperct = (int)(size * 100 / gsize); + sperct = size * 100 / gsize; + // used percentage on the current volume: + uperct = perct * size / gsize; + // one problem is that fs's with exactly 0.0 % usage are shown + // as empty (-) but fs's with something in between 0.0 % and 0.04 % + // are shown as full (=) because of the i < uperct check. } else { - uperct = (int)(used * 100 / size); sperct = 100; + uperct = perct; } int barinc = 5; From 8a8986d672a34034c6f425bee98f687511e06578 Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 08:56:52 +0100 Subject: [PATCH 05/20] cleanup --- src/export/text.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/export/text.c b/src/export/text.c index cd8e5ad..9536190 100644 --- a/src/export/text.c +++ b/src/export/text.c @@ -199,18 +199,18 @@ static void text_disp_bar(double perct, double size, double gsize) { int i; - double sperct, uperct; + double uperct, sperct; if (agflag) { - // percentage of the current volume size on the greatest volume size: - sperct = size * 100 / gsize; // used percentage on the current volume: uperct = perct * size / gsize; + // percentage of the current volume size on the greatest volume size: + sperct = size * 100 / gsize; // one problem is that fs's with exactly 0.0 % usage are shown // as empty (-) but fs's with something in between 0.0 % and 0.04 % // are shown as full (=) because of the i < uperct check. } else { - sperct = 100; uperct = perct; + sperct = 100; } int barinc = 5; From 0c63eaa87bf1e3d67806ff5ffcf2f98840f4995a Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 08:57:13 +0100 Subject: [PATCH 06/20] adding absolute graphs to the tex export --- src/export/tex.c | 49 ++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/src/export/tex.c b/src/export/tex.c index 18481b8..0b259e1 100644 --- a/src/export/tex.c +++ b/src/export/tex.c @@ -54,7 +54,7 @@ static void tex_disp_deinit(void); static void tex_disp_header(void); static void tex_disp_sum(double stot, double utot, double ftot, double ifitot, double ifatot); -static void tex_disp_bar(double used, double size, double gsize); +static void tex_disp_bar(double perct, double size, double gsize); static void tex_disp_uat(double n, double perct, int req_width); static void tex_disp_fs(const char *fsname); static void tex_disp_type(const char *type); @@ -213,57 +213,70 @@ tex_disp_sum(double stot, double atot, double utot, /* * Display the nice usage bar - * @perct: percentage value + * @perct: usage percentage + * @size: how much total space this volume has + * @gsize: how much total space the greatest volume has */ static void -tex_disp_bar(double used, double size, double gsize) +tex_disp_bar(double perct, double size, double gsize) { /* * It could be nice to have a non-ASCII graph bar but it requires TeX * packages usually using postscript and so on. So stick with ASCII for * now until someone shows up with a better idea. */ - int i, j; + int i; + double uperct, sperct; + if (agflag) { + // used percentage on the current volume: + uperct = perct * size / gsize; + // percentage of the current volume size on the greatest volume size: + sperct = size * 100 / gsize; + } else { + uperct = perct; + sperct = 100; + } int barinc = 5; - int perct = 0; // TODO - (void)used; - (void)size; - (void)gsize; - - (void)printf(" & "); - /* option to display a wider bar */ if (wflag) { barinc = 2; } + (void)printf(" & "); + if (!cflag) { - for (i = 0; i < perct; i += barinc) + for (i = 0; i < uperct; i += barinc) (void)printf("%c", cnf.gsymbol); - for (j = i; j < 100; j += barinc) + for (; i < sperct; i += barinc) (void)printf("\\-"); + + for (; i < 100; i += barinc) + (void)printf(" "); } else { /* color */ /* green */ (void)printf("\\textcolor{%s}{", colortostr(cnf.clow)); - for (i = 0; (i < cnf.gmedium) && (i < perct); i += barinc) + for (i = 0; (i < cnf.gmedium) && (i < uperct); i += barinc) (void)printf("%c", cnf.gsymbol); /* yellow */ (void)printf("}\\textcolor{%s}{", colortostr(cnf.cmedium)); - for (; (i < cnf.ghigh) && (i < perct); i += barinc) + for (; (i < cnf.ghigh) && (i < uperct); i += barinc) (void)printf("%c", cnf.gsymbol); /* red */ (void)printf("}\\textcolor{%s}{", colortostr(cnf.chigh)); - for (; (i < 100) && (i < perct); i += barinc) + for (; (i < sperct) && (i < uperct); i += barinc) (void)printf("%c", cnf.gsymbol); (void)printf("}"); - for (j = i; j < 100; j += barinc) - (void)printf("\\-"); + for (; i < sperct; i += barinc) + (void)printf("\\- "); + + for (; i < 100; i += barinc) + (void)printf(" "); } } From 0fefe157cbe9d1b360533de197814bf29b7b79e9 Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 09:02:24 +0100 Subject: [PATCH 07/20] adding absolute graphs to the html export --- src/export/html.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/export/html.c b/src/export/html.c index c3b227a..2485fd2 100644 --- a/src/export/html.c +++ b/src/export/html.c @@ -236,17 +236,19 @@ html_disp_sum(double stot, double atot, double utot, /* * Display the nice usage bar * @perct: percentage value + * @size: how much total space this volume has + * @gsize: how much total space the greatest volume has */ static void -html_disp_bar(double used, double size, double gsize) +html_disp_bar(double perct, double size, double gsize) { int barwidth = 100; /* In pixels */ int barheight = 25; /* In pixels */ int barsize; - int perct = 0; // TODO - (void)used; - (void)size; - (void)gsize; + + if (agflag) { + perct = perct * size / gsize; + } (void)puts("\t "); From b1f5f183c0919b5c285096007b4ca71c54d02c6e Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 09:03:33 +0100 Subject: [PATCH 08/20] a bit more cleanup --- src/export/html.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/export/html.c b/src/export/html.c index 2485fd2..ec75f42 100644 --- a/src/export/html.c +++ b/src/export/html.c @@ -258,7 +258,7 @@ html_disp_bar(double perct, double size, double gsize) if (!cflag) { (void)printf("\t \n", - (int)perct*barwidth/100, barheight); + (int)perct * barwidth / 100, barheight); } else { /* color */ barsize = (perct < cnf.gmedium) ? (int)perct : cnf.gmedium; (void)printf("\t \n", - barsize * barwidth / 100, barheight, cnf.hcmedium); + barsize * barwidth / 100, barheight, cnf.hcmedium); } if (perct >= cnf.ghigh) { barsize = (int)perct - cnf.ghigh; (void)printf("\t \n", - barsize * barwidth / 100, barheight, cnf.hchigh); + barsize * barwidth / 100, barheight, cnf.hchigh); } } (void)puts("\t "); From 304a99cfad9de7a4605acd4d6f9ddff8f99c28e9 Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 09:12:35 +0100 Subject: [PATCH 09/20] absolute summary graph in text mode --- src/export/text.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/export/text.c b/src/export/text.c index 9536190..5626c31 100644 --- a/src/export/text.c +++ b/src/export/text.c @@ -166,8 +166,12 @@ text_disp_sum(double stot, double atot, double utot, (void)printf("%-*s", width, _("SUM:")); reset_color(); - if (!bflag) - text_disp_bar(utot, stot, stot); + if (!bflag) { + text_disp_bar(ptot, stot, maxfssize); + if (agflag) { + (void)printf("\n%*c", 39, ' '); + } + } text_disp_perct(ptot); From 79ca9f38d319123f21df97142f4924722104204b Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 09:14:53 +0100 Subject: [PATCH 10/20] added summary graph for html export --- src/export/html.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/export/html.c b/src/export/html.c index ec75f42..76b62cf 100644 --- a/src/export/html.c +++ b/src/export/html.c @@ -207,7 +207,7 @@ html_disp_sum(double stot, double atot, double utot, (void)puts("\t N/A"); if (!bflag) - html_disp_bar(utot, stot, stot); + html_disp_bar(ptot, stot, maxfssize); html_disp_perct(ptot); From a1ef87779efdb71593b57fdac9dfb327ab03248f Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 09:17:26 +0100 Subject: [PATCH 11/20] added absolute summary graph to tex output --- src/export/tex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/export/tex.c b/src/export/tex.c index 0b259e1..af7d579 100644 --- a/src/export/tex.c +++ b/src/export/tex.c @@ -185,7 +185,7 @@ tex_disp_sum(double stot, double atot, double utot, (void)printf(" & N/A"); if (!bflag) - tex_disp_bar(utot, stot, stot); + tex_disp_bar(ptot, stot, maxfssize); tex_disp_perct(ptot); From 1826f76d30d13c4cb944eeebe72a3fa4d685c741 Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 09:22:59 +0100 Subject: [PATCH 12/20] removed hardcoded increments in favor of configurable bar width --- src/export/tex.c | 6 +----- src/export/text.c | 7 +------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/export/tex.c b/src/export/tex.c index af7d579..b17ced6 100644 --- a/src/export/tex.c +++ b/src/export/tex.c @@ -236,12 +236,8 @@ tex_disp_bar(double perct, double size, double gsize) uperct = perct; sperct = 100; } - int barinc = 5; - /* option to display a wider bar */ - if (wflag) { - barinc = 2; - } + int barinc = 100 / ((wflag ? GRAPHBAR_WIDE : GRAPHBAR_SHORT) - 2); (void)printf(" & "); diff --git a/src/export/text.c b/src/export/text.c index 5626c31..d93c9f1 100644 --- a/src/export/text.c +++ b/src/export/text.c @@ -216,12 +216,7 @@ text_disp_bar(double perct, double size, double gsize) uperct = perct; sperct = 100; } - int barinc = 5; - - /* option to display a wider bar */ - if (wflag) { - barinc = 2; - } + int barinc = 100 / ((wflag ? GRAPHBAR_WIDE : GRAPHBAR_SHORT) - 2); /* used (*) */ (void)printf("["); From 9e497acb3483de6664dfca4f762ffd61369d67ef Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 09:45:33 +0100 Subject: [PATCH 13/20] improved the summary bar. in absolute graph mode, it is wider than the other bars, so I needed support for flexible graph / bar width. before this commit, the color steps in the absolute summary graph would be on the same level as the ones above but not at the correct percentages, think something like this: sda1 ggggggyyyyrr-- sda2 ggggggy------- sda3 ggggggyy------ sum: ggggggyyyyrrrrrrrrrrrrrrrrr--------------- but it should look like this: ggggggggggggggggggyyyyyyyrr--------------- This issue is fixed in this commit. --- src/export/html.c | 28 ++++++++++++++++++++++------ src/export/tex.c | 4 ++-- src/export/text.c | 4 ++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/export/html.c b/src/export/html.c index 76b62cf..b196a2a 100644 --- a/src/export/html.c +++ b/src/export/html.c @@ -246,7 +246,9 @@ html_disp_bar(double perct, double size, double gsize) int barheight = 25; /* In pixels */ int barsize; + double sperct = 100; if (agflag) { + sperct = size / gsize * 100; perct = perct * size / gsize; } @@ -260,21 +262,35 @@ html_disp_bar(double perct, double size, double gsize) "background-color:silver; float: left;\">\n", (int)perct * barwidth / 100, barheight); } else { /* color */ - barsize = (perct < cnf.gmedium) ? (int)perct : cnf.gmedium; + // draw to either the next color or the full bar + // scaling each colors' width according to the bar width: + if (perct < cnf.gmedium * sperct / 100) { + barsize = (int)perct; + } else { + barsize = (int)(cnf.gmedium * sperct / 100); + } (void)printf("\t \n", barsize * barwidth / 100, barheight, cnf.hclow); - if (perct >= cnf.gmedium) { - barsize = (perct < cnf.ghigh) ? (int)perct : cnf.ghigh; - barsize -= cnf.gmedium; + if (perct >= cnf.gmedium * sperct / 100) { + // if there is something left after the low color, draw + // to the next color or the rest of the full bar + // scaling the colors according to the bar width: + if (perct < cnf.ghigh * sperct / 100) { + barsize = (int)perct; + } else { + barsize = (int)(cnf.ghigh * sperct / 100); + } + barsize -= (int)(cnf.gmedium * sperct / 100); (void)printf("\t \n", barsize * barwidth / 100, barheight, cnf.hcmedium); } - if (perct >= cnf.ghigh) { - barsize = (int)perct - cnf.ghigh; + // if there is something left after the medium color, draw it: + if (perct >= cnf.ghigh * sperct / 100) { + barsize = (int)(perct - cnf.ghigh * sperct / 100); (void)printf("\t \n", barsize * barwidth / 100, barheight, cnf.hchigh); diff --git a/src/export/tex.c b/src/export/tex.c index b17ced6..e88636c 100644 --- a/src/export/tex.c +++ b/src/export/tex.c @@ -253,12 +253,12 @@ tex_disp_bar(double perct, double size, double gsize) } else { /* color */ /* green */ (void)printf("\\textcolor{%s}{", colortostr(cnf.clow)); - for (i = 0; (i < cnf.gmedium) && (i < uperct); i += barinc) + for (i = 0; (i < cnf.gmedium * sperct / 100) && (i < uperct); i += barinc) (void)printf("%c", cnf.gsymbol); /* yellow */ (void)printf("}\\textcolor{%s}{", colortostr(cnf.cmedium)); - for (; (i < cnf.ghigh) && (i < uperct); i += barinc) + for (; (i < cnf.ghigh * sperct / 100) && (i < uperct); i += barinc) (void)printf("%c", cnf.gsymbol); /* red */ diff --git a/src/export/text.c b/src/export/text.c index d93c9f1..6a04c7d 100644 --- a/src/export/text.c +++ b/src/export/text.c @@ -234,12 +234,12 @@ text_disp_bar(double perct, double size, double gsize) /* green */ (void)printf("\033[%d;%dm", cnf.font_type , cnf.clow); - for (i = 0; (i < cnf.gmedium) && (i < uperct); i += barinc) + for (i = 0; (i < cnf.gmedium * sperct / 100) && (i < uperct); i += barinc) (void)printf("%c", cnf.gsymbol); /* yellow */ (void)printf("\033[%d;%dm", cnf.font_type , cnf.cmedium); - for (; (i < cnf.ghigh) && (i < uperct); i += barinc) + for (; (i < cnf.ghigh * sperct / 100) && (i < uperct); i += barinc) (void)printf("%c", cnf.gsymbol); /* red */ From d17a5df6761c1796971fce5f4659edb5f3339dc5 Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 09:50:40 +0100 Subject: [PATCH 14/20] new po files --- po/fr.po | 57 +++++++++++++++++++++++++++++--------------------------- po/nl.po | 52 ++++++++++++++++++++++++++------------------------- 2 files changed, 57 insertions(+), 52 deletions(-) diff --git a/po/fr.po b/po/fr.po index 1faabb9..57fb5f4 100644 --- a/po/fr.po +++ b/po/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: dfc 3.1.1\n" "Report-Msgid-Bugs-To: robin.hahling@gw-computing.net\n" -"POT-Creation-Date: 2017-09-11 13:26+0200\n" +"POT-Creation-Date: 2020-12-05 09:49+0100\n" "PO-Revision-Date: 2012-04-15 13:52+0200\n" "Last-Translator: Robin Hahling \n" "Language-Team: French\n" @@ -17,41 +17,43 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: src/dfc.c:214 +#: src/dfc.c:218 #, c-format msgid "-c: illegal sub option %s\n" msgstr "-c: sous-option illégale %s\n" -#: src/dfc.c:251 +#: src/dfc.c:255 #, c-format msgid "-e: illegal sub option %s\n" msgstr "-e: sous-option illégale %s\n" -#: src/dfc.c:302 +#: src/dfc.c:306 #, c-format msgid "-q: illegal sub option %s\n" msgstr "-q: sous-option illégale %s\n" -#: src/dfc.c:363 +#: src/dfc.c:367 #, c-format msgid "-u: illegal sub option %s\n" msgstr "-u: sous-option illégale %s\n" -#: src/dfc.c:406 +#: src/dfc.c:410 #, c-format msgid "Error reading the configuration file: %s\n" msgstr "Erreur pendant la lecture du fichier de configuration: %s\n" -#: src/dfc.c:445 +#: src/dfc.c:449 msgid "Try dfc -h for more information\n" msgstr "Essayez dfc -h pour plus d'informations\n" -#: src/dfc.c:448 +#: src/dfc.c:452 +#, fuzzy msgid "" "Usage: dfc [OPTION(S)] [-c WHEN] [-e FORMAT] [-p FSNAME] [-q SORTBY] [-t " "FSTYPE] [-u UNIT]\n" "Available options:\n" "\t-a\tprint all mounted filesystem\n" +"\t-A\tprint graphs of absolute width\n" "\t-b\tdo not show the graph bar\n" "\t-c\tchoose color mode. Read the manpage for details\n" "\t-d\tshow used size\n" @@ -76,7 +78,7 @@ msgstr "" "\t-l\taffiche les informations sur les systèmes de fichiers montés " "localement uniquement\n" -#: src/dfc.c:466 +#: src/dfc.c:471 msgid "" "\t-m\tuse metric (SI unit)\n" "\t-M\tdo not print \"mounted on\"\n" @@ -115,8 +117,9 @@ msgstr "" msgid "" "Config file path is longer than %lu and was truncated. Please, open a bug " "report.\n" -msgstr "Le chemin vers le fichier de configuration est plus long que %lu et a " -"été tronqué. Veuillez svp ouvrir un rapport de bogue.\n" +msgstr "" +"Le chemin vers le fichier de configuration est plus long que %lu et a été " +"tronqué. Veuillez svp ouvrir un rapport de bogue.\n" #: src/dotfile.c:159 #, c-format @@ -187,61 +190,61 @@ msgstr "Couleur HTML invalide pour '%s': %s\n" msgid "Cannot assign value for '%s': %s\n" msgstr "Impossible d'assigner une valeur pour '%s': %s\n" -#: src/util.c:510 src/export/html.c:157 src/export/tex.c:140 +#: src/util.c:521 src/export/html.c:157 src/export/tex.c:140 #: src/export/text.c:101 msgid "FILESYSTEM" msgstr "SYSTÈME DE FICHIERS" -#: src/util.c:511 src/export/html.c:160 src/export/tex.c:142 +#: src/util.c:522 src/export/html.c:160 src/export/tex.c:142 #: src/export/text.c:104 msgid "TYPE" msgstr "TYPE" -#: src/util.c:513 src/export/html.c:164 src/export/text.c:114 +#: src/util.c:524 src/export/html.c:164 src/export/text.c:114 msgid "%USED" msgstr "%UTILISÉ" -#: src/util.c:514 src/export/html.c:166 src/export/tex.c:147 +#: src/util.c:525 src/export/html.c:166 src/export/tex.c:147 #: src/export/text.c:117 msgid "USED" msgstr " UT." -#: src/util.c:515 src/export/html.c:167 src/export/tex.c:148 +#: src/util.c:526 src/export/html.c:167 src/export/tex.c:148 #: src/export/text.c:119 msgid "AVAILABLE" msgstr "DISPO." -#: src/util.c:516 src/export/csv.c:104 src/export/html.c:168 +#: src/util.c:527 src/export/csv.c:104 src/export/html.c:168 #: src/export/tex.c:149 src/export/text.c:120 #, c-format msgid "TOTAL" msgstr "TOTAL" -#: src/util.c:517 src/export/html.c:171 src/export/text.c:123 +#: src/util.c:528 src/export/html.c:171 src/export/text.c:123 msgid "#INODES" msgstr "#INODES" -#: src/util.c:518 src/export/csv.c:108 src/export/html.c:172 +#: src/util.c:529 src/export/csv.c:108 src/export/html.c:172 #: src/export/text.c:124 #, c-format msgid "AV.INODES" msgstr "INODES DISP." -#: src/util.c:519 src/export/csv.c:112 src/export/html.c:176 +#: src/util.c:530 src/export/csv.c:112 src/export/html.c:176 #: src/export/tex.c:155 src/export/text.c:131 msgid "MOUNTED ON" msgstr "MONTÉ SUR" -#: src/util.c:520 src/export/html.c:179 src/export/tex.c:157 +#: src/util.c:531 src/export/html.c:179 src/export/tex.c:157 #: src/export/text.c:134 msgid "MOUNT OPTIONS" msgstr "OPTIONS DE MONTAGE" -#: src/util.c:545 +#: src/util.c:557 msgid "Cannot compute required width\n" msgstr "Impossible de calculer la largeur requise\n" -#: src/util.c:621 +#: src/util.c:635 msgid "" "WARNING: TTY too narrow. Some options have been disabled to make dfc output " "fit (use -f to override).\n" @@ -249,7 +252,7 @@ msgstr "" "AVERTISSEMENT: le TTY est trop étroit. Certaines options ont été désactivées " "afin d'ajuster l'affichage (utilisez -f afin d'outrepasser).\n" -#: src/util.c:667 +#: src/util.c:681 msgid "WARNING: Output still messed up. Enlarge your terminal if you can...\n" msgstr "" "AVERTISSEMENT: l'affichage est toujours perturbé. Agrandissez votre terminal " @@ -328,16 +331,16 @@ msgstr "(=) UT." msgid "FREE (-)" msgstr "LIB. (-)" -#: src/export/text.c:165 +#: src/export/text.c:166 msgid "SUM:" msgstr "SOM:" -#: src/platform/services-bsd.c:353 +#: src/platform/services-bsd.c:350 #, c-format msgid "Could not retrieve mount flags for %s\n" msgstr "Impossible de récupérer les options de montage pour %s\n" -#: src/platform/services-bsd.c:382 +#: src/platform/services-bsd.c:379 #, c-format msgid "Truncating mount options for %s\n" msgstr "Troncation des options de montage pour %s\n" diff --git a/po/nl.po b/po/nl.po index 7a35ce0..6acedd9 100644 --- a/po/nl.po +++ b/po/nl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: dfc 3.1.1\n" "Report-Msgid-Bugs-To: robin.hahling@gw-computing.net\n" -"POT-Creation-Date: 2017-09-09 08:48+0200\n" +"POT-Creation-Date: 2020-12-05 09:49+0100\n" "PO-Revision-Date: 2016-04-15 02:02+0200\n" "Last-Translator: Michiel Pater \n" "Language-Team: Dutch\n" @@ -17,41 +17,43 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: src/dfc.c:214 +#: src/dfc.c:218 #, c-format msgid "-c: illegal sub option %s\n" msgstr "-c: ongeldige suboptie %s\n" -#: src/dfc.c:251 +#: src/dfc.c:255 #, c-format msgid "-e: illegal sub option %s\n" msgstr "-e: ongeldige suboptie %s\n" -#: src/dfc.c:302 +#: src/dfc.c:306 #, c-format msgid "-q: illegal sub option %s\n" msgstr "-q: ongeldige suboptie %s\n" -#: src/dfc.c:363 +#: src/dfc.c:367 #, c-format msgid "-u: illegal sub option %s\n" msgstr "-u: ongeldige suboptie %s\n" -#: src/dfc.c:406 +#: src/dfc.c:410 #, c-format msgid "Error reading the configuration file: %s\n" msgstr "Fout bij het lezen van het configuratiebestand: %s\n" -#: src/dfc.c:445 +#: src/dfc.c:449 msgid "Try dfc -h for more information\n" msgstr "Probeer dfc -h voor meer informatie\n" -#: src/dfc.c:448 +#: src/dfc.c:452 +#, fuzzy msgid "" "Usage: dfc [OPTION(S)] [-c WHEN] [-e FORMAT] [-p FSNAME] [-q SORTBY] [-t " "FSTYPE] [-u UNIT]\n" "Available options:\n" "\t-a\tprint all mounted filesystem\n" +"\t-A\tprint graphs of absolute width\n" "\t-b\tdo not show the graph bar\n" "\t-c\tchoose color mode. Read the manpage for details\n" "\t-d\tshow used size\n" @@ -75,7 +77,7 @@ msgstr "" "\t-i\tlaat informatie zien over inodes\n" "\t-l\tgeef alleen informatie weer over lokaal-gemountte bestandssystemen\n" -#: src/dfc.c:466 +#: src/dfc.c:471 msgid "" "\t-m\tuse metric (SI unit)\n" "\t-M\tdo not print \"mounted on\"\n" @@ -186,61 +188,61 @@ msgstr "Ongeldige HTML kleurcode voor '%s': %s\n" msgid "Cannot assign value for '%s': %s\n" msgstr "Kan geen waarde voor '%s' toewijzen: %s\n" -#: src/util.c:510 src/export/html.c:157 src/export/tex.c:140 +#: src/util.c:521 src/export/html.c:157 src/export/tex.c:140 #: src/export/text.c:101 msgid "FILESYSTEM" msgstr "BEST.SYS." -#: src/util.c:511 src/export/html.c:160 src/export/tex.c:142 +#: src/util.c:522 src/export/html.c:160 src/export/tex.c:142 #: src/export/text.c:104 msgid "TYPE" msgstr "TYPE" -#: src/util.c:513 src/export/html.c:164 src/export/text.c:114 +#: src/util.c:524 src/export/html.c:164 src/export/text.c:114 msgid "%USED" msgstr "%GEBR" -#: src/util.c:514 src/export/html.c:166 src/export/tex.c:147 +#: src/util.c:525 src/export/html.c:166 src/export/tex.c:147 #: src/export/text.c:117 msgid "USED" msgstr "GEBR" -#: src/util.c:515 src/export/html.c:167 src/export/tex.c:148 +#: src/util.c:526 src/export/html.c:167 src/export/tex.c:148 #: src/export/text.c:119 msgid "AVAILABLE" msgstr "BESCH." -#: src/util.c:516 src/export/csv.c:104 src/export/html.c:168 +#: src/util.c:527 src/export/csv.c:104 src/export/html.c:168 #: src/export/tex.c:149 src/export/text.c:120 #, c-format msgid "TOTAL" msgstr "TOT." -#: src/util.c:517 src/export/html.c:171 src/export/text.c:123 +#: src/util.c:528 src/export/html.c:171 src/export/text.c:123 msgid "#INODES" msgstr "#INODES" -#: src/util.c:518 src/export/csv.c:108 src/export/html.c:172 +#: src/util.c:529 src/export/csv.c:108 src/export/html.c:172 #: src/export/text.c:124 #, c-format msgid "AV.INODES" msgstr "BB.INODES" -#: src/util.c:519 src/export/csv.c:112 src/export/html.c:176 +#: src/util.c:530 src/export/csv.c:112 src/export/html.c:176 #: src/export/tex.c:155 src/export/text.c:131 msgid "MOUNTED ON" msgstr "MOUNT" -#: src/util.c:520 src/export/html.c:179 src/export/tex.c:157 +#: src/util.c:531 src/export/html.c:179 src/export/tex.c:157 #: src/export/text.c:134 msgid "MOUNT OPTIONS" msgstr "MOUNT OPTIES" -#: src/util.c:545 +#: src/util.c:557 msgid "Cannot compute required width\n" msgstr "Kan vereiste breedte niet berekenen\n" -#: src/util.c:621 +#: src/util.c:635 msgid "" "WARNING: TTY too narrow. Some options have been disabled to make dfc output " "fit (use -f to override).\n" @@ -248,7 +250,7 @@ msgstr "" "WAARSCHUWING: TTY te smal. Sommige opties zijn uitgeschakeld om dfc output " "te laten passen (gebruik -f om te overschrijven).\n" -#: src/util.c:667 +#: src/util.c:681 msgid "WARNING: Output still messed up. Enlarge your terminal if you can...\n" msgstr "" "WAARSCHUWING: Output nog steeds te breed. Probeer uw terminal te\n" @@ -327,16 +329,16 @@ msgstr "(=) GEBR" msgid "FREE (-)" msgstr "VRIJ (-)" -#: src/export/text.c:165 +#: src/export/text.c:166 msgid "SUM:" msgstr "TOTAAL:" -#: src/platform/services-bsd.c:353 +#: src/platform/services-bsd.c:350 #, c-format msgid "Could not retrieve mount flags for %s\n" msgstr "Kan mount flags niet ontvangen voor %s\n" -#: src/platform/services-bsd.c:382 +#: src/platform/services-bsd.c:379 #, c-format msgid "Truncating mount options for %s\n" msgstr "Mount opties inkorten voor %s\n" From 18ff7960c78daf56510849cc53fc248305208c66 Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Sat, 5 Dec 2020 09:57:24 +0100 Subject: [PATCH 15/20] added to authors --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 1682e22..7b2340a 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -11,6 +11,7 @@ * Frank Villaro-Dixon * Kevin Gillieron * Landry Breuil + * Lenni vh * Matthieu Le Jeune * Sylvain Laperche * Tobias Patzl From 82f6e826db08de535fb63a0691f5717a45b063cb Mon Sep 17 00:00:00 2001 From: scrouthtv Date: Wed, 3 Feb 2021 12:30:57 +0100 Subject: [PATCH 16/20] Update AUTHORS.md --- AUTHORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS.md b/AUTHORS.md index 7b2340a..c9b364a 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -11,7 +11,7 @@ * Frank Villaro-Dixon * Kevin Gillieron * Landry Breuil - * Lenni vh + * Lenni vh * Matthieu Le Jeune * Sylvain Laperche * Tobias Patzl From 14761fea01c3d08884f162f8ed49c4687ffcdddd Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Thu, 4 Feb 2021 10:25:58 +0100 Subject: [PATCH 17/20] fix for text mode --- src/export/text.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/export/text.c b/src/export/text.c index 6a04c7d..b96c4da 100644 --- a/src/export/text.c +++ b/src/export/text.c @@ -169,7 +169,8 @@ text_disp_sum(double stot, double atot, double utot, if (!bflag) { text_disp_bar(ptot, stot, maxfssize); if (agflag) { - (void)printf("\n%*c", 39, ' '); + int gap = max.fsname + max.fstype + max.bar; + (void)printf("\n%*c", gap, ' '); } } From c4e0ee179916b7431a690dc3e19ed37c7e9f818c Mon Sep 17 00:00:00 2001 From: Lenni vH Date: Thu, 4 Feb 2021 10:29:11 +0100 Subject: [PATCH 18/20] added comment --- src/export/text.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/export/text.c b/src/export/text.c index b96c4da..9814015 100644 --- a/src/export/text.c +++ b/src/export/text.c @@ -169,6 +169,7 @@ text_disp_sum(double stot, double atot, double utot, if (!bflag) { text_disp_bar(ptot, stot, maxfssize); if (agflag) { + // Display everything after the bar in a new row, indented correctly: int gap = max.fsname + max.fstype + max.bar; (void)printf("\n%*c", gap, ' '); } From 9729288a8a7bb5cdbae639e03f7a7909f4bcc542 Mon Sep 17 00:00:00 2001 From: Lenni Date: Sat, 6 Mar 2021 21:19:53 +0100 Subject: [PATCH 19/20] fixed total bar in absolute mode in some cases --- src/export/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/export/text.c b/src/export/text.c index 9814015..8bbb47b 100644 --- a/src/export/text.c +++ b/src/export/text.c @@ -170,7 +170,7 @@ text_disp_sum(double stot, double atot, double utot, text_disp_bar(ptot, stot, maxfssize); if (agflag) { // Display everything after the bar in a new row, indented correctly: - int gap = max.fsname + max.fstype + max.bar; + int gap = max.fsname + max.bar; (void)printf("\n%*c", gap, ' '); } } From 5da773aaf554033c139977b559ea57706a6f6854 Mon Sep 17 00:00:00 2001 From: Lenni Date: Sat, 6 Mar 2021 21:24:30 +0100 Subject: [PATCH 20/20] Fixed a bug where the details of the total bar would be off. If dfc decides at runtime to only display short bars instead of wide bars, because the tty is too narrow, the `max.bar` still indicates `GRAPHBAR_WIDE` but it should be `GRAPHBAR_SHORT`. So for calculating the detail fields offset I am now using the ternary thing instead of `max.bar`. This requires another look into it because currently, the titlebar is off if we are using the `-w` option and the tty is too narrow. --- AUTHORS.md | 2 +- src/export/text.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index c9b364a..1bf98f7 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -11,7 +11,7 @@ * Frank Villaro-Dixon * Kevin Gillieron * Landry Breuil - * Lenni vh + * Lenni vH * Matthieu Le Jeune * Sylvain Laperche * Tobias Patzl diff --git a/src/export/text.c b/src/export/text.c index 8bbb47b..89dbbde 100644 --- a/src/export/text.c +++ b/src/export/text.c @@ -170,7 +170,8 @@ text_disp_sum(double stot, double atot, double utot, text_disp_bar(ptot, stot, maxfssize); if (agflag) { // Display everything after the bar in a new row, indented correctly: - int gap = max.fsname + max.bar; + int barsize = wflag ? GRAPHBAR_WIDE : GRAPHBAR_SHORT; + int gap = max.fsname + barsize; (void)printf("\n%*c", gap, ' '); } }