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