home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / unixtex-6.1b-src.tgz / tar.out / contrib / unixtex / web2c / mf / MFwindow / regis.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-28  |  2.6 KB  |  106 lines

  1. /* Regis terminal window interface for Metafont, joe@rilgp.tamri.com.
  2.    screen_rows is 480; screen_cols is 800. */
  3.  
  4. #define    EXTERN    extern
  5. #include "../mfd.h"
  6.  
  7. #ifdef REGISWIN        /* Whole file */
  8.  
  9. #define ESCAPE        27
  10.  
  11. /* set this up in one of two ways.  if defined, display is white characters
  12. on a black background; undefined is the opposite */
  13. #undef WRITEWHITE
  14.  
  15. /* 
  16.  *    int init_screen 
  17.  *        Put screen in graphics mode:<ESC>Pp
  18.  *        Write no or both planes for the background black:S(I0)
  19.  *        Write both or no planes for the forground white:W(I3)
  20.  *        Erase screen:S(E)
  21.  *        Return to alpha mode: <ESC>\ 
  22.  *
  23.  *        Assuming that the speed limitation is a serial line to the
  24.  *        terminal, we want to define macros for the most common
  25.  *        character combinations.
  26.  *        Define macros for ,+0]P[ (call this "p") and
  27.  *        ,+0]V[ (this one is called "v").
  28.  *        drawing a line is 4+(2 to 6) characters
  29.  *        We always return true.
  30.  */
  31.  
  32. int mf_regis_initscreen()
  33. {
  34. #ifdef WRITEWHITE
  35.     printf("%cPpS(I0)W(I3)S(E)%c",ESCAPE,ESCAPE);
  36. #else
  37.     printf("%cPpS(I3)W(I0)S(E)%c",ESCAPE,ESCAPE);
  38. #endif
  39.     printf("%cPp@:p,+0]P[@;@:v,+0]V[@;",ESCAPE);
  40.     return 1;
  41. }
  42. /*
  43.  *    procedure updatescreen;
  44.  *
  45.  */
  46. void mf_regis_updatescreen()
  47. {
  48. }
  49.  /*    void blankrectangle(int left,int right,int top,int bottom);
  50.  *
  51.  *        Go to graphics mode: <ESC>Pp
  52.  *        Move to lower left: P[%d,%d]
  53.  *        Write no or both planes: W(I0)
  54.  *        Turn on shading: W(S1)
  55.  *        Vector to lower right, upper right, upper left, lower left: V's
  56.  *        Turn off shading: W(S0)
  57.  *        Write both or no planes: W(I3)
  58.  *        Return to alpha mode: <ESC>\ 
  59.  */
  60. mf_regis_blankrectangle(left, right, top, bottom)
  61. screencol left, right;
  62. screenrow top, bottom;
  63. {
  64.     printf(
  65. #ifdef WRITEWHITE
  66.     "%cPpP[%d,%d]W(I0)W(S1)V[%d,%d]V[%d,%d]V[%d,%d]V[%d,%d]W(S0)W(I3)%c\\",
  67. #else
  68.     "%cPpP[%d,%d]W(I3)W(S1)V[%d,%d]V[%d,%d]V[%d,%d]V[%d,%d]W(S0)W(I0)%c\\",
  69. #endif
  70.         ESCAPE,left,bottom,right,bottom,right,top,left,top,
  71.         left,bottom,ESCAPE);
  72. }
  73.  
  74. /*
  75.  *    void paintrow(int row, int init_color, int* transition_vector,
  76.  *                    int vector_size);
  77.  *        Paint "row" starting with color "init_color", up to next
  78.  *        transition specified by "transition_vector", switch colors,
  79.  *        and continue for "vector_size" transitions.
  80.  */
  81. void mf_regis_paintrow(row, init_color, transition_vector, vector_size)
  82. screenrow   row;
  83. pixelcolor  init_color;
  84. transspec   transition_vector;
  85. screencol   vector_size;
  86. {
  87.     int i;
  88.     if(init_color) {
  89.         init_color = 1;
  90.     } else {
  91.         init_color = 0;
  92.     }
  93.     printf("%cPpP[0,%d]P[",ESCAPE,row);
  94.     for(i=0;i<vector_size;i++) {
  95.         if(init_color)
  96.         printf("%d@v%d@p",transition_vector[i],
  97.                         transition_vector[i+1]);
  98.         init_color = 1-init_color;
  99.     }
  100.     printf("+0,+0]%c\\",ESCAPE);
  101. }
  102.  
  103. #else
  104. int regis_dummy;
  105. #endif    /* REGISWIN */
  106.