home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / STVI369G.ZIP / TERM.H < prev    next >
C/C++ Source or Header  |  1991-10-08  |  7KB  |  160 lines

  1. /* $Header: /nw/tony/src/stevie/src/RCS/term.h,v 1.7 89/08/01 17:25:18 tony Exp $
  2.  *
  3.  * System-dependent escape sequence definitions.
  4.  */
  5.  
  6. #ifdef TERMCAP
  7.    extern char *T_EL;        /* erase the entire current line */
  8.    extern char *T_IL;        /* insert one line */
  9.    extern char *T_DL;        /* delete one line */
  10.    extern char *T_SC;        /* save the cursor position */
  11.    extern char *T_ED;        /* erase display (may optionally home cursor) */
  12.    extern char *T_RC;        /* restore the cursor position */
  13.    extern char *T_CI;        /* invisible cursor (very optional) */
  14.    extern char *T_CV;        /* visible cursor (very optional) */
  15.    extern char *T_CM;        /* cursor motion string */
  16.  
  17. #else /* !TERMCAP */
  18. /*
  19.  * This file contains the machine dependent escape sequences that
  20.  * the editor needs to perform various operations. Some of the sequences
  21.  * here are optional. Anything not available should be indicated by
  22.  * a null string. In the case of insert/delete line sequences, the
  23.  * editor checks the capability and works around the deficiency, if
  24.  * necessary.
  25.  *
  26.  * Currently, insert/delete line sequences are used for screen scrolling.
  27.  * There are lots of terminals that have 'index' and 'reverse index'
  28.  * capabilities, but no line insert/delete. For this reason, the editor
  29.  * routines s_ins() and s_del() should be modified to use 'index'
  30.  * sequences when the line to be inserted or deleted is line zero.
  31.  */
  32.  
  33. /*
  34.  * The macro names here correspond (more or less) to the actual ANSI names
  35.  */
  36.  
  37. #  ifdef ATARI
  38. #    ifdef MINIX
  39. #      define    T_EL    "\033[2K"    /* erase the entire current line */
  40. #      define    T_IL    "\033[L"    /* insert one line */
  41. #      define    T_DL    "\033[M"    /* delete one line */
  42. #      define    T_SC    "\0337"        /* save the cursor position */
  43. #      define    T_ED    "\033[2J"     /* erase display (option:  home cursor) */
  44. #      define    T_RC    "\0338"        /* restore the cursor position */
  45. #      define    T_CI    ""        /* invisible cursor (very optional) */
  46. #      define    T_CV    ""        /* visible cursor (very optional) */
  47. #    else /* !MINIX */
  48. #      define    T_EL    "\033l"        /* erase the entire current line */
  49. #      define    T_IL    "\033L"        /* insert one line */
  50. #      define    T_DL    "\033M"        /* delete one line */
  51. #      define    T_SC    "\033j"        /* save the cursor position */
  52. #      define    T_ED    "\033E" /* erase display (may optionally home cursor) */
  53. #      define    T_RC    "\033k"        /* restore the cursor position */
  54. #      define    T_CI    "\033f"        /* invisible cursor (very optional) */
  55. #      define    T_CV    "\033e"        /* visible cursor (very optional) */
  56. #    endif /* ?MINIX */
  57. #  endif /* ATARI */
  58.  
  59. #  ifdef UNIX
  60. /*
  61.  * The following sequences are hard-wired for ansi-like terminals. To get
  62.  * termcap support, define TERMCAP in env.h and these sequences go away.
  63.  */
  64. #    define    T_EL    "\033[2K"    /* erase the entire current line */
  65. #    define    T_IL    "\033[L"    /* insert one line */
  66. #    define    T_DL    "\033[M"    /* delete one line */
  67. #    define    T_ED    "\033[2J"    /* erase display (may home cursor) */
  68. #    define    T_SC    "\0337"        /* save the cursor position */
  69. #    define    T_RC    "\0338"        /* restore the cursor position */
  70. #    define    T_CI    ""        /* invisible cursor (very optional) */
  71. #    define    T_CV    ""        /* visible cursor (very optional) */
  72. #  endif /* UNIX */
  73.  
  74.  
  75. #  ifdef OS2
  76. /*
  77.  * The OS/2 ansi console driver is pretty deficient. No insert or delete line
  78.  * sequences. The erase line sequence only erases from the cursor to the end
  79.  * of the line. For our purposes that works out okay, since the only time
  80.  * T_EL is used is when the cursor is in column 0.
  81.  *
  82.  * The insert/delete line sequences marked here are actually implemented in
  83.  * the file os2.c using direct OS/2 system calls. This makes the capability
  84.  * available for the rest of the editor via appropriate escape sequences
  85.  * passed to outstr().
  86.  */
  87. #    define    T_EL    "\033[K"    /* erase the entire current line */
  88. #    define    T_IL    "\033[L"    /* insert one line - fake (see os2.c) */
  89. #    define    T_DL    "\033[M"    /* delete one line - fake (see os2.c) */
  90. #    define    T_ED    "\033[2J"    /* erase display (may home cursor) */
  91. #    define    T_SC    "\033[s"    /* save the cursor position */
  92. #    define    T_RC    "\033[u"    /* restore the cursor position */
  93. #    define    T_CI    ""        /* invisible cursor (very optional) */
  94. #    define    T_CV    ""        /* visible cursor (very optional) */
  95. #  endif /* OS2 */
  96.  
  97.  
  98. #  ifdef DOS
  99. /*
  100.  * DOS sequences
  101.  *
  102.  * Some of the following sequences require the use of the "nansi.sys"
  103.  * console driver. The standard "ansi.sys" driver doesn't support
  104.  * sequences for insert/delete line.
  105.  */
  106. #    define    T_EL    "\033[K"    /* erase the entire current line */
  107. #    define    T_IL    "\033[L"    /* insert line (requires nansi.sys) */
  108. #    define    T_DL    "\033[M"    /* delete line (requires nansi.sys) */
  109. #    define    T_ED    "\033[2J"    /* erase display (may home cursor) */
  110. #    define    T_SC    "\033[s"    /* save the cursor position */
  111. #    define    T_RC    "\033[u"    /* restore the cursor position */
  112. #    define    T_CI    ""        /* invisible cursor (very optional) */
  113. #    define    T_CV    ""        /* visible cursor (very optional) */
  114. #  endif /* DOS */
  115.  
  116. #endif /* ?TERMCAP */
  117.  
  118. /*
  119.  * Machine-variant screen handling definitions.
  120.  *
  121.  * Define some macros which for invoking screen functions, whether by
  122.  * calling a bios function or outputting an escape sequence to be
  123.  * interpreted by a PC console driver or terminal.
  124.  *
  125.  * At this writing, not all of Stevie has been converted to use these
  126.  * macros.  So far, only DOS and PC BIOS versions are completely converted.
  127.  * Other versions are partly converted (because of changes I made in Stevie's
  128.  * common code), but they have not been tested.  I'll convert others which I'm
  129.  * in a position to test, but I'll leave any I can't test alone.  Hopefully,
  130.  * this will minimize any damage to working versions which I can't test. -LAS
  131.  */
  132.  
  133. #ifdef BIOS
  134. #  define    CANDL        TRUE        /* Can delete lines */
  135. #  define    CANIL        TRUE        /* Can insert lines */
  136. #  define    CLEOL        bios_t_el()    /* Erase to end-of-line */
  137. #  define    CLS        bios_t_ed()    /* Erase entire display */
  138. #  define    CRTDL(r,l)    bios_t_dl(r,l)    /* Delete lines from display */
  139. #  define    CRTIL(r,l)    bios_t_il(r,l)    /* Insert lines in display */
  140. #  define    CUROFF        bios_t_ci()    /* Make cursor invisible */
  141. #  define    CURON        bios_t_cv()    /* Make cursor visible */
  142. #  define    RESCUR        bios_t_rc()    /* Restore saved cursor pos. */
  143. #  define    SAVCUR        bios_t_sc()    /* Save cursor position */
  144. #else /* !BIOS */
  145. #  define    CANDL        (T_DL[0]!='\0')    /* see if can delete lines */
  146. #  define    CANIL        (T_IL[0]!='\0')    /* see if can insert lines */
  147. #  define    CLEOL        outstr(T_EL)    /* Erase to end-of-line */
  148. #  define    CLS        outstr(T_ED)    /* Erase entire display */
  149. #  define    CRTDL(r,l)    DO_DL(r,l)    /* Delete lines from display */
  150. #  define    CRTIL(r,l)    DO_IL(r,l)    /* Insert lines in display */
  151. #  define    CUROFF        outstr(T_CI)    /* Make cursor invisible */
  152. #  define    CURON        outstr(T_CV)    /* Make cursor visible */
  153. #  define    RESCUR        outstr(T_RC)    /* Restore saved cursor pos. */
  154. #  define    SAVCUR        outstr(T_SC)    /* Save cursor position */
  155. #  define    DO_DL(r,l)    {int __xx_knt = l; while (__xx_knt-- > 0) {outstr(T_DL);} }
  156. #  define    DO_IL(r,l)    {int __xx_knt = l; while (__xx_knt-- > 0) {outstr(T_IL);} }
  157. #endif /* ?BIOS */
  158.  
  159.  
  160.