]> git.webhop.me Git - msgbox.git/commitdiff
Revert "add descender hack & new params ~C, see readme.txt"
authorsvenhoefer <svenhoefer@svenhoefer.com>
Sun, 27 Nov 2016 21:39:13 +0000 (22:39 +0100)
committersvenhoefer <svenhoefer@svenhoefer.com>
Sun, 27 Nov 2016 21:39:13 +0000 (22:39 +0100)
This reverts commit 08bcadd38f0574f6a6d2c081e4e546fcc5fd20e9.

gfx.c
msgbox.c
text.c
txtform.c

diff --git a/gfx.c b/gfx.c
index c96ceed0b7c99748052357fd42e03d2adc6d0185..fadbb28b917e32f438fa312f28b9c6b9d3f4d72b 100644 (file)
--- a/gfx.c
+++ b/gfx.c
@@ -7,18 +7,12 @@ void RenderBox(int _sx, int _sy, int _ex, int _ey, int rad, int col)
        uint32_t *pos = lbb + ssx + stride * ssy;
        uint32_t *pos0, *pos1, *pos2, *pos3, *i;
        uint32_t pix = bgra[col];
-
+               
        if (dxx<0) 
        {
                printf("msgbox RenderBox called with dx < 0 (%d)\n", dxx);
                dxx=0;
        }
