home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / VILE327.ZIP / VILE327.TAR / vile3.27 / hp110.c < prev    next >
C/C++ Source or Header  |  1992-12-14  |  4KB  |  253 lines

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