From d90716a47ded0abb095be8eda89be0b426abaeca Mon Sep 17 00:00:00 2001 From: glenda Date: Sun, 2 Feb 2025 01:49:01 +0000 Subject: [PATCH] fix progressbar --- pres.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/pres.c b/pres.c index ca8a4957d201fa11b931f6b69e8bae066c0ec2dd..8f6d8812d9eef63d61bffb9378ad93f1fa3ed961 100644 --- a/pres.c +++ b/pres.c @@ -193,9 +193,10 @@ checkerr(Slide *s, char *msg, ...) void checkfile(void) { - int waserr, linum; + int i, waserr, linum; char *c2, *p; Slide *s; + Dir *d; waserr = 0; linum = 0; @@ -214,9 +215,22 @@ checkfile(void) continue; else if(strcmp(s->cmd, "text") == 0) continue; - else if(strcmp(s->cmd, "gallery") == 0) - continue; - else if(strcmp(s->cmd, "title") == 0){ + else if(strcmp(s->cmd, "gallery") == 0){ + if(s->nlines == 0){ + waserr = 1; + checkerr(s, "missing lines"); + } + + for(i = 0; i < s->nlines; i++){ + if(*(s->lines[i]) == '\0') + continue; + if((d = dirstat(s->lines[i])) == nil){ + waserr = 1; + checkerr(s, "missing file: '%s'", s->lines[i]); + } + free(d); + } + }else if(strcmp(s->cmd, "title") == 0){ if(s->arg == nil){ waserr = 1; checkerr(s, "missing arg"); @@ -503,11 +517,11 @@ render(void) prog0 = Pt(smin.x, smax.y); prog1 = Pt(smin.x + cslide + (smax.x - smin.x) / (nslides - 1) * cslide, smax.y); - line(screen, Pt(smin.x, smax.y), smax, Endsquare, Endsquare, 5, bg, Pt(0,0)); - line(screen, prog0, prog1, Endsquare, Enddisc, 5, fg, Pt(0,0)); + line(screen, Pt(smin.x, smax.y), smax, Endsquare, Endsquare, nfont->height, bg, Pt(0,0)); + line(screen, prog0, prog1, Endsquare, Enddisc, nfont->height, fg, Pt(0,0)); sprint(buf, "Slide %d", cslide); - stringbg(screen, Pt(5, smax.y - 5 - nfont->height), fg, Pt(0,0), nfont, buf, bg, Pt(0,0)); + stringbg(screen, SPt(2, smax.y - nfont->height - 2), bg, Pt(0,0), nfont, buf, fg, Pt(0,0)); } } @@ -540,7 +554,7 @@ main(int argc, char *argv[]) ym = 10; tfname = "/n/ttf/lucida.ttf.32/font"; - hfname = "/n/ttf/lucida.ttf.80/font"; + hfname = "/n/ttf/lucida.ttf.64/font"; ARGBEGIN{ case 'c': @@ -581,7 +595,7 @@ main(int argc, char *argv[]) contents = malloc(d->length + 2); if(readn(fd, contents, d->length) < 0) sysfatal("%r"); - // cursed but makes the handling nicer above + // insert a newline, just in case contents[d->length] = '\n'; contents[d->length + 1] = '\0'; offset = contents;