9 typedef struct Page Page;
39 Image *frame, *paper, *ground;
41 char pagespool[] = "/tmp/pagespool.";
73 [Corigsize] "orig size", 'o', Kesc, 0,
74 [Czoomin] "zoom in", '+', 0, 0,
75 [Czoomout] "zoom out", '-', 0, 0,
76 [Cfitwidth] "fit width", 'f', 0, 0,
77 [Cfitheight] "fit height", 'h', 0, 0,
78 [Crotate90] "rotate 90", 'r', 0, 0,
79 [Cupsidedown] "upside down", 'u', 0, 0,
80 [Cdummy1] "", 0, 0, 0,
81 [Cnext] "next", Kright, ' ', '\n',
82 [Cprev] "prev", Kleft, Kbs, 0,
83 [Czerox] "zerox", 'z', 0, 0,
84 [Cwrite] "write", 'w', 0, 0,
85 [Cdummy2] "", 0, 0, 0,
86 [Cquit] "quit", 'q', Kdel, Keof,
89 char *pagemenugen(int i);
90 char *cmdmenugen(int i);
106 {0xff, 0x80, 0xff, 0x80, 0xff, 0x00, 0xfe, 0x00,
107 0xff, 0x00, 0xff, 0x80, 0xff, 0xc0, 0xef, 0xe0,
108 0xc7, 0xf0, 0x03, 0xf0, 0x01, 0xe0, 0x00, 0xc0,
109 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, },
110 {0x00, 0x00, 0x7f, 0x00, 0x7e, 0x00, 0x7c, 0x00,
111 0x7e, 0x00, 0x7f, 0x00, 0x6f, 0x80, 0x47, 0xc0,
112 0x03, 0xe0, 0x01, 0xf0, 0x00, 0xe0, 0x00, 0x40,
113 0x00, 0x00, 0x01, 0xb6, 0x01, 0xb6, 0x00, 0x00, }
116 void showpage(Page *);
117 void drawpage(Page *);
118 Point pagesize(Page *);
121 addpage(Page *up, char *label, int (*popen)(Page *), void *pdata, int fd)
125 p = mallocz(sizeof(*p), 1);
126 p->label = strdup(label);
140 up->down = up->tail = p;
148 if(up && current == up)
154 resizewin(Point size)
158 if((wctl = open("/dev/wctl", OWRITE)) < 0)
161 size = addpt(size, Pt(Borderwidth*2, Borderwidth*2));
163 if(size.x > Dx(display->image->r))
164 size.x = Dx(display->image->r);
165 if(size.y > Dy(display->image->r))
166 size.y = Dy(display->image->r);
168 fprint(wctl, "resize -dx %d -dy %d\n", size.x, size.y);
177 snprint(nam, sizeof nam, "%s%s%.12d%.8lux", pagespool, pfx, getpid(), id++);
178 return create(nam, OEXCL|ORCLOSE|ORDWR, 0600);
182 catchnote(void *, char *msg)
184 if(strstr(msg, "sys: write on closed pipe"))
186 if(strstr(msg, "hangup"))
188 if(strstr(msg, "alarm"))
201 for(mfd = 0; fd >= 0; fd = va_arg(arg, int), mfd++)
206 if((fd = open("/fd", OREAD)) < 0)
207 sysfatal("open: %r");
208 n = dirreadall(fd, &dir);
210 if(strstr(dir[i].name, "ctl"))
212 fd = atoi(dir[i].name);
220 pipeline(int fd, char *fmt, ...)
222 char buf[NPATH], *argv[4];
232 vsnprint(buf, sizeof buf, fmt, arg);
234 switch(rfork(RFPROC|RFMEM|RFFDG|RFREND|RFNOWAIT)){
240 dupfds(fd, pfd[1], 2, -1);
245 exec("/bin/rc", argv);
246 sysfatal("exec: %r");
257 if(x = strrchr(s, '/'))
272 if((fd = dup(p->fd, -1)) < 0){
280 pipeline(fd, "%s", (char*)p->data);
283 * dont keep the file descriptor arround if it can simply
286 fd2path(p->fd, nam, sizeof(nam));
287 if(strncmp(nam, pagespool, strlen(pagespool))){
290 p->data = strdup(nam);
302 pipeline(p->fd, "%s", (char*)p->data);
312 char mnt[32], cmd[64], *argv[4];
315 snprint(mnt, sizeof(mnt), "/n/tapefs.%.12d%.8lux", getpid(), (ulong)p);
316 snprint(cmd, sizeof(cmd), "%s -m %s /fd/0", p->data, mnt);
317 switch(rfork(RFPROC|RFMEM|RFFDG|RFREND)){
323 dupfds(p->fd, 1, 2, -1);
328 exec("/bin/rc", argv);
329 sysfatal("exec: %r");
334 p->data = strdup(mnt);
342 char buf[NPATH], *s, *e;
348 e = buf+sizeof(buf)-1;
349 s += snprint(s, e-s, "%s/", (char*)p->data);
352 pipeline(fd, "awk '/\\<rootfile/{"
353 "if(match($0, /full\\-path\\=\\\"([^\\\"]+)\\\"/)){"
354 "print substr($0, RSTART+11,RLENGTH-12);exit}}'");
355 n = read(fd, s, e - s);
359 while(n > 0 && s[n-1] == '\n')
363 if((fd = open(buf, OREAD)) < 0)
365 pipeline(fd, "awk '/\\<item/{"
366 "if(match($0, /id\\=\\\"([^\\\"]+)\\\"/)){"
367 "id=substr($0, RSTART+4, RLENGTH-5);"
368 "if(match($0, /href\\=\\\"([^\\\"]+)\\\"/)){"
369 "item[id]=substr($0, RSTART+6, RLENGTH-7)}}};"
371 "if(match($0, /idref\\=\\\"([^\\\"]+)\\\"/)){"
372 "ref=substr($0, RSTART+7, RLENGTH-8);"
373 "print item[ref]; fflush}}'");
374 s = strrchr(buf, '/')+1;
375 while((n = read(fd, s, e-s)) > 0){
376 while(n > 0 && s[n-1] == '\n')
379 addpage(p, shortname(buf), popenfile, strdup(buf), -1);
385 typedef struct Ghost Ghost;
404 switch(rfork(RFPROC|RFMEM|RFFDG|RFNOWAIT)){
412 dupfds(gs->pdat, gs->pin, pfd[1], -1);
413 fprint(1, "%s DoPDFPage\n"
416 "dup (THIS IS NOT AN INFERNO BITMAP\\n) writestring "
417 "flushfile\n", p->label);
418 while((n = read(0, buf, sizeof buf)) > 0){
419 if(memcmp(buf, "THIS IS NOT AN INFERNO BITMAP\n", 30) == 0)
431 infernobithdr(char *buf, int n)
434 if(memcmp(buf, "compressed\n", 11) == 0)
436 if(strtochan((char*)buf))
438 if(memcmp(buf, " ", 10) == 0 &&
439 '0' <= buf[10] && buf[10] <= '9' &&
449 int n, i, pdf, ifd, ofd, pin[2], pout[2], pdat[2];
450 char buf[NBUF], nam[32], *argv[16];
456 if(read(ifd, buf, 5) != 5)
459 if(memcmp(buf, "%PDF-", 5) == 0)
480 switch(rfork(RFPROC|RFMEM|RFFDG|RFREND|RFNOWAIT)){
485 dupfds(pin[1], pout[1], 2, pdat[1], ifd, -1);
487 dupfds(nullfd, nullfd, 2, pdat[1], ifd, -1);
489 pipeline(4, "%s", argv[0]);
492 argv[2] = "-sDEVICE=plan9";
493 argv[3] = "-sOutputFile=/fd/3";
495 argv[5] = pdf ? "-dDELAYSAFER" : "-dSAFER";
497 argv[7] = "-dTextAlphaBits=4";
498 argv[8] = "-dGraphicsAlphaBits=4";
499 snprint(buf, sizeof buf, "-r%d", ppi);
501 argv[10] = "-dDOINTERPOLATE";
502 argv[11] = pdf ? "-" : "/fd/4";
504 exec("/bin/gs", argv);
505 sysfatal("exec: %r");
516 "/PAGEOUT (/fd/1) (w) file def\n"
517 "/PAGE== { PAGEOUT exch write==only PAGEOUT (\\n) writestring PAGEOUT flushfile } def\n"
521 "/PDFSave null def\n"
522 "/DSCPageCount 0 def\n"
523 "/DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage } def\n"
525 "GS_PDF_ProcSet begin\n"
527 "(/fd/4) (r) file { DELAYSAFER { .setsafe } if } stopped pop pdfopen begin\n"
529 "pdfpagecount PAGE==\n";
532 if(write(pin[0], prolog, n) != n)
534 if((n = read(pout[0], buf, sizeof(buf)-1)) < 0)
542 gs = mallocz(sizeof(*gs), 1);
547 snprint(nam, sizeof nam, "%d", i);
548 addpage(p, nam, popenpdf, gs, -1);
551 /* keep ghostscript arround */
556 while((n = read(pdat[0], buf, sizeof(buf))) >= 0){
557 if(ofd >= 0 && (n <= 0 || infernobithdr(buf, n))){
558 snprint(nam, sizeof nam, "%d", i);
559 addpage(p, nam, popenimg, nil, ofd);
565 snprint(nam, sizeof nam, "%.4d", ++i);
566 if((ofd = createtmp(nam)) < 0)
567 ofd = dup(nullfd, -1);
569 if(write(ofd, buf, n) != n)
583 filetype(char *buf, int nbuf, char *typ, int ntyp)
585 int n, ifd[2], ofd[2];
588 if(infernobithdr(buf, nbuf)){
589 strncpy(typ, "image/p9bit", ntyp);
601 if(rfork(RFPROC|RFMEM|RFFDG|RFREND|RFNOWAIT) == 0){
602 dupfds(ifd[1], ofd[1], 2, -1);
606 exec("/bin/file", argv);
610 if(rfork(RFPROC|RFMEM|RFFDG|RFNOWAIT) == 0){
616 if((n = readn(ofd[0], typ, ntyp-1)) < 0)
619 while(n > 0 && typ[n-1] == '\n')
626 dircmp(void *p1, void *p2)
633 return strcmp(d1->name, d2->name);
644 "application/pdf", popengs, nil,
645 "application/postscript", popengs, nil,
646 "application/troff", popengs, "lp -dstdout",
647 "text/plain", popengs, "lp -dstdout",
648 "text/html", popengs, "uhtml | html2ms | tbl | troff -ms | lp -dstdout",
649 "application/dvi", popengs, "dvips -Pps -r0 -q1 -f1",
650 "application/doc", popengs, "doc2ps",
651 "application/zip", popentape, "fs/zipfs",
652 "application/x-tar", popentape, "fs/tarfs",
653 "application/x-ustar", popentape, "fs/tarfs",
654 "application/x-compress", popenfilter, "uncompress",
655 "application/x-gzip", popenfilter, "gunzip",
656 "application/x-bzip2", popenfilter, "bunzip2",
657 "image/gif", popenimg, "gif -t9",
658 "image/jpeg", popenimg, "jpg -t9",
659 "image/png", popenimg, "png -t9",
660 "image/ppm", popenimg, "ppm -t9",
661 "image/bmp", popenimg, "bmp -t9",
662 "image/p9bit", popenimg, nil,
665 char buf[NBUF], typ[128], *file;
674 if((fd = open(file, OREAD)) < 0){
681 if((d = dirfstat(fd)) == nil){
690 snprint(buf, sizeof(buf), "%s/META-INF/container.xml", file);
691 if((tfd = open(buf, OREAD)) >= 0){
699 if((n = dirreadall(fd, &d)) < 0)
701 qsort(d, n, sizeof d[0], dircmp);
703 addpage(p, d[i].name, popenfile, smprint("%s/%s", file, d[i].name), -1);
709 memset(buf, 0, NBUF/2);
710 if((n = readn(fd, buf, NBUF/2)) <= 0)
712 filetype(buf, n, typ, sizeof(typ));
713 for(i=0; i<nelem(tab); i++)
714 if(strncmp(typ, tab[i].typ, strlen(tab[i].typ)) == 0)
717 werrstr("unknown image format: %s", typ);
721 p->data = tab[i].data;
722 p->open = tab[i].open;
723 if(seek(fd, 0, 0) < 0)
725 if((i = readn(fd, buf+n, n)) < 0)
727 if(i != n || memcmp(buf, buf+n, i)){
730 if((tfd = createtmp("file")) < 0)
733 if(write(tfd, buf, n) != n)
735 if((n = read(fd, buf, sizeof(buf))) < 0)
738 if(dup(tfd, fd) < 0){
768 for(p = root->down; p; p = t)
769 if((t = nextpage(p)) == x)
781 if(p->open == nil || (fd = p->open(p)) < 0)
785 pipeline(fd, "rotate -r %d", rotate);
787 pipeline(fd, "resize -x %d", resize.x);
789 pipeline(fd, "resize -y %d", resize.y);
799 if(p->open && p->image == nil){
800 if((fd = openpage(p)) >= 0){
802 if((p->image = readimage(display, fd, 1)) == nil)
803 fprint(2, "readimage: %r\n");
815 if(p->open == nil || p->image == nil)
817 lockdisplay(display);
819 unlockdisplay(display);
828 for(p = root->down; p; p = nextpage(p)){
829 if(age == 0) /* synchronous flush */
831 else if(!canqlock(p))
833 if((pagegen - p->gen) >= age)
840 loadpages(Page *p, int ahead, int oviewgen)
844 ahead++; /* load at least one */
845 unloadpages(ahead*2);
846 for(i = 0; i < ahead && p; p = nextpage(p), i++){
847 if(viewgen != oviewgen)
851 if(viewgen != oviewgen){
861 if(size.x && size.y && newwin){
865 lockdisplay(display);
867 unlockdisplay(display);
875 * A draw operation that touches only the area contained in bot but not in top.
876 * mp and sp get aligned with bot.min.
879 gendrawdiff(Image *dst, Rectangle bot, Rectangle top,
880 Image *src, Point sp, Image *mask, Point mp, int op)
886 if(Dx(bot)*Dy(bot) == 0)
889 /* no points in bot - top */
890 if(rectinrect(bot, top))
893 /* bot - top ≡ bot */
894 if(Dx(top)*Dy(top)==0 || rectXrect(bot, top)==0){
895 gendrawop(dst, bot, src, sp, mask, mp, op);
900 /* split bot into rectangles that don't intersect top */
902 if(bot.min.x < top.min.x){
903 r = Rect(bot.min.x, bot.min.y, top.min.x, bot.max.y);
904 delta = subpt(r.min, origin);
905 gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
906 bot.min.x = top.min.x;
910 if(bot.max.x > top.max.x){
911 r = Rect(top.max.x, bot.min.y, bot.max.x, bot.max.y);
912 delta = subpt(r.min, origin);
913 gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
914 bot.max.x = top.max.x;
918 if(bot.min.y < top.min.y){
919 r = Rect(bot.min.x, bot.min.y, bot.max.x, top.min.y);
920 delta = subpt(r.min, origin);
921 gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
922 bot.min.y = top.min.y;
926 if(bot.max.y > top.max.y){
927 r = Rect(bot.min.x, top.max.y, bot.max.x, bot.max.y);
928 delta = subpt(r.min, origin);
929 gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
930 bot.max.y = top.max.y;
935 alphachan(ulong chan)
937 for(; chan; chan >>= 8)
938 if(TYPE(chan) == CAlpha)
944 zoomdraw(Image *d, Rectangle r, Rectangle top, Image *b, Image *s, Point sp, int f)
952 if(r.min.x < d->r.min.x){
953 sp.x += (d->r.min.x - r.min.x)/f;
954 a.x = (d->r.min.x - r.min.x)%f;
955 r.min.x = d->r.min.x;
957 if(r.min.y < d->r.min.y){
958 sp.y += (d->r.min.y - r.min.y)/f;
959 a.y = (d->r.min.y - r.min.y)%f;
960 r.min.y = d->r.min.y;
963 w = s->r.max.x - sp.x;
967 dr.max.x = dr.min.x+w;
968 if(!alphachan(s->chan))
971 if(b) gendrawdiff(d, dr, top, b, sp, nil, ZP, SoverD);
972 gendrawdiff(d, dr, top, s, sp, nil, ZP, SoverD);
975 if((t = allocimage(display, dr, s->chan, 0, 0)) == nil)
977 for(; dr.min.y < r.max.y; dr.min.y++){
978 dr.max.y = dr.min.y+1;
979 draw(t, dr, s, nil, sp);
986 for(sp=dr.min; dr.min.x < r.max.x; sp.x++){
987 dr.max.x = dr.min.x+1;
988 if(b) gendrawdiff(d, dr, top, b, sp, nil, ZP, SoverD);
989 gendrawdiff(d, dr, top, t, sp, nil, ZP, SoverD);
990 for(dr.min.x++; ++a.x < f && dr.min.x < r.max.x; dr.min.x++){
991 dr.max.x = dr.min.x+1;
992 gendrawdiff(d, dr, top, d, Pt(dr.min.x-1, dr.min.y), nil, ZP, SoverD);
1002 return p->image ? mulpt(subpt(p->image->r.max, p->image->r.min), zoom) : ZP;
1006 drawframe(Rectangle r)
1008 border(screen, r, -Borderwidth, frame, ZP);
1009 gendrawdiff(screen, screen->r, insetrect(r, -Borderwidth), ground, ZP, nil, ZP, SoverD);
1010 flushimage(display, 1);
1020 r = rectaddpt(Rpt(ZP, pagesize(p)), addpt(pos, screen->r.min));
1021 zoomdraw(screen, r, ZR, paper, i, i->r.min, zoom);
1023 r = Rpt(ZP, stringsize(font, p->label));
1024 r = rectaddpt(r, addpt(subpt(divpt(subpt(screen->r.max, screen->r.min), 2),
1025 divpt(r.max, 2)), screen->r.min));
1026 draw(screen, r, paper, nil, ZP);
1027 string(screen, r.min, display->black, ZP, font, p->label);
1033 translate(Page *p, Point d)
1039 if(i==0 || d.x==0 && d.y==0)
1041 r = rectaddpt(Rpt(ZP, pagesize(p)), addpt(pos, screen->r.min));
1042 pos = addpt(pos, d);
1043 nr = rectaddpt(r, d);
1044 rectclip(&r, screen->r);
1045 draw(screen, rectaddpt(r, d), screen, nil, r.min);
1046 zoomdraw(screen, nr, rectaddpt(r, d), paper, i, i->r.min, zoom);
1051 findpage(char *name)
1057 /* look in current document first */
1058 if(current && current->up){
1059 for(p = current->up->down; p; p = p->next)
1060 if(cistrncmp(p->label, name, n) == 0)
1063 /* look everywhere */
1064 for(p = root->down; p; p = nextpage(p))
1065 if(cistrncmp(p->label, name, n) == 0)
1075 for(p = root->down; i > 0 && p; p = nextpage(p))
1086 for(i = 0, p = root->down; p && p != x; p = nextpage(p))
1088 return (p == x) ? i : -1;
1103 if(i < 0 || i >= nelem(cmds))
1116 esetcursor(&reading);
1122 switch(rfork(RFPROC|RFMEM)){
1124 sysfatal("rfork: %r");
1126 loadpages(p, NAHEAD, oviewgen);
1136 for(p = nextpage(current); p; p = nextpage(p))
1137 if(p->image || p->open)
1147 for(p = prevpage(current); p; p = prevpage(p))
1148 if(p->image || p->open)
1156 char nam[64], *argv[4];
1161 esetcursor(&reading);
1163 if((fd = openpage(p)) < 0)
1165 if(rfork(RFPROC|RFMEM|RFFDG|RFENVG|RFNOTEG|RFNOWAIT) == 0){
1166 dupfds(fd, 1, 2, -1);
1167 snprint(nam, sizeof nam, "/bin/%s", argv0);
1172 sysfatal("exec: %r");
1185 lockdisplay(display);
1186 if(new && getwindow(display, Refnone) == -1)
1187 sysfatal("getwindow: %r");
1194 unlockdisplay(display);
1198 void killcohort(void)
1201 for(i=0;i!=3;i++){ /* It's a long way to the kitchen */
1202 postnote(PNGROUP, cohort, "kill");
1207 void drawerr(Display *, char *msg)
1209 sysfatal("draw: %s", msg);
1215 fprint(2, "usage: %s [ -iRw ] [ -p ppi ] [ file ... ]\n", argv0);
1220 docmd(int i, Mouse *m)
1222 char buf[NPATH], *s;
1234 unlockdisplay(display);
1235 esetcursor(&reading);
1248 resize = subpt(screen->r.max, screen->r.min);
1254 resize = subpt(screen->r.max, screen->r.min);
1259 if(current == nil || !canqlock(current))
1261 o = subpt(m->xy, screen->r.min);
1263 if(zoom < 0x40000000){
1265 pos = addpt(mulpt(subpt(pos, o), 2), o);
1270 pos = addpt(divpt(subpt(pos, o), 2), o);
1277 if(current == nil || !canqlock(current))
1281 if(current->up && current->up != root)
1282 s = current->up->label;
1283 snprint(buf, sizeof(buf), "%s%s%s.bit",
1287 if(eenter("Write", buf, sizeof(buf), m) > 0){
1288 if((fd = create(buf, OWRITE, 0666)) < 0){
1289 errstr(buf, sizeof(buf));
1290 eenter(buf, 0, 0, m);
1292 esetcursor(&reading);
1293 writeimage(fd, current->image, 0);
1302 unlockdisplay(display);
1306 unlockdisplay(display);
1310 unlockdisplay(display);
1320 main(int argc, char *argv[])
1322 enum { Eplumb = 4 };
1347 ppi = atoi(EARGF(usage()));
1354 * so that we can stop all subprocesses with a note,
1355 * and to isolate rendezvous from other processes
1357 atnotify(catchnote, 1);
1358 if(cohort = rfork(RFPROC|RFNOTEG|RFNAMEG|RFREND)){
1367 s = smprint("-pid %d", getpid());
1368 if(newwindow(s) < 0)
1369 sysfatal("newwindow: %r");
1372 if(initdraw(drawerr, nil, argv0) < 0)
1373 sysfatal("initdraw: %r");
1374 paper = display->white;
1375 frame = display->black;
1376 ground = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x777777FF);
1377 display->locking = 1;
1378 unlockdisplay(display);
1379 einit(Ekeyboard|Emouse);
1380 eplumb(Eplumb, "image");
1381 memset(&m, 0, sizeof(m));
1382 if((nullfd = open("/dev/null", ORDWR)) < 0)
1383 sysfatal("open: %r");
1384 current = root = addpage(nil, "", nil, nil, -1);
1386 if(*argv == nil && !imode)
1387 addpage(root, "stdin", popenfile, strdup("/fd/0"), -1);
1388 for(; *argv; argv++)
1389 addpage(root, shortname(*argv), popenfile, strdup(*argv), -1);
1395 lockdisplay(display);
1398 if(current && canqlock(current)){
1402 if((m.buttons & 1) == 0)
1404 translate(current, subpt(m.xy, o));
1408 } else if(m.buttons & 2){
1410 i = emenuhit(2, &m, &cmdmenu);
1414 } else if(m.buttons & 4){
1419 pagemenu.lasthit = pageindex(current);
1420 x = pageat(emenuhit(3, &m, &pagemenu));
1422 unlockdisplay(display);
1427 unlockdisplay(display);
1430 lockdisplay(display);
1433 if(current == nil || !canqlock(current))
1436 translate(current, Pt(0, Dy(screen->r)/2));
1440 if(prevpage(current))
1443 if(!docmd(Cprev, &m))
1447 if(current == nil || !canqlock(current))
1449 o = addpt(pos, pagesize(current));
1450 if(o.y > Dy(screen->r)){
1451 translate(current, Pt(0, -Dy(screen->r)/2));
1455 if(nextpage(current))
1458 if(!docmd(Cnext, &m))
1462 for(i = 0; i<nelem(cmds); i++)
1463 if((cmds[i].k1 == e.kbdc) ||
1464 (cmds[i].k2 == e.kbdc) ||
1465 (cmds[i].k3 == e.kbdc))
1467 if(i < nelem(cmds)){
1472 if((e.kbdc < 0x20) ||
1473 (e.kbdc & 0xFF00) == KF ||
1474 (e.kbdc & 0xFF00) == Spec)
1476 snprint(buf, sizeof(buf), "%C", (Rune)e.kbdc);
1477 i = eenter("Go to", buf, sizeof(buf), &m);
1479 unlockdisplay(display);
1480 showpage(findpage(buf));
1484 unlockdisplay(display);
1488 if(pm && pm->ndata > 0){
1492 s = plumblookup(pm->attr, "action");
1493 if(s && strcmp(s, "quit")==0)
1495 if(s && strcmp(s, "showdata")==0){
1496 if((fd = createtmp("plumb")) < 0){
1497 fprint(2, "plumb: createtmp: %r\n");
1501 if(fd2path(fd, s, NPATH) < 0){
1505 write(fd, pm->data, pm->ndata);
1506 }else if(pm->data[0] == '/'){
1507 s = strdup(pm->data);
1509 s = malloc(strlen(pm->wdir)+1+pm->ndata+1);
1510 sprint(s, "%s/%s", pm->wdir, pm->data);
1513 showpage(addpage(root, shortname(s), popenfile, s, fd));