home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 198_02 / vt52.c < prev    next >
C/C++ Source or Header  |  1990-01-23  |  4KB  |  184 lines

  1. /*
  2.  * The routines in this file
  3.  * provide support for VT52 style terminals
  4.  * over a serial line. The serial I/O services are
  5.  * provided by routines in "termio.c". It compiles
  6.  * into nothing if not a VT52 style device. The
  7.  * bell on the VT52 is terrible, so the "beep"
  8.  * routine is conditionalized on defining BEL.
  9.  */
  10. #define    termdef    1            /* don't define "term" external */
  11.  
  12. #include        <stdio.h>
  13. #include        "estruct.h"
  14. #include    "edef.h"
  15.  
  16. #if     VT52
  17.  
  18. #define NROW    24                      /* Screen size.                 */
  19. #define NCOL    80                      /* Edit if you want to.         */
  20. #define    MARGIN    8            /* size of minimim margin and    */
  21. #define    SCRSIZ    64            /* scroll size for extended lines */
  22. #define    NPAUSE    100            /* # times thru update to pause */
  23. #define BIAS    0x20                    /* Origin 0 coordinate bias.    */
  24. #define ESC     0x1B                    /* ESC character.               */
  25. #define BEL     0x07                    /* ascii bell character         */
  26.  
  27. extern  int     ttopen();               /* Forward references.          */
  28. extern  int     ttgetc();
  29. extern  int     ttputc();
  30. extern  int     ttflush();
  31. extern  int     ttclose();
  32. extern  int     vt52move();
  33. extern  int     vt52eeol();
  34. extern  int     vt52eeop();
  35. extern  int     vt52beep();
  36. extern  int     vt52open();
  37. extern    int    vt52rev();
  38. extern    int    vt52cres();
  39. extern    int    vt52kopen();
  40. extern    int    vt52kclose();
  41.  
  42. #if    COLOR
  43. extern    int    vt52fcol();
  44. extern    int    vt52bcol();
  45. #endif
  46.  
  47. /*
  48.  * Dispatch table. All the
  49.  * hard fields just point into the
  50.  * terminal I/O code.
  51.  */
  52. TERM    term    = {
  53.     NROW-1,
  54.         NROW-1,
  55.         NCOL,
  56.         NCOL,
  57.     MARGIN,
  58.     SCRSIZ,
  59.     NPAUSE,
  60.         &vt52open,
  61.         &ttclose,
  62.     &vt52kopen,
  63.     &vt52kclose,
  64.         &ttgetc,
  65.         &ttputc,
  66.         &ttflush,
  67.         &vt52move,
  68.         &vt52eeol,
  69.         &vt52eeop,
  70.         &vt52beep,
  71.         &vt52rev,
  72.         &vt52cres
  73. #if    COLOR
  74.     , &vt52fcol,
  75.     &vt52bcol
  76. #endif
  77. };
  78.  
  79. vt52move(row, col)
  80. {
  81.         ttputc(ESC);
  82.         ttputc('Y');
  83.         ttputc(row+BIAS);
  84.         ttputc(col+BIAS);
  85. }
  86.  
  87. vt52eeol()
  88. {
  89.         ttputc(ESC);
  90.         ttputc('K');
  91. }
  92.  
  93. vt52eeop()
  94. {
  95.         ttputc(ESC);
  96.         ttputc('J');
  97. }
  98.  
  99. vt52rev(status)    /* set the reverse video state */
  100.  
  101. int status;    /* TRUE = reverse video, FALSE = normal video */
  102.  
  103. {
  104.     /* can't do this here, so we won't */
  105. }
  106.  
  107. vt52cres()    /* change screen resolution - (not here though) */
  108.  
  109. {
  110.     return(TRUE);
  111. }
  112.  
  113. spal()        /* change palette string */
  114.  
  115. {
  116.     /*    Does nothing here    */
  117. }
  118.  
  119. #if    COLOR
  120. vt52fcol()    /* set the forground color [NOT IMPLIMENTED] */
  121. {
  122. }
  123.  
  124. vt52bcol()    /* set the background color [NOT IMPLIMENTED] */
  125. {
  126. }
  127. #endif
  128.  
  129. vt52beep()
  130. {
  131. #ifdef  BEL
  132.         ttputc(BEL);
  133.         ttflush();
  134. #endif
  135. }
  136.  
  137. vt52open()
  138. {
  139. #if     V7 | BSD
  140.         register char *cp;
  141.         char *getenv();
  142.  
  143.         if ((cp = getenv("TERM")) == NULL) {
  144.                 puts("Shell variable TERM not defined!");
  145.                 exit(1);
  146.         }
  147.         if (strcmp(cp, "vt52") != 0 && strcmp(cp, "z19") != 0) {
  148.                 puts("Terminal type not 'vt52'or 'z19' !");
  149.                 exit(1);
  150.         }
  151. #endif
  152.         ttopen();
  153. }
  154.  
  155. vt52kopen()
  156.  
  157. {
  158. }
  159.  
  160. vt52kclose()
  161.  
  162. {
  163. }
  164.  
  165.  
  166. #if    FLABEL
  167. fnclabel(f, n)        /* label a function key */
  168.  
  169. int f,n;    /* default flag, numeric argument [unused] */
  170.  
  171. {
  172.     /* on machines with no function keys...don't bother */
  173.     return(TRUE);
  174. }
  175. #endif
  176. #else
  177.  
  178. vt52hello()
  179.  
  180. {
  181. }
  182.  
  183. #endif
  184.