9 typedef struct Page Page;
39 Image *frame, *paper, *ground;
41 char pagespool[] = "/tmp/pagespool.";
50 char *pagemenugen(int i);
86 {0xff, 0x80, 0xff, 0x80, 0xff, 0x00, 0xfe, 0x00,
87 0xff, 0x00, 0xff, 0x80, 0xff, 0xc0, 0xef, 0xe0,
88 0xc7, 0xf0, 0x03, 0xf0, 0x01, 0xe0, 0x00, 0xc0,
89 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, },
90 {0x00, 0x00, 0x7f, 0x00, 0x7e, 0x00, 0x7c, 0x00,
91 0x7e, 0x00, 0x7f, 0x00, 0x6f, 0x80, 0x47, 0xc0,
92 0x03, 0xe0, 0x01, 0xf0, 0x00, 0xe0, 0x00, 0x40,
93 0x00, 0x00, 0x01, 0xb6, 0x01, 0xb6, 0x00, 0x00, }
96 void showpage(Page *);
97 void drawpage(Page *);
98 Point pagesize(Page *);
101 addpage(Page *up, char *label, int (*popen)(Page *), void *pdata, int fd)
105 p = mallocz(sizeof(*p), 1);
106 p->label = strdup(label);
120 up->down = up->tail = p;
128 if(up && current == up)
134 resizewin(Point size)
138 if((wctl = open("/dev/wctl", OWRITE)) < 0)
141 size = addpt(size, Pt(Borderwidth*2, Borderwidth*2));
142 fprint(wctl, "resize -dx %d -dy %d\n", size.x, size.y);
151 snprint(nam, sizeof nam, "%s%s%.12d%.8lux", pagespool, pfx, getpid(), id++);
152 return create(nam, OEXCL|ORCLOSE|ORDWR, 0600);
156 catchnote(void *, char *msg)
158 if(strstr(msg, "sys: write on closed pipe"))
160 if(strstr(msg, "hangup"))
162 if(strstr(msg, "alarm"))
175 for(mfd = 0; fd >= 0; fd = va_arg(arg, int), mfd++)
180 if((fd = open("/fd", OREAD)) < 0)
181 sysfatal("open: %r");
182 n = dirreadall(fd, &dir);
184 if(strstr(dir[i].name, "ctl"))
186 fd = atoi(dir[i].name);
194 pipeline(int fd, char *fmt, ...)
196 char buf[NPATH], *argv[4];
206 vsnprint(buf, sizeof buf, fmt, arg);
208 switch(rfork(RFPROC|RFMEM|RFFDG|RFREND|RFNOWAIT)){
214 dupfds(fd, pfd[1], 2, -1);
219 exec("/bin/rc", argv);
220 sysfatal("exec: %r");
231 if(x = strrchr(s, '/'))
246 if((fd = dup(p->fd, -1)) < 0){
254 pipeline(fd, "%s", (char*)p->data);
257 * dont keep the file descriptor arround if it can simply
260 fd2path(p->fd, nam, sizeof(nam));
261 if(strncmp(nam, pagespool, strlen(pagespool))){
264 p->data = strdup(nam);
276 pipeline(p->fd, "%s", (char*)p->data);
286 char mnt[32], cmd[64], *argv[4];
289 snprint(mnt, sizeof(mnt), "/n/tapefs.%.12d%.8lux", getpid(), (ulong)p);
290 snprint(cmd, sizeof(cmd), "%s -m %s /fd/0", p->data, mnt);
291 switch(rfork(RFPROC|RFMEM|RFFDG|RFREND)){
297 dupfds(p->fd, 1, 2, -1);
302 exec("/bin/rc", argv);
303 sysfatal("exec: %r");
308 p->data = strdup(mnt);
316 char buf[NPATH], *s, *e;
322 e = buf+sizeof(buf)-1;
323 s += snprint(s, e-s, "%s/", (char*)p->data);
326 pipeline(fd, "awk '/\\<rootfile/{"
327 "if(match($0, /full\\-path\\=\\\"([^\\\"]+)\\\"/)){"
328 "print substr($0, RSTART+11,RLENGTH-12);exit}}'");
329 n = read(fd, s, e - s);
333 while(n > 0 && s[n-1] == '\n')
337 if((fd = open(buf, OREAD)) < 0)
339 pipeline(fd, "awk '/\\<item/{"
340 "if(match($0, /id\\=\\\"([^\\\"]+)\\\"/)){"
341 "id=substr($0, RSTART+4, RLENGTH-5);"
342 "if(match($0, /href\\=\\\"([^\\\"]+)\\\"/)){"
343 "item[id]=substr($0, RSTART+6, RLENGTH-7)}}};"
345 "if(match($0, /idref\\=\\\"([^\\\"]+)\\\"/)){"
346 "ref=substr($0, RSTART+7, RLENGTH-8);"
347 "print item[ref]; fflush}}'");
348 s = strrchr(buf, '/')+1;
349 while((n = read(fd, s, e-s)) > 0){
350 while(n > 0 && s[n-1] == '\n')
353 addpage(p, shortname(buf), popenfile, strdup(buf), -1);
359 typedef struct Ghost Ghost;
378 switch(rfork(RFPROC|RFMEM|RFFDG|RFNOWAIT)){
386 dupfds(gs->pdat, gs->pin, pfd[1], -1);
387 fprint(1, "%s DoPDFPage\n"
390 "dup (THIS IS NOT AN INFERNO BITMAP\\n) writestring "
391 "flushfile\n", p->label);
392 while((n = read(0, buf, sizeof buf)) > 0){
393 if(memcmp(buf, "THIS IS NOT AN INFERNO BITMAP\n", 30) == 0)
405 infernobithdr(char *buf, int n)
408 if(memcmp(buf, "compressed\n", 11) == 0)
410 if(strtochan((char*)buf))
412 if(memcmp(buf, " ", 10) == 0 &&
413 '0' <= buf[10] && buf[10] <= '9' &&
423 int n, i, pdf, ifd, ofd, pin[2], pout[2], pdat[2];
424 char buf[NBUF], nam[32], *argv[16];
430 if(read(ifd, buf, 5) != 5)
433 if(memcmp(buf, "%PDF-", 5) == 0)
454 switch(rfork(RFPROC|RFMEM|RFFDG|RFREND|RFNOWAIT)){
459 dupfds(pin[1], pout[1], 2, pdat[1], ifd, -1);
461 dupfds(nullfd, nullfd, 2, pdat[1], ifd, -1);
463 pipeline(4, "%s", argv[0]);
466 argv[2] = "-sDEVICE=plan9";
467 argv[3] = "-sOutputFile=/fd/3";
469 argv[5] = pdf ? "-dDELAYSAFER" : "-dSAFER";
471 argv[7] = "-dTextAlphaBits=4";
472 argv[8] = "-dGraphicsAlphaBits=4";
473 snprint(buf, sizeof buf, "-r%d", ppi);
475 argv[10] = "-dDOINTERPOLATE";
476 argv[11] = pdf ? "-" : "/fd/4";
478 exec("/bin/gs", argv);
479 sysfatal("exec: %r");
490 "/PAGEOUT (/fd/1) (w) file def\n"
491 "/PAGE== { PAGEOUT exch write==only PAGEOUT (\\n) writestring PAGEOUT flushfile } def\n"
495 "/PDFSave null def\n"
496 "/DSCPageCount 0 def\n"
497 "/DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage } def\n"
499 "GS_PDF_ProcSet begin\n"
501 "(/fd/4) (r) file { DELAYSAFER { .setsafe } if } stopped pop pdfopen begin\n"
503 "pdfpagecount PAGE==\n";
506 if(write(pin[0], prolog, n) != n)
508 if((n = read(pout[0], buf, sizeof(buf)-1)) < 0)
516 gs = mallocz(sizeof(*gs), 1);
521 snprint(nam, sizeof nam, "%d", i);
522 addpage(p, nam, popenpdf, gs, -1);
525 /* keep ghostscript arround */
530 while((n = read(pdat[0], buf, sizeof(buf))) >= 0){
531 if(ofd >= 0 && (n <= 0 || infernobithdr(buf, n))){
532 snprint(nam, sizeof nam, "%d", i);
533 addpage(p, nam, popenimg, nil, ofd);
539 snprint(nam, sizeof nam, "%.4d", ++i);
540 if((ofd = createtmp(nam)) < 0)
541 ofd = dup(nullfd, -1);
543 if(write(ofd, buf, n) != n)
557 filetype(char *buf, int nbuf, char *typ, int ntyp)
559 int n, ifd[2], ofd[2];
562 if(infernobithdr(buf, nbuf)){
563 strncpy(typ, "image/p9bit", ntyp);
575 if(rfork(RFPROC|RFMEM|RFFDG|RFREND|RFNOWAIT) == 0){
576 dupfds(ifd[1], ofd[1], 2, -1);
580 exec("/bin/file", argv);
584 if(rfork(RFPROC|RFMEM|RFFDG|RFNOWAIT) == 0){
590 if((n = readn(ofd[0], typ, ntyp-1)) < 0)
593 while(n > 0 && typ[n-1] == '\n')
600 dircmp(void *p1, void *p2)
607 return strcmp(d1->name, d2->name);
618 "application/pdf", popengs, nil,
619 "application/postscript", popengs, nil,
620 "application/troff", popengs, "lp -dstdout",
621 "text/plain", popengs, "lp -dstdout",
622 "text/html", popengs, "uhtml | html2ms | tbl | troff -ms | lp -dstdout",
623 "application/dvi", popengs, "dvips -Pps -r0 -q1 -f1",
624 "application/doc", popengs, "doc2ps",
625 "application/zip", popentape, "fs/zipfs",
626 "application/x-tar", popentape, "fs/tarfs",
627 "application/x-ustar", popentape, "fs/tarfs",
628 "application/x-compress", popenfilter, "uncompress",
629 "application/x-gzip", popenfilter, "gunzip",
630 "application/x-bzip2", popenfilter, "bunzip2",
631 "image/gif", popenimg, "gif -t9",
632 "image/jpeg", popenimg, "jpg -t9",
633 "image/png", popenimg, "png -t9",
634 "image/ppm", popenimg, "ppm -t9",
635 "image/bmp", popenimg, "bmp -t9",
636 "image/p9bit", popenimg, nil,
639 char buf[NBUF], typ[128], *file;
648 if((fd = open(file, OREAD)) < 0){
655 if((d = dirfstat(fd)) == nil){
664 snprint(buf, sizeof(buf), "%s/META-INF/container.xml", file);
665 if((tfd = open(buf, OREAD)) >= 0){
673 if((n = dirreadall(fd, &d)) < 0)
675 qsort(d, n, sizeof d[0], dircmp);
677 addpage(p, d[i].name, popenfile, smprint("%s/%s", file, d[i].name), -1);
683 memset(buf, 0, NBUF/2);
684 if((n = readn(fd, buf, NBUF/2)) <= 0)
686 filetype(buf, n, typ, sizeof(typ));
687 for(i=0; i<nelem(tab); i++)
688 if(strncmp(typ, tab[i].typ, strlen(tab[i].typ)) == 0)
691 werrstr("unknown image format: %s", typ);
695 p->data = tab[i].data;
696 p->open = tab[i].open;
697 if(seek(fd, 0, 0) < 0)
699 if((i = readn(fd, buf+n, n)) < 0)
701 if(i != n || memcmp(buf, buf+n, i)){
704 if((tfd = createtmp("file")) < 0)
707 if(write(tfd, buf, n) != n)
709 if((n = read(fd, buf, sizeof(buf))) < 0)
712 if(dup(tfd, fd) < 0){
742 for(p = root->down; p; p = t)
743 if((t = nextpage(p)) == x)
755 if(p->open == nil || (fd = p->open(p)) < 0)
759 pipeline(fd, "rotate -r %d", rotate);
761 pipeline(fd, "resize -x %d", resize.x);
763 pipeline(fd, "resize -y %d", resize.y);
773 if(p->open && p->image == nil){
774 if((fd = openpage(p)) >= 0){
776 if((p->image = readimage(display, fd, 1)) == nil)
777 fprint(2, "readimage: %r\n");
789 if(p->open == nil || p->image == nil)
791 lockdisplay(display);
793 unlockdisplay(display);
802 for(p = root->down; p; p = nextpage(p)){
803 if(age == 0) /* synchronous flush */
805 else if(!canqlock(p))
807 if((pagegen - p->gen) >= age)
814 loadpages(Page *p, int ahead, int oviewgen)
818 ahead++; /* load at least one */
819 unloadpages(ahead*2);
820 for(i = 0; i < ahead && p; p = nextpage(p), i++){
821 if(viewgen != oviewgen)
825 if(viewgen != oviewgen){
835 if(size.x && size.y && newwin){
839 lockdisplay(display);
841 unlockdisplay(display);
849 * A draw operation that touches only the area contained in bot but not in top.
850 * mp and sp get aligned with bot.min.
853 gendrawdiff(Image *dst, Rectangle bot, Rectangle top,
854 Image *src, Point sp, Image *mask, Point mp, int op)
860 if(Dx(bot)*Dy(bot) == 0)
863 /* no points in bot - top */
864 if(rectinrect(bot, top))
867 /* bot - top ≡ bot */
868 if(Dx(top)*Dy(top)==0 || rectXrect(bot, top)==0){
869 gendrawop(dst, bot, src, sp, mask, mp, op);
874 /* split bot into rectangles that don't intersect top */
876 if(bot.min.x < top.min.x){
877 r = Rect(bot.min.x, bot.min.y, top.min.x, bot.max.y);
878 delta = subpt(r.min, origin);
879 gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
880 bot.min.x = top.min.x;
884 if(bot.max.x > top.max.x){
885 r = Rect(top.max.x, bot.min.y, bot.max.x, bot.max.y);
886 delta = subpt(r.min, origin);
887 gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
888 bot.max.x = top.max.x;
892 if(bot.min.y < top.min.y){
893 r = Rect(bot.min.x, bot.min.y, bot.max.x, top.min.y);
894 delta = subpt(r.min, origin);
895 gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
896 bot.min.y = top.min.y;
900 if(bot.max.y > top.max.y){
901 r = Rect(bot.min.x, top.max.y, bot.max.x, bot.max.y);
902 delta = subpt(r.min, origin);
903 gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
904 bot.max.y = top.max.y;
909 alphachan(ulong chan)
911 for(; chan; chan >>= 8)
912 if(TYPE(chan) == CAlpha)
918 zoomdraw(Image *d, Rectangle r, Rectangle top, Image *b, Image *s, Point sp, int f)
926 if(r.min.x < d->r.min.x){
927 sp.x += (d->r.min.x - r.min.x)/f;
928 a.x = (d->r.min.x - r.min.x)%f;
929 r.min.x = d->r.min.x;
931 if(r.min.y < d->r.min.y){
932 sp.y += (d->r.min.y - r.min.y)/f;
933 a.y = (d->r.min.y - r.min.y)%f;
934 r.min.y = d->r.min.y;
937 w = s->r.max.x - sp.x;
941 dr.max.x = dr.min.x+w;
942 if(!alphachan(s->chan))
945 if(b) gendrawdiff(d, dr, top, b, sp, nil, ZP, SoverD);
946 gendrawdiff(d, dr, top, s, sp, nil, ZP, SoverD);
949 if((t = allocimage(display, dr, s->chan, 0, 0)) == nil)
951 for(; dr.min.y < r.max.y; dr.min.y++){
952 dr.max.y = dr.min.y+1;
953 draw(t, dr, s, nil, sp);
960 for(sp=dr.min; dr.min.x < r.max.x; sp.x++){
961 dr.max.x = dr.min.x+1;
962 if(b) gendrawdiff(d, dr, top, b, sp, nil, ZP, SoverD);
963 gendrawdiff(d, dr, top, t, sp, nil, ZP, SoverD);
964 for(dr.min.x++; ++a.x < f && dr.min.x < r.max.x; dr.min.x++){
965 dr.max.x = dr.min.x+1;
966 gendrawdiff(d, dr, top, d, Pt(dr.min.x-1, dr.min.y), nil, ZP, SoverD);
976 return p->image ? mulpt(subpt(p->image->r.max, p->image->r.min), zoom) : ZP;
980 drawframe(Rectangle r)
982 border(screen, r, -Borderwidth, frame, ZP);
983 gendrawdiff(screen, screen->r, insetrect(r, -Borderwidth), ground, ZP, nil, ZP, SoverD);
984 flushimage(display, 1);
994 r = rectaddpt(Rpt(ZP, pagesize(p)), addpt(pos, screen->r.min));
995 zoomdraw(screen, r, ZR, paper, i, i->r.min, zoom);
997 r = Rpt(ZP, stringsize(font, p->label));
998 r = rectaddpt(r, addpt(subpt(divpt(subpt(screen->r.max, screen->r.min), 2),
999 divpt(r.max, 2)), screen->r.min));
1000 draw(screen, r, paper, nil, ZP);
1001 string(screen, r.min, display->black, ZP, font, p->label);
1007 translate(Page *p, Point d)
1013 if(i==0 || d.x==0 && d.y==0)
1015 r = rectaddpt(Rpt(ZP, pagesize(p)), addpt(pos, screen->r.min));
1016 pos = addpt(pos, d);
1017 nr = rectaddpt(r, d);
1018 rectclip(&r, screen->r);
1019 draw(screen, rectaddpt(r, d), screen, nil, r.min);
1020 zoomdraw(screen, nr, rectaddpt(r, d), paper, i, i->r.min, zoom);
1025 findpage(char *name)
1031 /* look in current document first */
1032 if(current && current->up){
1033 for(p = current->up->down; p; p = p->next)
1034 if(cistrncmp(p->label, name, n) == 0)
1037 /* look everywhere */
1038 for(p = root->down; p; p = nextpage(p))
1039 if(cistrncmp(p->label, name, n) == 0)
1049 for(p = root->down; i > 0 && p; p = nextpage(p))
1060 for(i = 0, p = root->down; p && p != x; p = nextpage(p))
1062 return (p == x) ? i : -1;
1082 esetcursor(&reading);
1088 switch(rfork(RFPROC|RFMEM)){
1090 sysfatal("rfork: %r");
1092 loadpages(p, NAHEAD, oviewgen);
1102 for(p = nextpage(current); p; p = nextpage(p))
1103 if(p->image || p->open)
1113 for(p = prevpage(current); p; p = prevpage(p))
1114 if(p->image || p->open)
1122 char nam[64], *argv[4];
1127 esetcursor(&reading);
1129 if((fd = openpage(p)) < 0)
1131 if(rfork(RFPROC|RFMEM|RFFDG|RFENVG|RFNOTEG|RFNOWAIT) == 0){
1132 dupfds(fd, 1, 2, -1);
1133 snprint(nam, sizeof nam, "/bin/%s", argv0);
1138 sysfatal("exec: %r");
1151 lockdisplay(display);
1152 if(new && getwindow(display, Refnone) == -1)
1153 sysfatal("getwindow: %r");
1160 unlockdisplay(display);
1163 void killcohort(void)
1166 for(i=0;i!=3;i++){ /* It's a long way to the kitchen */
1167 postnote(PNGROUP, getpid(), "kill");
1172 void drawerr(Display *, char *msg)
1174 sysfatal("draw: %s", msg);
1180 fprint(2, "usage: %s [ -iRw ] [ -p ppi ] [ file ... ]\n", argv0);
1185 main(int argc, char *argv[])
1187 enum { Eplumb = 4 };
1212 ppi = atoi(EARGF(usage()));
1219 * so that we can stop all subprocesses with a note,
1220 * and to isolate rendezvous from other processes
1222 rfork(RFNOTEG|RFNAMEG|RFREND);
1224 atnotify(catchnote, 1);
1226 s = smprint("-pid %d", getpid());
1227 if(newwindow(s) < 0)
1228 sysfatal("newwindow: %r");
1231 if(initdraw(drawerr, nil, argv0) < 0)
1232 sysfatal("initdraw: %r");
1233 paper = display->white;
1234 frame = display->black;
1235 ground = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x777777FF);
1236 display->locking = 1;
1237 unlockdisplay(display);
1238 einit(Ekeyboard|Emouse);
1239 eplumb(Eplumb, "image");
1240 memset(&m, 0, sizeof(m));
1241 if((nullfd = open("/dev/null", ORDWR)) < 0)
1242 sysfatal("open: %r");
1243 current = root = addpage(nil, "", nil, nil, -1);
1245 if(*argv == nil && !imode)
1246 addpage(root, "stdin", popenfile, strdup("/fd/0"), -1);
1247 for(; *argv; argv++)
1248 addpage(root, shortname(*argv), popenfile, strdup(*argv), -1);
1254 lockdisplay(display);
1257 if(current == nil || !canqlock(current))
1262 if((m.buttons & 1) == 0)
1264 translate(current, subpt(m.xy, o));
1271 i = emenuhit(2, &m, &menu);
1272 if(i < 0 || i >= nelem(menuitems) || menuitems[i]==nil)
1276 if(strcmp(s, "orig size")==0){
1283 unlockdisplay(display);
1284 esetcursor(&reading);
1289 if(strncmp(s, "rotate ", 7)==0){
1290 rotate += atoi(s+7);
1294 if(strcmp(s, "upside down")==0){
1298 if(strcmp(s, "fit width")==0){
1301 resize = subpt(screen->r.max, screen->r.min);
1305 if(strcmp(s, "fit height")==0){
1308 resize = subpt(screen->r.max, screen->r.min);
1312 if(strncmp(s, "zoom", 4)==0){
1313 if(current && canqlock(current)){
1314 o = subpt(o, screen->r.min);
1315 if(strstr(s, "in")){
1316 if(zoom < 0x40000000){
1318 pos = addpt(mulpt(subpt(pos, o), 2), o);
1323 pos = addpt(divpt(subpt(pos, o), 2), o);
1331 if(strcmp(s, "write")==0){
1332 if(current && canqlock(current)){
1335 if(current->up && current->up != root)
1336 s = current->up->label;
1337 snprint(buf, sizeof(buf), "%s%s%s.bit",
1341 if(eenter("Write", buf, sizeof(buf), &m) > 0){
1344 if((fd = create(buf, OWRITE, 0666)) < 0){
1345 errstr(buf, sizeof(buf));
1346 eenter(buf, 0, 0, &m);
1348 esetcursor(&reading);
1349 writeimage(fd, current->image, 0);
1359 unlockdisplay(display);
1360 if(strcmp(s, "next")==0)
1362 if(strcmp(s, "prev")==0)
1364 if(strcmp(s, "zerox")==0)
1366 if(strcmp(s, "quit")==0)
1373 if(root->down == nil)
1376 pagemenu.lasthit = pageindex(current);
1377 x = pageat(emenuhit(3, &m, &pagemenu));
1379 unlockdisplay(display);
1384 unlockdisplay(display);
1408 lockdisplay(display);
1413 if(current == nil || !canqlock(current))
1415 lockdisplay(display);
1417 translate(current, Pt(0, Dy(screen->r)/2));
1418 unlockdisplay(display);
1422 unlockdisplay(display);
1424 if(prevpage(current))
1431 if(current == nil || !canqlock(current))
1433 o = addpt(pos, pagesize(current));
1434 lockdisplay(display);
1435 if(o.y > Dy(screen->r)){
1436 translate(current, Pt(0, -Dy(screen->r)/2));
1437 unlockdisplay(display);
1441 unlockdisplay(display);
1443 if(nextpage(current))
1451 if((e.kbdc < 0x20) ||
1452 (e.kbdc & 0xFF00) == KF ||
1453 (e.kbdc & 0xFF00) == Spec)
1455 snprint(buf, sizeof(buf), "%C", (Rune)e.kbdc);
1456 lockdisplay(display);
1457 i = eenter("Go to", buf, sizeof(buf), &m);
1458 unlockdisplay(display);
1460 showpage(findpage(buf));
1465 if(pm && pm->ndata > 0){
1469 s = plumblookup(pm->attr, "action");
1470 if(s && strcmp(s, "quit")==0)
1472 if(s && strcmp(s, "showdata")==0){
1473 if((fd = createtmp("plumb")) < 0){
1474 fprint(2, "plumb: createtmp: %r\n");
1478 if(fd2path(fd, s, NPATH) < 0){
1482 write(fd, pm->data, pm->ndata);
1483 }else if(pm->data[0] == '/'){
1484 s = strdup(pm->data);
1486 s = malloc(strlen(pm->wdir)+1+pm->ndata+1);
1487 sprint(s, "%s/%s", pm->wdir, pm->data);
1490 showpage(addpage(root, shortname(s), popenfile, s, fd));