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

  1. /*
  2.  *    HP110:    Hewlett Packard 110 Screen Driver
  3.  */
  4.  
  5. #define    termdef    1            /* don't define "term" external */
  6.  
  7. #include        <stdio.h>
  8. #include    "estruct.h"
  9. #include        "edef.h"
  10.  
  11. #if     HP110
  12.  
  13. #define NROW    16                      /* Screen size.                 */
  14. #define NCOL    80                      /* Edit if you want to.         */
  15. #define    NPAUSE    100            /* # times thru update to pause */
  16. #define    MARGIN    8            /* size of minimim margin and    */
  17. #define    SCRSIZ    64            /* scroll size for extended lines */
  18. #define BEL     0x07                    /* BEL character.               */
  19. #define ESC     0x1B                    /* ESC character.               */
  20.  
  21. extern  int     ttopen();               /* Forward references.          */
  22. extern  int     ttgetc();
  23. extern  int     ttputc();
  24. extern  int     ttflush();
  25. extern  int     ttclose();
  26. extern  int     h110move();
  27. extern  int     h110eeol();
  28. extern  int     h110eeop();
  29. extern  int     h110beep();
  30. extern  int     h110open();
  31. extern    int    h110rev();
  32. extern    int    h110cres();
  33. extern    int    h110close();
  34. extern    int    h110kopen();
  35. extern    int    h110kclose();
  36.  
  37. #if    COLOR
  38. extern    int    h110fcol();
  39. extern    int    h110bcol();
  40.  
  41. int    cfcolor = -1;        /* current forground color */
  42. int    cbcolor = -1;        /* current background color */
  43. #endif
  44.  
  45. /*
  46.  * Standard terminal interface dispatch table. Most of the fields point into
  47.  * "termio" code.
  48.  */
  49. TERM    term    = {
  50.     NROW-1,
  51.         NROW-1,
  52.         NCOL,
  53.         NCOL,
  54.     MARGIN,
  55.     SCRSIZ,
  56.     NPAUSE,
  57.         h110open,
  58.         h110close,
  59.     h110kopen,
  60.     h110kclose,
  61.         ttgetc,
  62.         ttputc,
  63.         ttflush,
  64.         h110move,
  65.         h110eeol,
  66.         h110eeop,
  67.         h110beep,
  68.     h110rev,
  69.     h110cres
  70. #if    COLOR
  71.     , h110fcol,
  72.     h110bcol
  73. #endif
  74. };
  75.  
  76. #if    COLOR
  77. h110fcol(color)        /* set the current output color */
  78.  
  79. int color;    /* color to set */
  80.  
  81. {
  82.     if (color == cfcolor)
  83.         return;
  84.     ttputc(ESC);
  85.     ttputc('[');
  86.     h110parm(color+30);
  87.     ttputc('m');
  88.     cfcolor = color;
  89. }
  90.  
  91. h110bcol(color)        /* set the current background color */
  92.  
  93. int color;    /* color to set */
  94.  
  95. {
  96.     if (color == cbcolor)
  97.         return;
  98.     ttputc(ESC);
  99.     ttputc('[');
  100.     h110parm(color+40);
  101.     ttputc('m');
  102.         cbcolor = color;
  103. }
  104. #endif
  105.  
  106. h110move(row, col)
  107. {
  108.         ttputc(ESC);
  109.         ttputc('[');
  110.         h110parm(row+1);
  111.         ttputc(';');
  112.         h110parm(col+1);
  113.         ttputc('H');
  114. }
  115.  
  116. h110eeol()
  117. {
  118.         ttputc(ESC);
  119.         ttputc('[');
  120.     ttputc('0');
  121.         ttputc('K');
  122. }
  123.  
  124. h110eeop()
  125. {
  126. #if    COLOR
  127.     h110fcol(gfcolor);
  128.     h110bcol(gbcolor);
  129. #endif
  130.         ttputc(ESC);
  131.         ttputc('[');
  132.     ttputc('0');
  133.         ttputc('J');
  134. }
  135.  
  136. h110rev(state)        /* change reverse video state */
  137.  
  138. int state;    /* TRUE = reverse, FALSE = normal */
  139.  
  140. {
  141. #if    COLOR
  142.     int ftmp, btmp;        /* temporaries for colors */
  143. #endif
  144.  
  145.     ttputc(ESC);
  146.     ttputc('[');
  147.     ttputc(state ? '7': '0');
  148.     ttputc('m');
  149. #if    COLOR
  150.     if (state == FALSE) {
  151.         ftmp = cfcolor;
  152.         btmp = cbcolor;
  153.         cfcolor = -1;
  154.         cbcolor = -1;
  155.         h110fcol(ftmp);
  156.         h110bcol(btmp);
  157.     }
  158. #endif
  159. }
  160.  
  161. h110cres()    /* change screen resolution */
  162.  
  163. {
  164.     return(TRUE);
  165. }
  166.  
  167. spal()        /* change pallette register */
  168.  
  169. {
  170.     /*   not here */
  171. }
  172.  
  173. h110beep()
  174. {
  175.         ttputc(BEL);
  176.         ttflush();
  177. }
  178.  
  179. h110parm(n)
  180. register int    n;
  181. {
  182.         register int q,r;
  183.  
  184.         q = n/10;
  185.         if (q != 0) {
  186.         r = q/10;
  187.         if (r != 0) {
  188.             ttputc((r%10)+'0');
  189.         }
  190.         ttputc((q%10) + '0');
  191.         }
  192.         ttputc((n%10) + '0');
  193. }
  194.  
  195. h110open()
  196. {
  197.     strcpy(sres, "15LINE");
  198.     revexist = TRUE;
  199.         ttopen();
  200. }
  201.  
  202. h110close()
  203.  
  204. {
  205. #if    COLOR
  206.     h110fcol(7);
  207.     h110bcol(0);
  208. #endif
  209.     ttclose();
  210. }
  211.  
  212. h110kopen()
  213.  
  214. {
  215. }
  216.  
  217. h110kclose()
  218.  
  219. {
  220. }
  221.  
  222. #if    FLABEL
  223. fnclabel(f, n)        /* label a function key */
  224.  
  225. int f,n;    /* default flag, numeric argument [unused] */
  226.  
  227. {
  228.     /* on machines with no function keys...don't bother */
  229.     return(TRUE);
  230. }
  231. #endif
  232. #else
  233. h110hello()
  234. {
  235. }
  236. #endif
  237.