Browse code

tweak info header's colors and contents

Dario Rodriguez authored on 01/12/2020 17:59:37
Showing 1 changed files
... ...
@@ -6,7 +6,6 @@
6 6
  * Author: Dario Rodriguez dario@softhome.net
7 7
  * This program is licensed under the terms of GNU GPL v2.1+
8 8
  */
9
-
10 9
 #include <stdio.h>
11 10
 #include <stdlib.h>
12 11
 #include <unistd.h>
... ...
@@ -42,8 +41,10 @@
42 41
 #define COMMAND_QUESTION "(?)"
43 42
 #define COMMAND_EXIT "Exit"
44 43
 
44
+/* "forest" theme */
45 45
 #define COLOR_STATUSBG "\x14\x3a\xaf\xff"
46 46
 #define COLOR_STATUSFG "\xe6\xdc\x5d\xff"
47
+#define COLOR_STATUSFGLIGHT "\x6f\x73\xa3\xff"
47 48
 
48 49
 #define COLOR_QUERYBG "\xad\x92\x5e\xff"
49 50
 #define COLOR_QUERYFG "\xd0\xef\x4f\xff"
... ...
@@ -53,7 +54,7 @@
53 54
 
54 55
 #define COLOR_INFOBG "\x4e\x8a\x4e\xff"
55 56
 #define COLOR_INFOFG "\xee\xee\x46\xff"
56
-
57
+#define COLOR_INFOFGLIGHT "\x84\xa4\x4c\xff"
57 58
 
58 59
 typedef struct re_t {
59 60
         redata_t *data;
... ...
@@ -1561,16 +1562,37 @@ int
1561 1562
 re_drawheader_editing(re_t *re)
1562 1563
 {
1563 1564
         long cursorpos;
1565
+        char linebuf[32],colbuf[32],posbuf[32],sizebuf[32];
1566
+        char *spaceslinebuf,*spacescolbuf,*spacesposbuf,*spacessizebuf;
1567
+        char spaces[128];
1568
+        int lenfilename;
1569
+        char *filename;
1570
+        char *spacesfilename;
1564 1571
         if(re==NULL)
1565 1572
                 return(-1);
1566 1573
         if(redata_linecol2pos(re->data,re->curline,re->curcol,&cursorpos,NULL)!=0)
1567 1574
                 return(0); /* error obtaining position */
1568
-        reui_fill(re->ui,0,0,re->ui->w,re->ui->fontheight,COLOR_STATUSBG);
1575
+        reui_fill(re->ui,0,0,re->ui->w,re->ui->fontheight,redata_needs_saving(re->data)?COLOR_STATUSBG:COLOR_INFOBG);
1569 1576
         /* for the user, lines start at 0 (internally they start at 0) */
1570
-        reui_printf(re->ui,0,0,COLOR_STATUSFG,"File: %s Line:%i Col:%i Pos:%li Size:%li %s"
1571
-          ,re->filename,re->curline+1,re->curcol+1,cursorpos,redata_getused(re->data)
1572
-          ,"");
1573
-#warning #error MAKE THE PREVIOUS LINE LAST %s print: "CHANGED" when unsaved&not-in-reu, "changed" when unsaved but is in reu, "saved" when it is saved.
1577
+        memset(spaces,' ',sizeof(spaces));
1578
+        spaces[sizeof(spaces)-1]='\0';
1579
+        snprintf(linebuf,sizeof(linebuf),"%i",re->curline+1),linebuf[sizeof(linebuf)-1]='\0';
1580
+        spaceslinebuf=spaces+sizeof(spaces)-1-strlen(linebuf);
1581
+        snprintf(colbuf,sizeof(colbuf),"%i",re->curcol+1),colbuf[sizeof(colbuf)-1]='\0';
1582
+        spacescolbuf=spaces+sizeof(spaces)-1-strlen(colbuf);
1583
+        snprintf(posbuf,sizeof(posbuf),"%li",cursorpos),posbuf[sizeof(posbuf)-1]='\0';
1584
+        spacesposbuf=spaces+sizeof(spaces)-1-strlen(posbuf);
1585
+        snprintf(sizebuf,sizeof(sizebuf),"%li",redata_getused(re->data)),sizebuf[sizeof(sizebuf)-1]='\0';
1586
+        spacessizebuf=spaces+sizeof(spaces)-1-strlen(sizebuf);
1587
+        lenfilename=strlen(re->filename);
1588
+        filename=((lenfilename)>(sizeof(spaces)-1))?(re->filename+lenfilename-sizeof(spaces)-1):re->filename;
1589
+        spacesfilename=spaces+sizeof(spaces)-1-strlen(filename);
1590
+        reui_printf(re->ui,0,0,redata_needs_saving(re->data)?COLOR_STATUSFGLIGHT:COLOR_INFOFGLIGHT
1591
+           ,"File:%s%s Line:%s Col:%s Pos:%s Size:%s"
1592
+          ,spacesfilename,redata_needs_saving(re->data)?"*":" ",spaceslinebuf,spacescolbuf,spacesposbuf,spacessizebuf);
1593
+        reui_printf(re->ui,0,0,redata_needs_saving(re->data)?COLOR_STATUSFG:COLOR_INFOFG
1594
+           ,"     %s%s      %s     %s     %s      %s"
1595
+          ,filename," ",linebuf,colbuf,posbuf,sizebuf);
1574 1596
         re->headerdirty=0;
1575 1597
         re->ui->rendererdirty=1;
1576 1598
         return(0);