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