home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / STVI369G.ZIP / TERM.C < prev    next >
C/C++ Source or Header  |  1990-05-01  |  2KB  |  89 lines

  1. /* $Header: /nw/tony/src/stevie/src/RCS/term.c,v 1.4 89/03/11 22:43:55 tony Exp $
  2.  *
  3.  * Termcap initialization (optional).
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include "stevie.h"
  8.  
  9. #ifdef    TERMCAP
  10.  
  11. static    char    buf[1024];    /* termcap entry read here */
  12. static    char    cap[256];    /* capability strings go in here */
  13.  
  14. char    *T_EL;        /* erase the entire current line */
  15. char    *T_IL;        /* insert one line */
  16. char    *T_DL;        /* delete one line */
  17. char    *T_SC;        /* save the cursor position */
  18. char    *T_ED;        /* erase display (may optionally home cursor) */
  19. char    *T_RC;        /* restore the cursor position */
  20. char    *T_CI;        /* invisible cursor (very optional) */
  21. char    *T_CV;        /* visible cursor (very optional) */
  22.  
  23. char    *T_CM;        /* cursor motion string */
  24.  
  25. extern    int    tgetent(), tgetnum();
  26. extern    char    *tgetstr();
  27. extern    char    *getenv();
  28.  
  29. int
  30. t_init()
  31. {
  32.     char    *term;
  33.     int    n;
  34.     char    *cp = cap;
  35.  
  36.     if ((term = getenv("TERM")) == NULL)
  37.         return 0;
  38.  
  39.     if (tgetent(buf, term) != 1)
  40.         return 0;
  41.  
  42.     if ((n = tgetnum("li")) == -1)
  43.         return 0;
  44.     else
  45.         P(P_LI) = Rows = n;
  46.  
  47.     if ((n = tgetnum("co")) == -1)
  48.         return 0;
  49.     else
  50.         Columns = n;
  51.  
  52.     /*
  53.      * Get mandatory capability strings.
  54.      */
  55.     if ((T_CM = tgetstr("cm", &cp)) == NULL)
  56.         return 0;
  57.  
  58.     if ((T_EL = tgetstr("ce", &cp)) == NULL)
  59.         return 0;
  60.  
  61.     if ((T_ED = tgetstr("cl", &cp)) == NULL)
  62.         return 0;
  63.  
  64.     /*
  65.      * Optional capabilities.
  66.      */
  67.     if ((T_IL = tgetstr("al", &cp)) == NULL)
  68.         T_IL = "";
  69.  
  70.     if ((T_DL = tgetstr("dl", &cp)) == NULL)
  71.         T_DL = "";
  72.  
  73.     if ((T_SC = tgetstr("sc", &cp)) == NULL)
  74.         T_SC = "";
  75.  
  76.     if ((T_RC = tgetstr("rc", &cp)) == NULL)
  77.         T_RC = "";
  78.  
  79.     if ((T_CI = tgetstr("vi", &cp)) == NULL)
  80.         T_CI = "";
  81.  
  82.     if ((T_CV = tgetstr("ve", &cp)) == NULL)
  83.         T_CV = "";
  84.  
  85.     return 1;
  86. }
  87.  
  88. #endif
  89.