-       if (dyy > 700)
-       {
-               printf("msgbox RenderBox called with dyy > 700 (%d)\n", dyy); //FIXME
-               //*** Error in `msgbox': munmap_chunk(): invalid pointer: 0x31459008 *** //Nevis
-               dyy = 700;
-       }
 
        if(R)
        {
index 4403d497b99a376775de528ace2d9c58cf14614d..c1cf5f47ecdba0b54c1cb4d4e6c24cb8ea7889de 100644 (file)
--- a/msgbox.c
+++ b/msgbox.c
@@ -8,7 +8,7 @@
 #include "gfx.h"
 #include "txtform.h" 
 
-#define M_VERSION 1.21
+#define M_VERSION 1.20
 
 #define NCF_FILE       "/var/tuxbox/config/neutrino.conf"
 #define HDF_FILE       "/tmp/.msgbox_hidden"
@@ -40,7 +40,7 @@ static char spres[][5]={"","_crt","_lcd"};
 
 char *line_buffer=NULL, *title=NULL;
 int size=24, type=0, timeout=0, refresh=3, flash=0, selection=0, tbuttons=0, buttons=0, bpline=3, echo=0, absolute=0, mute=1, header=1, cyclic=1;
-char *butmsg[16]={0};
+char *butmsg[16];
 int rbutt[16],hide=0,radius=11;
 
 // Misc
@@ -48,7 +48,7 @@ const char NOMEM[]="msgbox <Out of memory>\n";
 char TMP_FILE[64]="/tmp/msgbox.tmp";
 uint32_t *lfb = NULL, *lbb = NULL, *obb = NULL, *hbb = NULL, *ibb = NULL;
 char nstr[BUFSIZE]={0};
-char *trstr=NULL;
+char *trstr;
 const char INST_FILE[]="/tmp/rc.locked";
 int instance=0;
 int stride;
@@ -94,7 +94,7 @@ static void quit_signal(int sig)
 int Read_Neutrino_Cfg(char *entry)
 {
 FILE *nfh;
-char tstr [512]={0}, *cfptr=NULL;
+char tstr [512], *cfptr=NULL;
 int rv=-1;
 
        if((nfh=fopen(NCF_FILE,"r"))!=NULL)
@@ -161,7 +161,7 @@ char *pt1=strg, *pt2=strg;
 int GetSelection(char *sptr)
 {
 int rv=0,btn=0,run=1;
-char *pt1=strdup(sptr),*pt2=NULL,*pt3=NULL;
+char *pt1=strdup(sptr),*pt2,*pt3;
 
        pt2=pt1;
        while(*pt2 && run && btn<MAX_BUTTONS)
@@ -216,9 +216,7 @@ int i,bx,by,x1,y1,rv=-1,run=1,line=0,action=1,cut,itmp,btns=buttons,lbtns=(butto
                memcpy(lfb, hbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
                return 0;
        }
-
        yo=20+((header)?FSIZE_MED*5/4:0);
-       int moffs=yo*3/4+6;
        if(!buttonly)
        {
                memcpy(lbb, ibb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
@@ -295,10 +293,10 @@ int i,bx,by,x1,y1,rv=-1,run=1,line=0,action=1,cut,itmp,btns=buttons,lbtns=(butto
                                        if(header)
                                        {
                                                RenderBox(psx-20, psy-yo+2-FSIZE_BIG/2, psx+pxw+20, psy-yo+FSIZE_BIG*3/4, radius, CMH);
-                                               RenderString(title, psx, psy-moffs+FSIZE_BIG/2, pxw, CENTER, FSIZE_BIG, CMHT);
+                                               RenderString(title, psx, psy-yo+FSIZE_BIG/2, pxw, CENTER, FSIZE_BIG, CMHT);
                                        }
                                }
-                               if(buttonly || !(rv=fh_txt_load(TMP_FILE, psx, pxw, psy+20, dy, size, line, &cut)))
+                               if(buttonly || !(rv=fh_txt_load(TMP_FILE, psx, pxw, psy+15, dy, size, line, &cut)))
                                {
                                        if(type==1)
                                        {
@@ -308,7 +306,7 @@ int i,bx,by,x1,y1,rv=-1,run=1,line=0,action=1,cut,itmp,btns=buttons,lbtns=(butto
                                                        by=i/lbtns;
                                                        RenderBox(buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2), buttxstart+(bx+1)*buttsize+bx*(buttdx/2), buttystart+by*(butty+buttdy/2)+butty, radius, YELLOW);
                                                        RenderBox(buttxstart+bx*(buttsize+buttdx/2)+2, buttystart+by*(butty+buttdy/2)+2, buttxstart+(bx+1)*buttsize+bx*(buttdx/2)-2, buttystart+by*(butty+buttdy/2)+butty-2, radius, ((by*bpline+bx)==(selection-1))?CMCS:CMC);
-                                                       RenderString(butmsg[i], buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2)+butty, buttsize, CENTER, 26, (i==(selection-1))?CMCST:CMCIT);
+                                                       RenderString(butmsg[i], buttxstart+bx*(buttsize+buttdx/2), buttystart+by*(butty+buttdy/2)+butty-7, buttsize, CENTER, 26, (i==(selection-1))?CMCST:CMCIT);
                                                }
                                        }
                                        memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
@@ -404,7 +402,7 @@ int main (int argc, char **argv)
 {
 int ix,tv,found=0, spr;
 int dloop=1, rcc=-1;
-char rstr[BUFSIZE]={0}, *rptr=NULL, *aptr=NULL;
+char rstr[BUFSIZE]={0}, *rptr, *aptr;
 time_t tm1,tm2;
 FILE *fh;
 
@@ -768,7 +766,7 @@ FILE *fh;
 
        //init backbuffer
 
-               if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t))))
+               if(!(lbb = malloc(fix_screeninfo.line_length*var_screeninfo.yres)))
                {
                        perror("msgbox <allocating of Backbuffer>\n");
                        FTC_Manager_Done(manager);
@@ -778,7 +776,7 @@ FILE *fh;
                }
                stride = fix_screeninfo.line_length/sizeof(uint32_t);
 
-               if(!(obb = malloc(var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t))))
+               if(!(obb = malloc(fix_screeninfo.line_length*var_screeninfo.yres)))
                {
                        perror("msgbox <allocating of Backbuffer>\n");
                        FTC_Manager_Done(manager);
@@ -787,7 +785,8 @@ FILE *fh;
                        munmap(lfb, fix_screeninfo.smem_len);
                        return -1;
                }
-               if(!(hbb = malloc(var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t))))
+
+               if(!(hbb = malloc(fix_screeninfo.line_length*var_screeninfo.yres)))
                {
                        perror("msgbox <allocating of Backbuffer>\n");
                        FTC_Manager_Done(manager);
@@ -797,7 +796,8 @@ FILE *fh;
                        munmap(lfb, fix_screeninfo.smem_len);
                        return -1;
                }
-               if(!(ibb = malloc(var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t))))
+
+               if(!(ibb = malloc(fix_screeninfo.line_length*var_screeninfo.yres)))
                {
                        perror("msgbox <allocating of Backbuffer>\n");
                        FTC_Manager_Done(manager);
@@ -943,6 +943,7 @@ FILE *fh;
        
        
        //cleanup
+
        memcpy(lfb, obb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t));
        munmap(lfb, fix_screeninfo.smem_len);
        close(fb);
diff --git a/text.c b/text.c
index 2569d572b69f3312750fb2fb61f4d5ff7925d502..c223f5110580039aa065a03a14cbccb9030026f7 100644 (file)
--- a/text.c
+++ b/text.c
@@ -221,7 +221,7 @@ int RenderChar(FT_ULong currentchar, int _sx, int _sy, int _ex, int color)
                if(color != -1)
                {
                        if (_sx + 10 < _ex)
-                               RenderBox(_sx, _sy - 16, _sx + 10, _sy - 6, GRID, color);
+                               RenderBox(_sx, _sy - 10, _sx + 10, _sy, GRID, color);
                        else
                                return -1;
                }
@@ -236,69 +236,59 @@ int RenderChar(FT_ULong currentchar, int _sx, int _sy, int _ex, int color)
 
        //load char
 
