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