home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / DVI_MGR / dvimgr_s.lzh / dvimgr / prtpage.h < prev    next >
Text File  |  1993-08-06  |  8KB  |  317 lines

  1. /* -*-C-*- prtpage.h */
  2. /*-->prtpage*/
  3. /**********************************************************************/
  4. /****************************** prtpage *******************************/
  5. /**********************************************************************/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /* Modified for use with DVIDECW driver     (30.06.89)              */
  9. /*--------------------------------------------------------------------*/
  10.  
  11.  
  12.  
  13. void
  14. prtpage(bytepos)        /* print page whose BOP is at bytepos */
  15. long bytepos;
  16.  
  17. {
  18.     struct stack_entry
  19.     {
  20.     INT32 h;
  21.     COORDINATE hh;
  22.     INT32 v;
  23.     COORDINATE vv;
  24.     INT32 w, x, y, z;    /* what's on stack */
  25.     };
  26.     register BYTE command;  /* current command                */
  27.     register INT16 i;        /* command parameter; loop index        */
  28.     char tc;            /* temporary character            */
  29.     UNSIGN32 ht_rule;        /* rule height                              */
  30.     UNSIGN32 wd_rule;        /* rule width                               */
  31.     INT32 k,m;            /* temporary parameter            */
  32.     BOOLEAN seen_bop;        /* flag for noting processing of BOP    */
  33.     register INT16 sp;        /* stack pointer                */
  34.     struct stack_entry stack[STACKSIZE];    /* stack            */
  35.     char specstr[MAXSPECIAL+1];        /* \special{} string        */
  36.     INT32 w;            /* current horizontal spacing        */
  37.     INT32 x;            /* current horizontal spacing        */
  38.     INT32 y;            /* current vertical spacing            */
  39.     INT32 z;            /* current vertical spacing            */
  40.  
  41. /***********************************************************************
  42. Process all commands  between the  BOP at bytepos  and the  next BOP  or
  43. POST.  The page is  printed when the  EOP is met,  but font changes  can
  44. also happen between EOP and BOP, so we have to keep going after EOP.
  45. ***********************************************************************/
  46.  
  47.     seen_bop = FALSE;            /* this is first time through */
  48.     (void) FSEEK(dvifp,bytepos,0);    /* start at the desired position */
  49.  
  50.     for (;;)    /* "infinite" loop - exits when POST or second BOP met */
  51.     {
  52. #if    BBNBITGRAPH
  53. #if    (DECWINDOWS | MGR_OSK)
  54.                     /* Do nothing here but we could */
  55.                     /* check for any event in the    */
  56.                     /* queue in the next version of */
  57.                     /* DVIDECW            */
  58. #else
  59.     /* If the test here on every byte proves to carry objectionable
  60.        overhead, it can be moved into the default, PUTx, and SETx
  61.        command sections. The goal is to give the user instant
  62.        response in page screen positioning, without having to wait
  63.        for the entire screen to be painted when it is just going
  64.        to be moved anyway.  This is the sort of display algorithm
  65.        that EMACS uses. */
  66.     if (kbinput() > 0)    /* user has typed something */
  67.         command = EOP;    /* so set for end-of-page action */
  68.     else
  69. #endif
  70. #endif
  71.     command = (BYTE)nosignex(dvifp,(BYTE)1);
  72.     switch (command)
  73.     {
  74.  
  75.     case SET1:
  76.     case SET2:
  77.     case SET3:
  78.     case SET4:
  79.         (void)setchar((BYTE)nosignex(dvifp,(BYTE)(command-SET1+1)),TRUE);
  80.         break;
  81.  
  82.     case SET_RULE:
  83.         ht_rule = nosignex(dvifp,(BYTE)4);
  84.         wd_rule = nosignex(dvifp,(BYTE)4);
  85.         (void)setrule(ht_rule,wd_rule,TRUE);
  86.         break;
  87.  
  88.     case PUT1:
  89.     case PUT2:
  90.     case PUT3:
  91.     case PUT4:
  92.         (void)setchar((BYTE)nosignex(dvifp,(BYTE)(command-PUT1+1)),FALSE);
  93.         break;
  94.  
  95.     case PUT_RULE:
  96.         ht_rule = nosignex(dvifp,(BYTE)4);
  97.         wd_rule = nosignex(dvifp,(BYTE)4);
  98.         (void)setrule(ht_rule,wd_rule,FALSE);
  99.         break;
  100.  
  101.     case NOP:
  102.         break;
  103.  
  104.     case BOP:
  105.         if (seen_bop) {
  106.         return;            /* we have been here already */
  107.         }
  108.         seen_bop = TRUE;
  109.  
  110.         for (i=0; i<=9; i++)
  111.         tex_counter[i] = (INT32)signex(dvifp,(BYTE)4);
  112.  
  113. #if    BBNBITGRAPH
  114.         (void)bopact();        /* display menu at top of page */
  115. #else /* not BBNBITGRAPH */
  116.  
  117. #if    (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT)
  118.         (void)bopact();
  119. #else /* NOT (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */
  120.         (void)clrbmap();
  121. #endif /* (CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */
  122.  
  123.         if (!quiet)
  124.             (void)fprintf(stderr,"{%s}",tctos()); /* TeX page counters */
  125.         (void) nosignex(dvifp,(BYTE)4);    /* skip prev. page ptr */
  126. #endif /* BBNBITGRAPH */
  127.  
  128.         h = v = w = x = y = z = 0;
  129.         hh = lmargin;
  130.         vv = tmargin;
  131.         sp = 0;
  132.         fontptr = (struct font_entry*)NULL;
  133.         break;
  134.  
  135.     case EOP:
  136.  
  137. #if     (DECWINDOWS | MGR_OSK)        /* No endofpage act with DECW    */
  138.  
  139. #else
  140. #if    (BBNBITGRAPH | CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT)
  141.         (void)eopact();
  142. #else
  143.         (void)prtbmap();
  144. #endif /* (BBNBITGRAPH | CANON_A2 | HPJETPLUS | IMPRESS | POSTSCRIPT) */
  145. #endif
  146.         return;
  147.  
  148.     case PUSH:
  149.         if (sp >= STACKSIZE)
  150.         (void)fatal("prtpage():  stack overflow");
  151.         stack[sp].h = h;
  152.         stack[sp].hh = hh;
  153.         stack[sp].v = v;
  154.         stack[sp].vv = vv;
  155.         stack[sp].w = w;
  156.         stack[sp].x = x;
  157.         stack[sp].y = y;
  158.         stack[sp].z = z;
  159.         sp++;
  160.         break;
  161.  
  162.     case POP:
  163.         --sp;
  164.         if (sp < 0)
  165.         (void)fatal("prtpage():  stack underflow");
  166.         h = stack[sp].h;
  167.         hh = stack[sp].hh;
  168.         v = stack[sp].v;
  169.         vv = stack[sp].vv;
  170.         w = stack[sp].w;
  171.         x = stack[sp].x;
  172.         y = stack[sp].y;
  173.         z = stack[sp].z;
  174.         break;
  175.  
  176.     case RIGHT1:
  177.     case RIGHT2:
  178.     case RIGHT3:
  179.     case RIGHT4:
  180.         (void)moveover(signex(dvifp,(BYTE)(command-RIGHT1+1)));
  181.         break;
  182.  
  183.     case W0:
  184.         (void)moveover(w);
  185.         break;
  186.  
  187.     case W1:
  188.     case W2:
  189.     case W3:
  190.     case W4:
  191.         w = (INT32)signex(dvifp,(BYTE)(command-W1+1));
  192.         (void)moveover(w);
  193.         break;
  194.  
  195.     case X0:
  196.         (void)moveover(x);
  197.         break;
  198.  
  199.     case X1:
  200.     case X2:
  201.     case X3:
  202.     case X4:
  203.         x = (INT32)signex(dvifp,(BYTE)(command-X1+1));
  204.         (void)moveover(x);
  205.         break;
  206.  
  207.     case DOWN1:
  208.     case DOWN2:
  209.     case DOWN3:
  210.     case DOWN4:
  211.         (void)movedown(signex(dvifp,(BYTE)(command-DOWN1+1)));
  212.         break;
  213.  
  214.     case Y0:
  215.         (void)movedown(y);
  216.         break;
  217.  
  218.     case Y1:
  219.     case Y2:
  220.     case Y3:
  221.     case Y4:
  222.         y = signex(dvifp,(BYTE)(command-Y1+1));
  223.         (void)movedown(y);
  224.         break;
  225.  
  226.     case Z0:
  227.         (void)movedown(z);
  228.         break;
  229.  
  230.     case Z1:
  231.     case Z2:
  232.     case Z3:
  233.     case Z4:
  234.         z = signex(dvifp,(BYTE)(command-Z1+1));
  235.         (void)movedown(z);
  236.         break;
  237.  
  238.     case FNT1:
  239.     case FNT2:
  240.     case FNT3:
  241.     case FNT4:
  242.         (void)setfntnm((INT32)nosignex(dvifp,
  243.         (BYTE)(command-FNT1+1)));
  244.         break;
  245.  
  246.     case XXX1:
  247.     case XXX2:
  248.     case XXX3:
  249.     case XXX4:
  250.         k = (INT32)nosignex(dvifp,(BYTE)(command-XXX1+1));
  251.         if (k > MAXSPECIAL)
  252.         {
  253.         (void)sprintf(message,
  254.             "prtpage():  \\special{} string of %d characters longer \
  255. than DVI driver limit of %d -- truncated.",
  256.         k,MAXSPECIAL);
  257.         (void)warning(message);
  258.         }
  259.         m = 0;
  260.         while (k--)
  261.         {
  262.          tc = (char)nosignex(dvifp,(BYTE)1);
  263.          if (m < MAXSPECIAL)
  264.              specstr[m++] = tc;
  265.         }
  266.         specstr[m] = '\0';
  267.          (void) special(specstr);
  268.         break;
  269.  
  270.     case FNT_DEF1:
  271.     case FNT_DEF2:
  272.     case FNT_DEF3:
  273.     case FNT_DEF4:
  274.         if (preload)
  275.         (void)skipfont ((INT32) nosignex(dvifp,
  276.             (BYTE)(command-FNT_DEF1+1)));
  277.         else
  278.         (void)readfont ((INT32) nosignex(dvifp,
  279.             (BYTE)(command-FNT_DEF1+1)));
  280.         break;
  281.  
  282.     case PRE:
  283.         (void)fatal("prtpage():  PRE occurs within file");
  284.         break;
  285.  
  286.     case POST:
  287.         (void)devterm();        /* terminate device output */
  288.         (void)dviterm();        /* terminate DVI file processing */
  289.         (void)alldone();        /* this will never return */
  290.         break;
  291.  
  292.     case POST_POST:
  293.         (void)fatal("prtpage():  POST_POST with no preceding POST");
  294.         break;
  295.  
  296.     default:
  297.         if (command >= FONT_00 && command <= FONT_63)
  298.         (void)setfntnm((INT32)(command - FONT_00));
  299.         else if (command >= SETC_000 && command <= SETC_127)
  300.  
  301. #if    (HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2)
  302.         (void)setstr((BYTE)command); /* this sets several chars */
  303. #else
  304.         (void)setchar((BYTE)(command-SETC_000), TRUE);
  305. #endif /* (HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2) */
  306.  
  307.         else
  308.         {
  309.         (void)sprintf(message,"prtpage():  %d is an undefined command",
  310.             command);
  311.         (void)fatal(message);
  312.         }
  313.         break;
  314.     }
  315.     }
  316. }
  317.