-       if(!(glyphindex = FT_Get_Char_Index(face, currentchar)))
-       {
-               printf("msgbox <FT_Get_Char_Index for Char \"%c\" failed\n", (int)currentchar);
-               return 0;
-       }
-
-       if((err = FTC_SBitCache_Lookup(cache, &desc, glyphindex, &sbit, NULL)))
-       {
-               printf("msgbox <FTC_SBitCache_Lookup for Char \"%c\" failed with Errorcode 0x%.2X>\n", (int)currentchar, error);
-               return 0;
-       }
+               if(!(glyphindex = FT_Get_Char_Index(face, currentchar)))
+               {
+                       printf("msgbox <FT_Get_Char_Index for Char \"%c\" failed\n", (int)currentchar);
+                       return 0;
+               }
 
-       int _d = 0;
-       if (1)
-       {
-               FT_UInt _i = FT_Get_Char_Index(face, 'g');
-               FTC_SBit _g;
-               FTC_SBitCache_Lookup(cache, &desc, _i, &_g, NULL);
-               _d = _g->height - _g->top;
-               _d += 1;
-       }
+               if((err = FTC_SBitCache_Lookup(cache, &desc, glyphindex, &sbit, NULL)))
+               {
+                       printf("msgbox <FTC_SBitCache_Lookup for Char \"%c\" failed with Errorcode 0x%.2X>\n", (int)currentchar, error);
+                       return 0;
+               }
 
-       if(use_kerning)
-       {
-               FT_Get_Kerning(face, prev_glyphindex, glyphindex, ft_kerning_default, &kerning);
+               if(use_kerning)
+               {
+                       FT_Get_Kerning(face, prev_glyphindex, glyphindex, ft_kerning_default, &kerning);
 
-               prev_glyphindex = glyphindex;
-               kerning.x >>= 6;
-       } else
-               kerning.x = 0;
+                       prev_glyphindex = glyphindex;
+                       kerning.x >>= 6;
+               } else
+                       kerning.x = 0;
 
-       //render char
+               //render char
 
-       if(color != -1) /* don't render char, return charwidth only */
-       {
-               if (_sx + sbit->xadvance >= _ex)
-                       return -1; /* limit to maxwidth */
-
-               uint32_t bgcolor = *(lbb + (sy + _sy) * stride + (sx + _sx));
-               uint32_t fgcolor = bgra[color];
-               uint32_t *colors = lookup_colors(fgcolor, bgcolor);
-               uint32_t *p = lbb + (sx + _sx + sbit->left + kerning.x) + stride * (sy + _sy - sbit->top - _d);
-               uint32_t *r = p + (_ex - _sx);  /* end of usable box */
-               for(row = 0; row < sbit->height; row++)
+               if(color != -1) /* don't render char, return charwidth only */
                {
-                       uint32_t *q = p;
-                       uint8_t *s = sbit->buffer + row * sbit->pitch;
-                       for(pitch = 0; pitch < sbit->width; pitch++)
+                       if (_sx + sbit->xadvance >= _ex)
+                               return -1; /* limit to maxwidth */
+
+                       uint32_t bgcolor = *(lbb + (sy + _sy) * stride + (sx + _sx));
+                       uint32_t fgcolor = bgra[color];
+                       uint32_t *colors = lookup_colors(fgcolor, bgcolor);
+                       uint32_t *p = lbb + (sx + _sx + sbit->left + kerning.x) + stride * (sy + _sy - sbit->top);
+                       uint32_t *r = p + (_ex - _sx);  /* end of usable box */
+                       for(row = 0; row < sbit->height; row++)
                        {
-                               if (*s)
-                                               *q = colors[*s];
-                               q++, s++;
-                               if (q > r)      /* we are past _ex */
-                                       break;
+                               uint32_t *q = p;
+                               uint8_t *s = sbit->buffer + row * sbit->pitch;
+                               for(pitch = 0; pitch < sbit->width; pitch++)
+                               {
+                                       if (*s)
+                                                       *q = colors[*s];
+                                       q++, s++;
+                                       if (q > r)      /* we are past _ex */
+                                               break;
+                               }
+                               p += stride;
+                               r += stride;
                        }
-                       p += stride;
-                       r += stride;
                }
-       }
 
        //return charwidth
 
