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

  1. /*    AT386:     hacked tcap.c for the 386 console, when you don't
  2.  *        have libtermcap.   grrr.
  3.  *
  4.  * $Log: at386.c,v $
  5.  * Revision 1.8  1992/05/16  12:00:31  pgf
  6.  * prototypes/ansi/void-int stuff/microsoftC
  7.  *
  8.  * Revision 1.7  1992/04/10  18:47:25  pgf
  9.  * change abs to absol to get rid of name conflicts
  10.  *
  11.  * Revision 1.6  1991/09/10  01:19:35  pgf
  12.  * re-tabbed, and moved ESC and BEL to estruct.h
  13.  *
  14.  * Revision 1.5  1991/08/07  12:34:39  pgf
  15.  * added RCS log messages
  16.  *
  17.  * revision 1.4
  18.  * date: 1991/06/19 01:32:21;
  19.  * change name of howmany 'cuz of HP/UX conflict
  20.  * sheesh
  21.  * 
  22.  * revision 1.3
  23.  * date: 1991/05/31 10:27:03;
  24.  * moved PRETTIER_SCROLL #define to estruct.h
  25.  * 
  26.  * revision 1.2
  27.  * date: 1990/10/01 10:37:32;
  28.  * un-#ifdef spal()
  29.  * 
  30.  * revision 1.1
  31.  * date: 1990/09/21 10:24:39;
  32.  * initial vile RCS revision
  33. */
  34.  
  35. #define termdef 1            /* don't define "term" external */
  36.  
  37. #include <stdio.h>
  38. #include    "estruct.h"
  39. #include    "edef.h"
  40.  
  41. #if AT386
  42.  
  43. #define NROW    25            /* Screen size.         */
  44. #define NCOL    80            /* Edit if you want to.     */
  45. #define MARGIN    8
  46. #define SCRSIZ    64
  47. #define NPAUSE    10            /* # times thru update to pause */
  48.  
  49. extern int    ttopen();
  50. extern int    ttgetc();
  51. extern int    ttputc();
  52. extern int    tgetnum();
  53. extern int    ttflush();
  54. extern int    ttclose();
  55. extern int    at386kopen();
  56. extern int    at386kclose();
  57. extern int    at386move();
  58. extern int    at386eeol();
  59. extern int    at386eeop();
  60. extern int    at386beep();
  61. extern int    at386rev();
  62. extern int    at386cres();
  63. extern int    at386open();
  64. extern int    tput();
  65. extern char    *tgoto();
  66. #if    COLOR
  67. extern    int    at386fcol();
  68. extern    int    at386bcol();
  69. #endif
  70. #if    SCROLLCODE
  71. extern    int    at386scroll_delins();
  72. #endif
  73.  
  74. #define TCAPSLEN 315
  75. char at386buf[TCAPSLEN];
  76. char *UP, PC, *CM, *CE, *CL, *SO, *SE;
  77.  
  78. #if    SCROLLCODE
  79. char *DL, *AL, *SF, *SR;
  80. #endif
  81.  
  82. TERM term = {
  83.     NROW-1,
  84.     NROW-1,
  85.     NCOL,
  86.     NCOL,
  87.     MARGIN,
  88.     SCRSIZ,
  89.     NPAUSE,
  90.     at386open,
  91.     ttclose,
  92.     at386kopen,
  93.     at386kclose,
  94.     ttgetc,
  95.     ttputc,
  96.     ttflush,
  97.     at386move,
  98.     at386eeol,
  99.     at386eeop,
  100.     at386beep,
  101.     at386rev,
  102.     at386cres
  103. #if    COLOR
  104.     , at386fcol,
  105.     at386bcol
  106. #endif
  107. #if    SCROLLCODE
  108.     , NULL        /* set dynamically at open time */
  109. #endif
  110. };
  111.  
  112. at386open()
  113. {
  114.     char *getenv();
  115.     char *t, *p, *tgetstr();
  116.     char tcbuf[1024];
  117.     char *tv_stype;
  118.     char err_str[72];
  119.  
  120.     CL = "\033[2J\033[H";
  121.     CE = "\033[K";
  122.     UP = "\033[A";
  123.     SE = "\033[m";
  124.     SO = "\033[7m";
  125.     revexist = TRUE;
  126.  
  127.  
  128. #if SCROLLCODE
  129.     DL = "\033[1M";
  130.     AL = "\033[1L";
  131.     term.t_scroll = at386scroll_delins;
  132. #endif
  133.     ttopen();
  134. }
  135.  
  136. at386kopen()
  137. {
  138.     strcpy(sres, "NORMAL");
  139. }
  140.  
  141. at386kclose()
  142. {
  143. }
  144.  
  145. csi()
  146. {
  147.     ttputc(ESC);
  148.     ttputc('[');
  149. }
  150.  
  151. ansiparm(n)
  152. register int    n;
  153. {
  154.     register int q,r;
  155.  
  156.     q = n/10;
  157.     if (q != 0) {
  158.         r = q/10;
  159.         if (r != 0) {
  160.             ttputc((r%10)+'0');
  161.         }
  162.         ttputc((q%10) + '0');
  163.     }
  164.     ttputc((n%10) + '0');
  165. }
  166.  
  167. at386move(row, col)
  168. register int row, col;
  169. {
  170.     csi();
  171.     if (row) ansiparm(row+1);
  172.     ttputc(';');
  173.     if (col) ansiparm(col+1);
  174.     ttputc('H');
  175. }
  176.  
  177. at386eeol()
  178. {
  179.     fputs(CE,stdout);
  180. }
  181.  
  182. at386eeop()
  183. {
  184.     fputs(CL,stdout);
  185. }
  186.  
  187. at386rev(state)     /* change reverse video status */
  188. int state;        /* FALSE = normal video, TRUE = reverse video */
  189. {
  190.     static int revstate = -1;
  191.     if (state == revstate)
  192.         return;
  193.     revstate = state;
  194.     if (state) {
  195.         if (SO != NULL)
  196.             fputs(SO,stdout);
  197.     } else {
  198.         if (SE != NULL)
  199.             fputs(SE,stdout);
  200.     }
  201. }
  202.  
  203. at386cres()    /* change screen resolution */
  204. {
  205.     return(TRUE);
  206. }
  207.  
  208. #if SCROLLCODE
  209.  
  210. /* 
  211. PRETTIER_SCROLL is prettier but slower -- it scrolls 
  212.         a line at a time instead of all at once.
  213. */
  214.  
  215. /* move howmany lines starting at from to to */
  216. at386scroll_delins(from,to,n)
  217. {
  218.     int i;
  219.     if (to == from) return;
  220. #if PRETTIER_SCROLL
  221.     if (absol(from-to) > 1) {
  222.         at386scroll_delins(from, (from<to) ? to-1:to+1, n);
  223.         if (from < to)
  224.             from = to-1;
  225.         else
  226.             from = to+1;    
  227.     }
  228. #endif
  229.     if (to < from) {
  230.         at386move(to,0);
  231.         for (i = from - to; i > 0; i--)
  232.             fputs(DL,stdout);
  233.         at386move(to+n,0);
  234.         for (i = from - to; i > 0; i--)
  235.             fputs(AL,stdout);
  236.     } else {
  237.         at386move(from+n,0);
  238.         for (i = to - from; i > 0; i--)
  239.             fputs(DL,stdout);
  240.         at386move(from,0);
  241.         for (i = to - from; i > 0; i--)
  242.             fputs(AL,stdout);
  243.     }
  244. }
  245.  
  246. #endif
  247.  
  248. spal(dummy)    /* change palette string */
  249. {
  250.     /*    Does nothing here    */
  251. }
  252.  
  253.  
  254. #if    COLOR
  255. at386fcol()    /* no colors here, ignore this */
  256. {
  257. }
  258.  
  259. at386bcol()    /* no colors here, ignore this */
  260. {
  261. }
  262. #endif
  263.  
  264. at386beep()
  265. {
  266.     ttputc(BEL);
  267. }
  268.  
  269.  
  270. #if    FLABEL
  271. int
  272. fnclabel(f, n)        /* label a function key */
  273. int f,n;    /* default flag, numeric argument [unused] */
  274. {
  275.     /* on machines with no function keys...don't bother */
  276.     return(TRUE);
  277. }
  278. #endif
  279. #else
  280.  
  281. hello()
  282. {
  283. }
  284.  
  285. #endif
  286.