]> granicus.if.org Git - vnstat/commitdiff
highlight current day in top list when visible
authorTeemu Toivola <git@humdi.net>
Thu, 21 Mar 2019 20:05:46 +0000 (22:05 +0200)
committerTeemu Toivola <git@humdi.net>
Thu, 21 Mar 2019 20:05:46 +0000 (22:05 +0200)
CHANGES
src/dbshow.c
src/image.c

diff --git a/CHANGES b/CHANGES
index 8218d4f7f02ac67026ea37b244458b958f0727b2..25dec471b1ac2b42809498d3839ce598a29ee1db 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -8,6 +8,7 @@
      traffic calculations in rollover situations, cfg: 64bitInterfaceCounters
    - Possibility for queries to merge data from multiple interfaces to one
      output with interface1+interface2 syntax
+   - Highlight current day in top list when visible
 
 
 2.1 / 6-Dec-2018
index 008e6e924ccfc4fe9d9e16b727664c2b32060ec2..4d2350fb92dc30fc9139c8696c79e4431d2101ba 100644 (file)
@@ -282,6 +282,7 @@ void showlist(const interfaceinfo *interface, const char *listname, const char *
        int32_t limit;
        int listtype, offset = 0, i = 1;
        struct tm *d;
+       time_t current;
        char datebuff[DATEBUFFLEN], daybuff[DATEBUFFLEN];
        char titlename[16], colname[8], stampformat[64];
        uint64_t e_rx, e_tx, e_secs, div, mult;
@@ -351,6 +352,9 @@ void showlist(const interfaceinfo *interface, const char *listname, const char *
                } else {
                        snprintf(titlename, 16, "top %d", limit);
                }
+               current = time(NULL);
+               d = localtime(&current);
+               strftime(daybuff, DATEBUFFLEN, stampformat, d);
        }
 
        printf("\n");
@@ -433,7 +437,11 @@ void showlist(const interfaceinfo *interface, const char *listname, const char *
                }
 
                if (listtype == 4) {
-                       printf("  %2d  ", i);
+                       if (strcmp(daybuff, datebuff) == 0) {
+                               printf("> %2d  ", i);
+                       } else {
+                               printf("  %2d  ", i);
+                       }
                }
 
                if (strlen(datebuff)<=9 && listtype != 4) {
index 402c28c55a0a6bfb847bad53a1de56d01fbf7382..1c93a6a672effdfac144cdd7bc905cb5b1119176 100644 (file)
@@ -488,6 +488,7 @@ void drawlist(IMAGECONTENT *ic, const char *listname)
        char buffer[512], datebuff[16], daybuff[16];
        char stampformat[64], titlename[16], colname[8];
        struct tm *d;
+       time_t current;
        dbdatalist *datalist = NULL, *datalist_i = NULL;
        dbdatalistinfo datainfo;
 
@@ -613,6 +614,9 @@ void drawlist(IMAGECONTENT *ic, const char *listname)
                        if (cfg.ostyle<=2) {
                                drawlegend(ic, 398, 40-headermod);
                        }
+                       current = time(NULL);
+                       d = localtime(&current);
+                       strftime(daybuff, 16, stampformat, d);
                } else { // everything else
                        if (cfg.ostyle>2) {
                                drawlegend(ic, 432, 40-headermod);
@@ -664,6 +668,13 @@ void drawlist(IMAGECONTENT *ic, const char *listname)
                        } else {
                                snprintf(buffer, 32, "  %2d  %-*s ", i, getpadding(11, datebuff), datebuff);
                        }
+                       if (strcmp(datebuff, daybuff) == 0) {
+                               if (cfg.ostyle > 2) {
+                                       gdImageFilledRectangle(ic->im, textx+2, texty+2, textx+422, texty+12, ic->cbgoffset);
+                               } else {
+                                       gdImageFilledRectangle(ic->im, textx+2, texty+2, textx+326, texty+12, ic->cbgoffset);
+                               }
+                       }
                } else {
                        if (strftime(datebuff, 16, stampformat, d)<=8) {
                                snprintf(buffer, 32, "  %*s", getpadding(8, datebuff), datebuff);