home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume15 / ps.sun.pch < prev    next >
Text File  |  1988-06-07  |  23KB  |  744 lines

  1. Subject:  v15i049:  Module to make postscript interpreter work under Suntools
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Rick Lindsley <richl@penguin.uss.tek.com>
  7. Posting-number: Volume 15, Issue 49
  8. Archive-name: ps.sun.pch
  9.  
  10. [  I haven't tried this.  --r$  ]
  11.  
  12. The following is a file which can be added to the previously posted
  13. Postscript interpreter which will allow it to run under Suntools
  14. (instead of *over* Suntools :) ) The file pixwin.README describes how
  15. to add it into the package, and what special things need to be done
  16. to make it run.
  17.  
  18. The previous version worked by simply blatting to the screen. This now
  19. runs in a window.
  20.  
  21. Rick Lindsley
  22. richl@penguin.uss.tek.com
  23.  
  24. # This is a shell archive.  Remove anything before this line, then
  25. # unpack it by saving it in a file and typing "sh file".  (Files
  26. # unpacked will be owned by you and have default permissions.)
  27. #
  28. # This archive contains:
  29. # pixwin.c pixwin.README ps.empty ps.full
  30.  
  31. echo x - pixwin.c
  32. cat > "pixwin.c" << '//E*O*F pixwin.c//'
  33. /*
  34.  * Copyright (C) Rutherford Appleton Laboratory 1987, All Rights Reserved.
  35.  * 
  36.  * This source may be copied, distributed, altered or used, but not sold
  37.  * for profit or incorporated into a product except under licence from the
  38.  * author.
  39.  * It is not in the public domain.
  40.  * This notice should remain in the source unaltered, and any changes to
  41.  * the source made by persons other than the author should be marked as such.
  42.  * 
  43.  *    Crispin Goswell @ Rutherford Appleton Laboratory caag@uk.ac.rl.vd
  44.  */
  45.  
  46. #include "main.h"
  47. #include "graphics.h"
  48. #include "canon.h"
  49. #include <pixrect/pixrect_hs.h>
  50. #include <suntool/sunview.h>
  51. #include <suntool/canvas.h>
  52. #include <suntool/frame.h>
  53.  
  54. /*
  55.  * Major changes. Rick Lindsley, richl@tektronix.tek.com, 3/9/88.
  56.  * Disclaimers and restrictions as outlined above.
  57.  *
  58.  * Driver to work with(in) Suntools. Should produce black & white images
  59.  * just peachy. Anything with color or gray-scaling is untested.
  60.  *
  61.  * Note! To make this work properly, you must redefine showpage in your
  62.  * ~/.postscript file! The definition is thus:
  63.  *
  64.  * /showpage { copypage initgraphics flush erasepage } def
  65.  *
  66.  * Otherwise, every showpage will beep nastily at you and require
  67.  * response in TWO windows!
  68.  *
  69.  * Philosophy (for those who follow in my footsteps)
  70.  *
  71.  * Short version: Suntools is ok to work with from scratch, but it is a
  72.  *    royal PAIN to "hook in". It CAN be done; however, one needs to
  73.  *    read the "advanced" manuals.
  74.  *
  75.  * Long version: The trick is to set up a window, display it, and process
  76.  *    events that happen in that window, and do that asynchronously from
  77.  *    the PostScript interpreter that is running. It turns out that you
  78.  *    CAN'T do that (it would require two processes to provide two threads
  79.  *    of control), so the next best thing is to give it the APPEARANCE of
  80.  *    asynchronicity. This is accomplished by giving the Notifier, which
  81.  *    presents all window and input events to us, a nudge now and then.
  82.  *    (Because the documentation constantly gives me the impression that
  83.  *    it is non-conformist to not allow the Notifier to do the work for
  84.  *    us, and that the Notifier knows what is best, I've taken to calling
  85.  *    it Hal in the comments below.)
  86.  *
  87.  *    At times (see HardUpdate) we can allow the Notifier to behave almost
  88.  *    as a normal Suntool (taking control and calling our event procedures
  89.  *    when appropriate), because we are waiting on the user and are willing
  90.  *    to be event-driven, but most of the time we give it one shot, at times
  91.  *    of our convenience, to present us with events. Thus, in all the
  92.  *    hardware-specific routines listed here, DoDispatch is called once
  93.  *    in each function. DoDispatch checks for a few simple conditions
  94.  *    (like, was the window destroyed underneath us?) and then calls the
  95.  *    Notifier *once*. If there is a stretch in the Interpreter where no
  96.  *    hardware-specific routines are called, the window may appear to
  97.  *    "hang" or be sluggish at those points in the code because the Notifier
  98.  *    will not be poked to provide support for events. (They ARE queued,
  99.  *    though, and will occur, in sequence, when the Notifier is poked!)
  100.  *
  101.  *    Our event handler, STWinEvent, is fairly simple, because all it ever
  102.  *    cares about is mouse events, and only at fairly well-defined times.
  103.  *    All other events can be handled by the default actions Suntools
  104.  *    provides.
  105.  *
  106.  *    Two icons are provided as niceties. An empty scroll denotes the
  107.  *    page is being filled yet. A scroll with writing indicates the page
  108.  *    is full and the Interpreter is waiting for an ok to continue to
  109.  *    the next page. The frame label also indicates this change in
  110.  *    condition.
  111.  *
  112.  *    Numerous bells and whistles are possible, given this minimum. They
  113.  *    are left as an exercise for the reader.
  114.  *
  115.  *    This code based on pixrect.c, provided with the original software.
  116.  */
  117.  
  118. static short wi_image[] = {
  119. #include "ps.empty"
  120. };
  121. DEFINE_ICON_FROM_IMAGE(working_icon,wi_image);
  122.  
  123. static short fi_image[] = {
  124. #include "ps.full"
  125. };
  126. DEFINE_ICON_FROM_IMAGE(ready_icon,fi_image);
  127.  
  128. #define PG_WAITING    0    /* still processing a page        */
  129. #define PG_ADVANCE    1    /* page done; user ok'ed us to start on    */
  130.                 /* the next page            */
  131. #define PG_DESTROYED    2    /* window is already destroyed! Data    */
  132.                 /* structures are probably meaningless.    */
  133.                 /* Exit at next opportunity.        */
  134.  
  135. int rop_map [] =
  136.  {
  137.      PIX_SRC & PIX_NOT (PIX_SRC),
  138.      PIX_SRC & PIX_DST,
  139.      PIX_SRC & PIX_NOT (PIX_DST),
  140.      PIX_SRC,
  141.      PIX_NOT (PIX_SRC) & PIX_DST,
  142.      PIX_DST,
  143.      PIX_SRC ^ PIX_DST,
  144.      PIX_SRC | PIX_DST,
  145.      PIX_NOT (PIX_SRC | PIX_DST),
  146.      PIX_NOT (PIX_SRC ^ PIX_DST),
  147.      PIX_NOT (PIX_DST),
  148.      PIX_SRC | PIX_NOT (PIX_DST),
  149.      PIX_NOT (PIX_SRC),
  150.      PIX_NOT (PIX_SRC) | PIX_DST,
  151.      PIX_NOT (PIX_SRC & PIX_DST),
  152.      PIX_SRC | PIX_NOT (PIX_SRC)
  153.  };
  154.  
  155. /*
  156.  * Suntools global variables and routines were given names beginning with
  157.  * ST whenever possible, for ease in recognizing them.
  158.  */
  159. Frame    STFrame;
  160. Canvas    STCanvas;
  161. Pixwin*    STScreen;
  162. Menu    STPageMenu, STJustQuit;
  163. char    STPageStatus = PG_ADVANCE;
  164.  
  165.  
  166. char *malloc ();
  167.  
  168. struct hardware *NewHardware ();
  169.  
  170. struct hardware *InitHardware ()
  171. {
  172.     InitTransfer (80);    /* XXX */
  173.     return NULL;
  174. }
  175.  
  176. /*
  177.  * NewWindowHardware() --    we take this opportunity to create our
  178.  *                window. By specifying WIN_SHOW to be true,
  179.  *                we can make it appear nearly immediately. To
  180.  *                be less alarming, it appears first as an icon.
  181.  */
  182. struct hardware *NewWindowHardware (width, height)
  183. int width, height;
  184. {
  185.     DevicePoint real_extent;
  186.     int STWinEvent();
  187.     Notify_value STDestroyEvent();
  188.     
  189.     STFrame = window_create(0,FRAME,
  190.     FRAME_LABEL, "Postscript display window",
  191.     FRAME_CLOSED, TRUE,
  192.     FRAME_ICON, &working_icon,
  193.     WIN_HEIGHT, height,
  194.     WIN_WIDTH, width,
  195.     WIN_SHOW, TRUE,
  196.     WIN_Y, 0,
  197.     0);
  198.     STCanvas = window_create(STFrame,CANVAS,
  199.     WIN_EVENT_PROC, STWinEvent,
  200.     0);
  201.     STScreen = canvas_pixwin(STCanvas);
  202.     STPageMenu = menu_create(MENU_STRINGS, "Next page", "Quit", 0, 0);
  203.     STJustQuit = menu_create(MENU_STRINGS, "Quit", 0, 0);
  204.     /*
  205.      * we will want to know if the user destroys the window
  206.      */
  207.     notify_interpose_destroy_func(STFrame,STDestroyEvent);
  208.  
  209.     /*
  210.      * sigh. Suntools, somewhere, must do a TIOCSPGRP; that is, resets
  211.      * its process group. This causes all sorts of nasties to happen
  212.      * if the Interpreter wants to print error messages while this process
  213.      * is in the background, not the least of which is suddenly stopping
  214.      * with no way (short of ps(1)) to restart it. So, for now, this must
  215.      * ignore SIGTTOU signals, and blat right on the screen. (Or stderr
  216.      * must be redirected.)
  217.      */
  218.     (void) signal(SIGTTOU,SIG_IGN);        /* XXX SUNTOOLS HACK XXX */
  219.  
  220.     real_extent = NewDevicePoint (width, height);
  221.     
  222.     return NewHardware (STScreen, real_extent, ISWIN);
  223. }
  224.  
  225. struct hardware *NewBitmapHardware (width, height)
  226. int width, height;
  227. {
  228.     DevicePoint real_extent;
  229.     struct pixrect *bm;
  230.     
  231.     real_extent = NewDevicePoint (width, height);
  232.     
  233.     if ((bm = mem_create (width, height, 1)) == NULL) {
  234.     fprintf (stderr, "mem_create (%d, %d, 1)\n", width, height);
  235.     Panic ("failed to create bitmap");
  236.     }
  237.     
  238.     return NewHardware (bm, real_extent, 0);
  239. }
  240.  
  241. /* 
  242.  * The hardware structure can contain pointers to pixrects, if they were
  243.  * created by NewBitmapHardware, or to a pixwin, if it was created by a
  244.  * new window. Why the difference? Pixwin routines will do clipping for
  245.  * us, if the window is covered or closed or whatever.
  246.  */
  247. #define Pixrect_addr(h)    ((Pixrect *) ((h)->hard.addr))
  248. #define Pixwin_addr(h)    ((Pixwin *) ((h)->hard.addr))
  249.  
  250. static void DestroyHard (dev)
  251. struct hardware *dev;
  252. {
  253.     Pixrect *bm;
  254.     
  255.     if (dev->flags == ISWIN)
  256.     window_done(STFrame);
  257.     else if (bm) {
  258.     bm = Pixrect_addr (dev);
  259.     pr_destroy (bm);
  260.     }
  261. }
  262.  
  263. void DestroyHardware (dev) struct hardware *dev;
  264. {
  265.     DoDispatch();
  266.     if (dev == NULL) return;
  267.     DestroyHard (dev);
  268.     if (dev->aux) DestroyHardware (dev->aux);
  269.     Free ((char *) dev);
  270. }
  271.  
  272. static struct hardware *NewHardware (addr, extent, flags)
  273. struct pixrect *addr;
  274. DevicePoint extent;
  275. int flags;
  276. {
  277.     struct hardware *d = (struct hardware *) Malloc (sizeof (struct hardware));
  278.     
  279.     d->flags = flags;
  280.     d->hard.addr = (char *) addr;
  281.     d->aux = d->clip = NULL;
  282.     d->extent = extent;
  283.     DoDispatch();
  284.     
  285.     return d;
  286. }
  287.  
  288. struct hardware *HardwareFromString (s, width, height)
  289. unsigned char *s;
  290. int width, height;
  291. {
  292.     int words = (width + 15) / 16;
  293.     Pixrect *pr = mem_create (width, height, 1);
  294.     short *d = mpr_d (pr)->md_image;
  295.     int odd = ((width + 7) / 8) & 1;
  296.     int i, j;
  297.  
  298.     for (i = 0; i < height; i++) {
  299.     for (j = 0; j < words - odd; j++) {
  300.         short word = *s++;
  301.  
  302.         *d++ = (word << 8) | *s++;
  303.         }
  304.     if (odd) *d++ = *s++ << 8;
  305.     }
  306.     return NewHardware (pr, NewDevicePoint (width, height), 0);
  307. }
  308.  
  309. char *StringFromHardware (h)
  310. struct hardware *h;
  311. {
  312.     int words = (h->extent.dx + 15) / 16;
  313.     char *string = malloc ((h->extent.dx + 7) / 8 * h->extent.dy), *s = string;
  314.     int i, j, odd = ((h->extent.dx + 7) / 8) & 1;
  315.     short *d;
  316.     
  317.     DoDispatch();
  318.     if (h->flags & ISWIN)
  319.     d = mpr_d (Pixwin_addr(h)->pw_prretained)->md_image;
  320.     else
  321.     d = mpr_d (Pixrect_addr (h))->md_image;
  322.     for (i = 0; i < h->extent.dy; i++) {
  323.     for (j = 0; j < words - odd; j++) {
  324.         short word = *d++;
  325.  
  326.         *s++ = (word >> 8) & 0xFF;
  327.         *s++ = word & 0xFF;
  328.         }
  329.     if (odd) *s++ = (*d++ >> 8) & 0xFF;
  330.     }
  331.     return string;
  332. }
  333.  
  334. void UpdateControl (h, flag) struct hardware *h; int flag;
  335. {
  336. }
  337.  
  338. void RasterTile (from, to, toPoint, extent, rop)
  339.     struct hardware *from, *to;
  340.     DevicePoint toPoint, extent;
  341.     int rop;
  342. {
  343.     Pixrect *fr;
  344.     
  345.     DoDispatch();
  346.     if (to == NULL || extent.dx == 0 || extent.dy == 0) return;
  347.  
  348.     if (from)
  349.     if (from->flags & ISWIN)
  350.         fr = Pixwin_addr(from)->pw_prretained;
  351.     else
  352.         fr = Pixrect_addr(from);
  353.     else
  354.     fr = NULL;
  355.     
  356.     if (to->flags & ISWIN)
  357.     pw_replrop (Pixwin_addr (to), toPoint.dx, toPoint.dy, extent.dx,
  358.         extent.dy, rop_map [rop], fr, toPoint.dx, toPoint.dy);
  359.     else
  360.     pr_replrop (Pixrect_addr (to), toPoint.dx, toPoint.dy, extent.dx,
  361.         extent.dy, rop_map [rop], fr, toPoint.dx, toPoint.dy);
  362. }
  363.  
  364. void BitBlt (from, to, fromPoint, toPoint, extent, rop)
  365. struct hardware *from, *to;
  366. DevicePoint fromPoint, toPoint, extent;
  367. int rop;
  368. {
  369.     Pixrect *fr;
  370.     
  371.     DoDispatch();
  372.     if (to == NULL || extent.dx == 0 || extent.dy == 0) return;
  373.         
  374.     if (from)
  375.     if (from->flags & ISWIN)
  376.         fr = Pixwin_addr(from)->pw_prretained;
  377.     else
  378.         fr = Pixrect_addr(from);
  379.     else {
  380.     fr = NULL;
  381.     rop = single_rop [rop];
  382.     }
  383.     
  384.     if (to->flags & ISWIN)
  385.     pw_rop (Pixwin_addr (to), toPoint.dx, toPoint.dy, extent.dx,
  386.         extent.dy, rop_map [rop], fr, fromPoint.dx, fromPoint.dy);
  387.     else
  388.     pr_rop (Pixrect_addr (to), toPoint.dx, toPoint.dy, extent.dx,
  389.         extent.dy, rop_map [rop], fr, fromPoint.dx, fromPoint.dy);
  390. }
  391.  
  392. void BitBltLine (h, fromPoint, toPoint, rop) 
  393. struct hardware *h;
  394. DevicePoint fromPoint, toPoint;
  395. int rop;
  396. {
  397.     DoDispatch();
  398.     if (h == NULL)
  399.         return;
  400.     
  401.     switch (single_rop [rop]) {
  402.     case ROP_FALSE:        rop = PIX_NOT (PIX_SET);    break;
  403.     case ROP_TRUE:        rop = PIX_SET;            break;
  404.     case ROP_NOTDEST:    rop = PIX_NOT (PIX_SRC);    break;
  405.     case ROP_DEST:        return;                break;
  406.     
  407.     default:    fprintf (stderr, "illegal rasterop\n"); exit (1);
  408.     }
  409.     
  410.     if (h->flags & ISWIN)
  411.     pw_vector (Pixwin_addr (h), fromPoint.dx, fromPoint.dy,
  412.         toPoint.dx, toPoint.dy, rop, ~0);
  413.     else
  414.     pr_vector (Pixrect_addr (h), fromPoint.dx, fromPoint.dy,
  415.         toPoint.dx, toPoint.dy, rop, ~0);
  416. }
  417.  
  418. void BitBltBlob (to, top, height, left, right, rop)
  419. struct hardware *to;
  420. int top, height, *left, *right, rop;
  421. {
  422.     int i, op, offset = top;
  423.     Pixrect *bm;
  424.     
  425.     DoDispatch();
  426.     height += top;
  427.     switch (rop) {
  428.     case ROP_FALSE:     op = PIX_NOT (PIX_SET);    break;
  429.     case ROP_DEST:                     return;
  430.     case ROP_NOTDEST:     op = PIX_NOT (PIX_SRC);    break;
  431.     case ROP_TRUE:         op = PIX_SET;        break;
  432.     }
  433.     rop = rop_map [rop];
  434.     UpdateControl (to, FALSE);
  435.     for (i = top; i < height; i++)
  436.     if (to->flags & ISWIN)
  437.         pw_rop (Pixwin_addr(to), left[i - offset], i,
  438.         right[i - offset] - left[i - offset], 1, op, bm, 0, 0);
  439.     else
  440.         pr_rop (Pixrect_addr(to), left[i - offset], i,
  441.         right[i - offset] - left[i - offset], 1, op, bm, 0, 0);
  442.     UpdateControl (to, TRUE);
  443. }
  444.  
  445. void HardUpdate()
  446.  
  447. {
  448.     window_set(STFrame,
  449.     FRAME_LABEL, "Postscript display window (new page ready)",
  450.     FRAME_ICON, &ready_icon,
  451.     0);
  452.     window_set(STCanvas,
  453.     WIN_CONSUME_PICK_EVENTS, WIN_MOUSE_BUTTONS, 0,
  454.     0);
  455.  
  456.     STPageStatus = PG_WAITING;
  457.     do
  458.     /*
  459.      * turn control over to Hal for a while
  460.      */
  461.     notify_start();
  462.     while (STPageStatus == PG_WAITING);
  463.  
  464.     window_set(STFrame,
  465.     FRAME_LABEL, "Postscript display window",
  466.     FRAME_ICON, &working_icon,
  467.     0);
  468.     /*
  469.      * poke Hal once more, so he'll update our frame label and icon
  470.      */
  471.     notify_dispatch();
  472. }
  473.  
  474. STWinEvent(win,event,arg)
  475. Window win;
  476. Event *event;
  477. caddr_t arg;
  478.  
  479. {
  480.     int selection;
  481.  
  482.     if (win != STCanvas)
  483.     return;
  484.     
  485.     switch (event_id(event)) {
  486.     case MS_RIGHT:
  487.         if (event_is_down(event)) {
  488.  
  489.         if (STPageStatus == PG_WAITING)
  490.             selection = (int) menu_show(STPageMenu,win,event,0);
  491.         else
  492.             selection = (int) menu_show(STJustQuit,win,event,0);
  493.  
  494.         /*
  495.          * see the Suntools section on menus to learn the magic
  496.          * of what menu_show() returns
  497.          */
  498.  
  499.         if ((selection == 1 && STPageStatus != PG_WAITING) ||
  500.              (selection == 2 && STPageStatus == PG_WAITING)) {
  501.             if (notify_die(DESTROY_CHECKING) == NOTIFY_OK) {
  502.             window_set(STFrame,FRAME_NO_CONFIRM,TRUE,0);
  503.             window_done(STFrame);
  504.             exit(0);
  505.             }
  506.             }
  507.         else {
  508.             if (STPageStatus == PG_WAITING && selection == 1) {
  509.             STPageStatus = PG_ADVANCE;
  510.             /*
  511.              * You've done a nice job, Hal, but we will
  512.              * take control again now, thank you
  513.              */
  514.             notify_stop();
  515.             }
  516.             }
  517.         }
  518.         break;
  519.     default:
  520.         window_default_event_proc(win,event,arg);
  521.         break;
  522.     }
  523. }
  524.  
  525. DoDispatch()
  526. {
  527.     if (STPageStatus == PG_DESTROYED)    /* take this opportunity to go away */
  528.     exit(0);
  529.     notify_dispatch();    /* gratuitous method of dispatching window events */
  530. }
  531.  
  532. Notify_value STDestroyEvent(win,status)
  533. Frame win;
  534. Destroy_status status;
  535. {
  536.     if (win != STFrame)
  537.     return(NOTIFY_IGNORED);
  538.     if (status == DESTROY_CHECKING)
  539.     return(notify_next_destroy_func(STFrame,status));
  540.     else
  541.     STPageStatus = PG_DESTROYED;
  542.     return(NOTIFY_DONE);
  543. }
  544.     
  545. /*
  546.  * Because I needed to provide a version of HardUpdate(), the file canon.c
  547.  * from canon.a, minus HardUpdate, must be provided here.
  548.  */
  549.  
  550. int pixels_per_inch;
  551.  
  552. int single_rop [] =
  553.  {
  554.     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE,
  555.     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE,
  556.     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE,
  557.     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE
  558.  };
  559.  
  560. /*ARGSUSED*/
  561. Matrix DeviceMatrix (width, height) int width, height;
  562.  {
  563.      return NewMatrix (pixels_per_inch / 72.0, 0.0, 0.0, -pixels_per_inch / 72.0, 0.0, (float) height);
  564.  }
  565.  
  566. int IsWindowHardware (h) struct hardware *h;
  567.  {
  568.      return h->flags & ISWIN;
  569.  }
  570.  
  571. DevicePoint HardwareExtent (h) struct hardware *h;
  572.  {
  573.      if (h)
  574.          return h->extent;
  575.      else
  576.          return NewDevicePoint (0, 0);
  577.  }
  578.  
  579. void SetClipHardware (h, clip) struct hardware *h, *clip;
  580.  {
  581.      if (h)
  582.         h->clip = clip;
  583.  }
  584. //E*O*F pixwin.c//
  585.  
  586. echo x - pixwin.README
  587. cat > "pixwin.README" << '//E*O*F pixwin.README//'
  588. The pixwin changes require some subtle knowledge to use effectively.
  589.  
  590. To compile, edit the Makefile and replace each instance of pixrect.o
  591. with pixwin.o. Replace each instance of
  592.     -lpixrect
  593. with
  594.     -lsuntool -lsunwindow -lpixrect
  595. (Yes, the ordering is important.) Do a make depend. Do a make suntools.
  596.  
  597. Next, to make this work properly, you must redefine showpage in your
  598. ~/.postscript file. The definition is thus:
  599.  
  600. /showpage { copypage initgraphics flush erasepage } def
  601.  
  602. If you don't do this, the interpreter (either "postscript" or "sunPS")
  603. will beep nastily at you every time it encounters a showpage, and wait
  604. for a carriage return, thus requiring response in TWO windows!
  605.  
  606. Execute "sunPS file.ps". Voila.
  607.  
  608. It can be highly efficient to run the interpreter on one machine via
  609. rsh and the viewer on your Sun. However, suntools requires some
  610. environment variables be set for you to start up -- environment
  611. variables which your .cshrc or .profile will not provide. These are
  612. WINDOW_PARENT and WMGR_ENV_PLACEHOLDER.
  613.  
  614. This example assumes that machine A and machine B have the rsh command
  615. available.
  616.  
  617. Let us suppose that you wish to view the output on machine A, but run
  618. the interpreter on machine B. The following shell script, which should
  619. reside on machine A and which I call "rmtviewer", will provide the
  620. window information for suntools.
  621.  
  622. -----
  623. #! /bin/sh
  624. # the following is the "most general" method. For quick 'n' dirty, comment
  625. # this out and uncomment the two lines following, which seem to work in
  626. # all the cases I've tried.
  627. eval `ps axeww | grep shelltool | awk '
  628.     BEGIN   {    done = 0 }
  629.             {    for (i=1;i<NF&&done != 2;i++)
  630.         if (index($i,"=")) {
  631.             split($i,tmp,"=")
  632.             if (tmp[1] == "WINDOW_PARENT" || \
  633.             tmp[1] == "WMGR_ENV_PLACEHOLDER") {
  634.             print $i
  635.             done++
  636.             }
  637.             }
  638.         }'`
  639. #WINDOW_PARENT=/dev/win0
  640. #WMGR_ENV_PLACEHOLDER=/dev/win1
  641.  
  642. export WINDOW_PARENT; export WMGR_ENV_PLACEHOLDER
  643.  
  644. exec sunviewer
  645. -----
  646.  
  647. On machine B, you must have
  648.  
  649.     POSTSCRIPTDEVICE="| rsh machineA rmtviewer"; export POSTSCRIPTDEVICE
  650.         -or-
  651.     setenv POSTSCRIPTDEVICE "| rsh machineA rmtviewer"
  652.  
  653. in your .cshrc or .profile (as appropriate for your shell). Verify that
  654. your .postscript is set up as above. Then, still on machine B, execute
  655.  
  656.     postscript myfile
  657.  
  658. (where myfile contains postscript commands)
  659.  
  660. The window should appear on machine A and (eventually) display your output.
  661.  
  662. There is no reason you could not use rsh to run the postscript command on
  663. machine B from machine A, either.
  664. //E*O*F pixwin.README//
  665.  
  666. echo x - ps.empty
  667. cat > "ps.empty" << '//E*O*F ps.empty//'
  668. /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  669.  */
  670.     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8000,0x0000,0x0000,0x0001,
  671.     0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  672.     0x80FC,0x0000,0x0000,0x0001,0x8387,0x0000,0x0000,0x0001,
  673.     0x8201,0x0000,0x0000,0x0001,0x8387,0x0000,0x0000,0x0001,
  674.     0x82FD,0x0000,0x7800,0x0001,0x8102,0x0000,0x8600,0x0001,
  675.     0x8084,0x0001,0x0100,0x0001,0x8084,0x0002,0x0260,0x0001,
  676.     0x8703,0x8004,0x02DC,0x0001,0x9800,0x6008,0x0586,0x0001,
  677.     0xA102,0x9010,0x0601,0x8001,0xA14B,0x1020,0x0000,0x2001,
  678.     0xA269,0x9040,0x0000,0x0E01,0xA259,0x5080,0x0000,0x0181,
  679.     0x9048,0x2180,0x0000,0x0071,0x8C00,0xC300,0x0000,0x0021,
  680.     0x8387,0x0200,0x0000,0x0009,0x8078,0x0200,0x0006,0x0079,
  681.     0x8000,0x0200,0x0003,0xC3C1,0x8000,0x0100,0x0001,0x3401,
  682.     0x8000,0x0100,0x0001,0x8801,0x8000,0x0100,0x0000,0xC001,
  683.     0x8000,0x3D00,0x0000,0x4001,0x8000,0x2700,0x0000,0x4001,
  684.     0x8000,0x4300,0x0000,0x8001,0x8000,0x4000,0x0001,0x0001,
  685.     0x80C0,0x8000,0x0001,0x0001,0x8738,0x8000,0x0003,0x0001,
  686.     0x8C07,0x0000,0x0002,0x0001,0x9001,0x8000,0x0004,0x0001,
  687.     0x9000,0x6000,0x0004,0x0001,0x9000,0x2000,0x0008,0x0001,
  688.     0xA000,0x1800,0x0008,0x0001,0x8000,0x0C00,0x0010,0x0001,
  689.     0xA000,0x0200,0x0030,0x0001,0xA000,0x0100,0x0060,0x0001,
  690.     0x9000,0x0180,0x0040,0x0001,0x9000,0x0080,0x0040,0x0001,
  691.     0x9800,0x0060,0x0080,0x0001,0x8800,0x0FE0,0x0180,0x0001,
  692.     0x8400,0x0AB0,0x7100,0x0001,0x8200,0x1558,0x4E00,0x0001,
  693.     0x8300,0x1AA8,0x4000,0x0001,0x8100,0x1D54,0x2000,0x0001,
  694.     0x80C0,0x17AC,0x3000,0x0001,0x8038,0x10D4,0x1800,0x0001,
  695.     0x800C,0x102C,0x0800,0x0001,0x8004,0x1000,0x0800,0x0001,
  696.     0x8002,0x1000,0x1800,0x0001,0x8001,0x1800,0x0000,0x0001,
  697.     0x8000,0xC800,0x2000,0x0001,0x8000,0x2C00,0x6000,0x0001,
  698.     0x8000,0x1E00,0x8000,0x0001,0x8000,0x0303,0x0000,0x0001,
  699.     0x8000,0x00FC,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  700.     0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  701.     0x8000,0x0000,0x0000,0x0001,0xFFFF,0xFFFF,0xFFFF,0xFFFF
  702. //E*O*F ps.empty//
  703.  
  704. echo x - ps.full
  705. cat > "ps.full" << '//E*O*F ps.full//'
  706. /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16
  707.  */
  708.     0xFFFF,0xFFFF,0xFFFF,0xFFFF,0x8000,0x0000,0x0000,0x0001,
  709.     0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  710.     0x80FC,0x0000,0x0000,0x0001,0x8387,0x0000,0x0000,0x0001,
  711.     0x8201,0x0000,0x0000,0x0001,0x8387,0x0000,0x0000,0x0001,
  712.     0x82FD,0x0000,0x7800,0x0001,0x8102,0x0000,0x8600,0x0001,
  713.     0x8084,0x0001,0x0100,0x0001,0x8084,0x0002,0x0260,0x0001,
  714.     0x8703,0x8004,0x02DC,0x0001,0x9800,0x6008,0x0586,0x0001,
  715.     0xA102,0x9010,0x0601,0x8001,0xA14B,0x1020,0x0000,0x2001,
  716.     0xA269,0x9048,0x0800,0x0E01,0xA259,0x50B6,0x1800,0x0181,
  717.     0x9048,0x21A0,0x6800,0x0071,0x8C00,0xC321,0xD000,0x0021,
  718.     0x8387,0x021E,0x7000,0x0009,0x8078,0x0200,0x2006,0x0079,
  719.     0x8000,0x0200,0x2103,0xC3C1,0x8000,0x0100,0x20C1,0x3401,
  720.     0x8000,0x0100,0x2021,0x8801,0x8000,0x0118,0x0010,0xC001,
  721.     0x8000,0x3D0C,0x0018,0x4001,0x8000,0x2706,0x0308,0x4001,
  722.     0x8000,0x4301,0x8080,0x8001,0x8000,0x4000,0xC0E1,0x0001,
  723.     0x80C0,0x8000,0x3031,0x0001,0x8738,0x8020,0x0C03,0x0001,
  724.     0x8C07,0x0C30,0x0402,0x0001,0x9001,0x860C,0x0004,0x0001,
  725.     0x9000,0x6302,0x0004,0x0001,0x9000,0x2181,0x0008,0x0001,
  726.     0xA000,0x1840,0xC008,0x0001,0x8000,0x0C20,0x6010,0x0001,
  727.     0xA000,0x0208,0x1830,0x0001,0xA000,0x010C,0x0860,0x0001,
  728.     0x9000,0x0182,0x0040,0x0001,0x9000,0x0083,0x0040,0x0001,
  729.     0x9800,0x0060,0x0080,0x0001,0x8800,0x0FE0,0x0180,0x0001,
  730.     0x8400,0x0AB0,0x7100,0x0001,0x8200,0x1558,0x4E00,0x0001,
  731.     0x8300,0x1AA8,0x4000,0x0001,0x8100,0x1D54,0x2000,0x0001,
  732.     0x80C0,0x17AC,0x3000,0x0001,0x8038,0x10D5,0x1800,0x0001,
  733.     0x800C,0x1C2D,0x8800,0x0001,0x8004,0x1600,0xC800,0x0001,
  734.     0x8002,0x1300,0x7800,0x0001,0x8001,0x1980,0x2000,0x0001,
  735.     0x8000,0xC860,0x2000,0x0001,0x8000,0x2C00,0x6000,0x0001,
  736.     0x8000,0x1E00,0x8000,0x0001,0x8000,0x0303,0x0000,0x0001,
  737.     0x8000,0x00FC,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  738.     0x8000,0x0000,0x0000,0x0001,0x8000,0x0000,0x0000,0x0001,
  739.     0x8000,0x0000,0x0000,0x0001,0xFFFF,0xFFFF,0xFFFF,0xFFFF
  740. //E*O*F ps.full//
  741.  
  742. exit 0
  743.  
  744.