*** /home/newswin/NeWS1.1/clientsrc/client/psview.c Mon Feb 22 19:00:44 1988 --- psview.c Thu Sep 21 10:03:48 1989 *************** *** 61,66 **** --- 61,67 ---- static int box = 1; static int recolor; static int ditroff = 0; + static int dvips = 0; static int direction; struct point { *************** *** 213,218 **** --- 214,220 ---- } while (fgets(line, sizeof line, f)) if (line[0] == '%') + { if (line[1] == '%') switch (line[2]) { /*- case 'E': *************** *** 220,226 **** EndProlog = ftell(f); break; */ case 'P': ! if (strncmp(line + 3, "age:", 4) == 0) { if (npages >= psize) { if (psize) pagestart = (int *) realloc(pagestart, (psize = npages * 3 / 2) * sizeof(int)); --- 222,229 ---- EndProlog = ftell(f); break; */ case 'P': ! if ((strncmp(line + 3, "age", 3) == 0) && ! (line[6] != 's')) { if (npages >= psize) { if (psize) pagestart = (int *) realloc(pagestart, (psize = npages * 3 / 2) * sizeof(int)); *************** *** 236,242 **** break; } else if (line[1] == ' ' && line[2] == 'l' && strncmp(line, "% lib/psdit.pro", 15) == 0) ! ditroff = 1; if (npages > 0) { if (EndProlog < 0 || pagestart[0] < EndProlog) EndProlog = pagestart[0]; --- 239,248 ---- break; } else if (line[1] == ' ' && line[2] == 'l' && strncmp(line, "% lib/psdit.pro", 15) == 0) ! ditroff = 1; ! else if (line[1] == ' ' && line[3] == 'D' && strncmp(line, "% Dvips.pro", 12) == 0) ! dvips = 1; ! } if (npages > 0) { if (EndProlog < 0 || pagestart[0] < EndProlog) EndProlog = pagestart[0]; *************** *** 287,293 **** ps_startpage(); PumpBytes(f, pagestart[n], pagestart[n + 1]); ps_endpage(); ! if (notfirst) ps_damageall(); notfirst = 1; --- 293,299 ---- ps_startpage(); PumpBytes(f, pagestart[n], pagestart[n + 1]); ps_endpage(); ! /* if (notfirst)*/ ps_damageall(); notfirst = 1; *************** *** 325,343 **** ps_defBG(); } } - if (EndProlog > 0) { - ps_startprolog(); - PumpBytes(f, 0, EndProlog); - ps_endprolog(); - } - if (ditroff) - ps_ditroff_fix(); if (npages < 2) make_MIN_MAX(); if (npages >= 2) make_MAX(); ! GotoPage(f, 0); { char buf[100]; #ifndef SYSVREF --- 331,346 ---- ps_defBG(); } } if (npages < 2) make_MIN_MAX(); if (npages >= 2) make_MAX(); ! if (EndProlog > 0 && !dvips) { ! ps_startprolog(); ! PumpBytes(f, 0, EndProlog); ! ps_endprolog(); ! } { char buf[100]; #ifndef SYSVREF *************** *** 354,359 **** --- 357,372 ---- *dest++ = 0; ps_setupwindow(buf[0] ? buf : "Preview"); } + if (EndProlog > 0 && dvips) { + ps_dvips_fix(); + ps_startprolog(); + PumpBytes(f, 0, EndProlog); + ps_endprolog(); + } + if (ditroff) + ps_ditroff_fix(); + ps_prolog_done(); + GotoPage(f, 0); while (!psio_error(PostScriptInput) && !psio_eof(PostScriptInput)) if (get_page_selection(&page_selection)) GotoPage(f, page_selection - 1); *************** *** 367,377 **** char *filename = 0; /* The file to be previewed */ char *tempname = 0; /* The name of a temporary file, if we created * one */ ProgramName = argv[0]; ! if (argv[1] == NULL) { printf("%s: Requires PostScript filename.\n",ProgramName ); exit(0); ! } while (--argc > 0) if ((++argv)[0][0] == '-') switch (argv[0][1]) { --- 380,393 ---- char *filename = 0; /* The file to be previewed */ char *tempname = 0; /* The name of a temporary file, if we created * one */ + char asize; /* the size of A? paper */ + short temp; /* for swapping sizes */ + ProgramName = argv[0]; ! /*- if (argv[1] == NULL) { printf("%s: Requires PostScript filename.\n",ProgramName ); exit(0); ! } */ while (--argc > 0) if ((++argv)[0][0] == '-') switch (argv[0][1]) { *************** *** 390,395 **** --- 406,442 ---- ProgramName, argv[0]); exit(-1); } + break; + case 'a': + case 'A': + asize = argv[0][2]; + if (asize < '0' || asize > '5') { + fprintf(stderr, "%s: Bad page size `%s'\n", ProgramName, argv[0]); + exit(-1); + } + size.x = 2381; + size.y = 3368; + while (asize-- > '0') { + short temp; + temp = size.y; + size.y = size.x; + size.x = temp / 2; + } + switch (argv[0][3]) { + case 'L': + case 'l': + temp = size.x; size.x = size.y; size.y = temp; + break; + case 'P': + case 'p': + case '\0': + break; + default: + fprintf(stderr, "%s: Bad page orientation `%s'\n", ProgramName, argv[0]); + exit(-1); + } + center.x = size.x / 2; + center.y = size.y / 2; break; case 'b': if (!parse_color(&argv[0][2], &FGBG[1])) {