home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1740 / cledio.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  6.7 KB  |  199 lines

  1. /*
  2.     $Id: cledio.h,v 2.5 90/08/26 11:35:00 sw Exp $
  3. */
  4.  
  5. /*
  6.     CLED will be active only if this options are set
  7. */
  8.  
  9. #define CLEDFLAGS    (ICANON|ECHO|ECHOE|ECHOK)
  10.  
  11. /*
  12.     Terminal capabilities remembered by CLED
  13. */
  14.  
  15. #define TCAP_CLREOL_STR        "\033[K"    /* clear to eol        */
  16. #define TCAP_SETINV_STR        "\033[7m"    /* set inverse video    */
  17. #define TCAP_SETNORM_STR    "\033[m"    /* set normal video    */
  18. #define TCAP_SAVE_STR        "\0337"        /* save cursor pos and attr */
  19. #define TCAP_RESTORE_STR    "\0338"        /* restore pos and attr    */
  20. #define TCAP_FLASH_STR        "\007"        /* ring bell or similar    */
  21.  
  22. #define TCAP_CLREOL    0
  23. #define TCAP_SETINV    1
  24. #define TCAP_SETNORM    2
  25. #define TCAP_SAVE    3
  26. #define TCAP_RESTORE    4
  27. #define TCAP_FLASH    5
  28. #define TCAP_COUNT    6            /* last one indicates total */
  29.  
  30. /*
  31.     ioctl codes available
  32. */
  33.  
  34. #define LDIOC        ('D'<<8)
  35.  
  36. /*
  37.     Ioctls on the line discipline itself
  38. */
  39.  
  40. #define LDGETCOLS   (LDIOC|14)        /* Get terminal line length        */
  41. #define LDSETCOLS   (LDIOC|15)        /* Set terminal line length        */
  42.  
  43. #define LDGETBF        (LDIOC|16)        /* get bindings & capabilities    */
  44. #define LDSETBF        (LDIOC|17)        /* set bindings & capabilities    */
  45.  
  46. #define LDGETHB        (LDIOC|18)        /* get history buffer        */
  47. #define LDSETHB        (LDIOC|19)        /* set history buffer        */
  48.  
  49. /*
  50.     Ioctls on the CLED driver in general
  51. */
  52.  
  53. #define LDGETS        (LDIOC|20)        /* get cled stats            */
  54.  
  55. #define LDGETB        (LDIOC|21)        /* dump its guts (debug mode only)    */
  56. #define LDGETTTY    (LDIOC|22)        /* dump a tty struct (debug mode only) */
  57. #define LDGETC        (LDIOC|23)        /* dump contents of a clist (debug only) */
  58.  
  59. /*
  60.     Error codes returned from ioctl functions
  61. */
  62.  
  63. #define ERR_NOTTYBUF    12        /* ENOMEM no more ttybufs available */
  64. #define ERR_NOLEDBUF    11        /* EAGAIN no more ledbufs available */
  65. #define ERR_NOLBASS    19        /* ENODEV no led buf assigned to process */
  66. #define ERR_BADPARAM    22        /* EINVAL bad paramater value */
  67. #define ERR_BADIOCTL    33        /* EDOM bad ioctl function */
  68.  
  69. /*
  70.     Pass the address of this struct to LDGETS
  71. */
  72.  
  73. struct cle_stats
  74. {
  75.     int            ledbufs;        /* max number of led_buffers    */
  76.     int            ttybufs;        /* max number of tty_buffers    */
  77.     int            promptsize;        /* size of prompt buffer        */
  78.     int            linesize;        /* size of command buffer        */
  79.     int            histsize;        /* size of history buffer        */
  80.     int            multi_lb;        /* t/f flag indicating multi-lb mode */
  81.     int            spt;        /* t/f flag indicating using sptalloc */
  82.     int            tcapsize;        /* max length of all ascii strings    */
  83.     int            ledbufs_used;   /* number of led_buf's in use    */
  84.     int            ttybufs_used;   /* number of tty_buf's in use    */
  85.     int            line;        /* cled's line discipline number    */
  86.     char        vers[4];        /* version #            */
  87. };
  88.  
  89. /*
  90.     Pass the address of this struct to LDGETB/LDSETB
  91. */
  92.  
  93. struct cle_buf
  94. {
  95.     int            lbsize;
  96.     int            tbsize;
  97.     struct led_buf  *lbbase;
  98.     struct led_buf  *lbfree;
  99.     struct tty_buf  *tbbase;
  100.     struct tty_buf  *tbused;
  101.     struct tty_buf  *tbfree;
  102.     struct proc        *procbase;
  103. };
  104.  
  105. /*
  106.     Pass this struct for LDGETF/LDSETF.
  107.  
  108.     The following structure is passed to the ioctl routine to
  109.     /dev/cled to assign the key bindings and the TCAP sequences
  110.     (and other strings) desired for various functions.
  111.  
  112.     If the ioctl completes with an error, then the len fields of
  113.     the struct will have been changed to an index into the
  114.     respective buffer at which the error occured (the driver sets
  115.     the value).
  116.  
  117.     The key buffer immediately follows the set_key struct and the
  118.     TCAP buffer immediately follows the key buffer.
  119.  
  120.     The key buffer contains pairs of chars; the first is the key
  121.     number and the second is the function number.  The kdbuf_len
  122.     entry in the set_key struct contains the total number of these
  123.     pairs of chars.  Any of the control keys and/or keypad keys can
  124.     be set to any function at any time.  New definitions replace
  125.     previous definitions.  Keys not explicitly defined in the
  126.     buffer are left defined to whatever they were.
  127.  
  128.     The TCAP buffer consists of a stream of null terminated strings
  129.     preceeded by the number of the sequence to which the string
  130.     belongs.  If any TCAP sequence is defined, then ALL the
  131.     sequences are first reset to their defaults and then replaced
  132.     with the new definitions.  That is, you can change one or all,
  133.     but unlike the key definitions, you cannot change just one
  134.     without affecting all the others.
  135. */
  136.  
  137. struct set_key
  138. {
  139.     int                     modes;        /* default mode bits        */
  140.     int                     kdbuf_len;        /* key buffer length (in items) */
  141.     int                     tcapbuf_len;    /* length of escapes (in chars) */
  142. };
  143.  
  144. /*
  145.     We implement a very contrived set of key bindings; we have
  146.     the 32 control characters, then 96 meta characters, then
  147.     DEL. We don't provide for bindint to x or M-C-x, only
  148.     either C-x or M-x.
  149.  
  150.     To bind to M-x, use CLEKEY_ESC(x), to bind to C-x, use CLEKEY_CTL(x).
  151. */
  152.  
  153. #define CLEKEY_CHAR(c)    ((c) >= ' ' && (c) <= '~')
  154.  
  155. #define CLEKEY_CMD(c)    ((c)&0x7F)
  156. #define CLEKEY_ESC(c)    ((c)&0x7F)
  157. #define CLEKEY_CTL(c)    ((c)&0x1F)
  158. #define CLEKEY_DEL    0x7F
  159.  
  160. #define CLEKEY_MAX    0x80
  161.  
  162. /*
  163.     default modes
  164. */
  165.  
  166. #define CLEMODE_INSERT    0x01    /* insert mode */
  167. #define CLEMODE_OVER    0x02    /* overstrike mode */
  168.  
  169. /*
  170.     Editor functions: (don't change the order of these)
  171. */
  172.  
  173. #define CLEFUN_CHAR    0x00    /* insert character into buffer        */
  174. #define CLEFUN_INSERT    0x01    /* toggle insert/overstrike mode    */
  175. #define CLEFUN_GOTOBOL    0x02    /* goto beginning of line        */
  176. #define CLEFUN_GOTOEOL    0x03    /* goto end of line            */
  177. #define CLEFUN_DELWLFT    0x04    /* delete word to left of cursor    */
  178. #define CLEFUN_DELWRIT    0x05    /* delete word to right of cursor    */
  179. #define CLEFUN_DELBOL    0x06    /* delete from cursor to beginning of line */
  180. #define CLEFUN_DELEOL    0x07    /* delete from cursor to end of line    */
  181. #define CLEFUN_CURSL    0x08    /* move cursor left 1 position        */
  182. #define CLEFUN_CURSR    0x09    /* move cursor right 1 position        */
  183. #define CLEFUN_DELCLFT    0x0A    /* delete char left of cursor        */
  184. #define CLEFUN_DELCRIT    0x0B    /* delete char under cursor        */
  185. #define CLEFUN_REFRESH    0x0C    /* reprint the current line        */
  186. #define CLEFUN_PREVIOUS    0x0D    /* recall previous command        */
  187. #define CLEFUN_NEXT    0x0E    /* recall next command            */
  188. #define CLEFUN_FIND    0x0F    /* find matching string            */
  189. #define CLEFUN_NEWLINE    0x10    /* end of line                */
  190. #define CLEFUN_ESCAPE    0x11    /* "escape" the next character        */
  191. #define CLEFUN_NOP    0x12    /* nop                    */
  192. #define CLEFUN_BELL    0x13    /* ring bell                */
  193. #define CLEFUN_SKIPWL    0x14    /* skip word left            */
  194. #define CLEFUN_SKIPWR    0x15    /* skip word right            */
  195. #define CLEFUN_PURGE    0x16    /* purge all typeahead            */
  196. #define CLEFUN_META    0x17    /* access chars with 8th bit on        */
  197. #define CLEFUN_ANSI    0x18    /* parse ansi cursor sequence        */
  198. #define CLEFUN_MAX    0x19    /* number of functions            */
  199.