-       return sbit->xadvance + kerning.x;
+               return sbit->xadvance + kerning.x;
 }
 
 /******************************************************************************
@@ -328,9 +318,6 @@ int GetStringLen(int _sx, char *string, size_t size)
                                string+=5;
                                stringlen=i-_sx;
                        }
-                       else if(*string=='!') {
-                               string++;
-                       }
                        break;
                default:
                        stringlen += RenderChar(UTF8ToUnicode(&string, 1), -1, -1, -1, -1);
@@ -386,7 +373,7 @@ int RenderString(char *string, int _sx, int _sy, int maxwidth, int layout, int s
                        case CENTER:    if(stringlen < maxwidth) _sx += (maxwidth - stringlen)/2;
                                        break;
 
-                       case RIGHT:     if(stringlen < maxwidth) _sx += maxwidth - stringlen * 0.8;
+                       case RIGHT:     if(stringlen < maxwidth) _sx += maxwidth - stringlen;
                }
        }
 
index 97f2e6efaf1df7194fa428d7903acc38868fcad2..b53b3d631c1710e8b239b9a2bddbfe112b61acea 100644 (file)
--- a/txtform.c
+++ b/txtform.c
 
 int fh_txt_trans(const char *name, int xs, int xw, int ys, int dy, int size, int line, int *cut, int *x, int *y, int plot)
 {
-char tstr[BUFSIZE]={0},rstr[BUFSIZE]={0},*tptr=NULL;
-int loop=1, j, slen;
+char tstr[BUFSIZE],rstr[BUFSIZE],*tptr;
+int loop=1, j, slen, cnt=0;
 FILE *fh;
-int just, comment, color=CMCT;
+int just, color=CMCT;
 
        if(!(fh=fopen(name,"rb")))      return(FH_ERROR_FILE);
 
@@ -27,7 +27,6 @@ int just, comment, color=CMCT;
        {
                j=0;
                just=LEFT;
-               comment=0;
                color=CMCT;
                
                tptr=tstr+strlen(tstr);
@@ -40,6 +39,7 @@ int just, comment, color=CMCT;
                while(*tptr)
                {
                        rstr[j++]=*tptr;
+                       cnt++;
 
                        if(*tptr == '~')
                        {
@@ -48,24 +48,9 @@ int just, comment, color=CMCT;
                                        case 'l': just=LEFT; break;
                                        case 'r': just=RIGHT; break;
                                        case 'c': just=CENTER; break;
-                                       case 'C':
-                                               if (*(tptr+2) == '!') {
-                                                       comment=1;
-                                                       tptr++;
-                                               }
-                                               else if (*(tptr+2) == 'L') {
-                                                       comment=2;
-                                                       tptr++;
-                                               }
-                                               else if (*(tptr+2) == 'R') {
-                                                       comment=3;
-                                                       tptr++;
-                                               }
-                                               break;
                                        case 's':
-                                               ys-=(dy/2);
-                                               RenderBox(xs, ys-2-size/3+1, xs+xw, ys-2-size/3+2, FILL, CMS);
-                                               RenderBox(xs, ys-2-size/3, xs+xw, ys-2-size/3+1, FILL, CMCIT);
+                                               RenderBox(xs, ys-size/3+1, xs+xw, ys-size/3+2, FILL, CMS);
+                                               RenderBox(xs, ys-size/3, xs+xw, ys-size/3+1, FILL, CMCIT);
                                                break;
                                }
                        }
@@ -82,34 +67,7 @@ int just, comment, color=CMCT;
                        {
                                if(loop>=line)
                                {
-                                       slen=GetStringLen(xs, t, size);
-                                       if (comment == 1)
-                                       {
-                                               int xxs = xs;
-                                               RenderBox(xs, ys-2-size/2+1, xs+xw, ys-2-size/2+2, FILL, CMS);
-                                               RenderBox(xs, ys-2-size/2, xs+xw, ys-2-size/2+1, FILL, CMCIT);
-                                               if(slen > 0 && slen < xw) {
-                                                       xxs += (xw-slen-10)/2-3;
-                                                       RenderBox(xxs, ys-2-size/2, xxs+slen+10, ys-2-size/2+2, FILL, CMC);
-                                               }
-                                               RenderString(t, xs, ys, xw, CENTER, size, CMCIT);
-                                       }
-                                       else if (comment == 2)
-                                       {
-                                               RenderBox(xs+slen, ys-2-size/2+1, xs+xw, ys-2-size/2+2, FILL, CMS);
-                                               RenderBox(xs+slen, ys-2-size/2, xs+xw, ys-2-size/2+1, FILL, CMCIT);
-                                               RenderString(t, xs, ys, xw, LEFT, size, color);
-                                       }
-                                       else if (comment == 3)
-                                       {
-                                               RenderBox(xs, ys-2-size/2+1, xs+xw-slen, ys-2-size/2+2, FILL, CMS);
-                                               RenderBox(xs, ys-2-size/2, xs+xw-slen, ys-2-size/2+1, FILL, CMCIT);
-                                               RenderString(t, xs, ys, xw, RIGHT, size, color);
-                                       }
-                                       else
-                                       {
-                                               RenderString(t, xs, ys, xw, just, size, color);
-                                       }
+                                       RenderString(t, xs, ys, xw, just, size, color);
                                        ys+=dy;
                                }
                        }