home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pine / pine3.07 / pico / estruct.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-30  |  11.8 KB  |  262 lines

  1. /*
  2.  * Program:    Struct and preprocessor definitions
  3.  *
  4.  * Modifier:    Michael Seibel
  5.  *        Networks and Distributed Computing
  6.  *        Computing & Communications
  7.  *        University of Washington
  8.  *        Administration Building, AG-44
  9.  *        Seattle, WA  98195
  10.  *        Internet: mikes@cac.washington.edu
  11.  *
  12.  * Date:    19 Jan 1991
  13.  * Last Edited:    6 Jan 1992
  14.  *
  15.  * Copyright 1991 by the University of Washington
  16.  *
  17.  *  Permission to use, copy, modify, and distribute this software and its
  18.  * documentation for any purpose and without fee is hereby granted, provided
  19.  * that the above copyright notice appears in all copies and that both the
  20.  * above copyright notice and this permission notice appear in supporting
  21.  * documentation, and that the name of the University of Washington not be
  22.  * used in advertising or publicity pertaining to distribution of the software
  23.  * without specific, written prior permission.  This software is made
  24.  * available "as is", and
  25.  * THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
  26.  * WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED
  27.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
  28.  * NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
  29.  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  30.  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
  31.  * (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
  32.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  33.  *
  34.  */
  35. /*    ESTRUCT:    Structure and preprocesser defined for
  36.             MicroEMACS 3.6
  37.  
  38.             written by Dave G. Conroy
  39.             modified by Steve Wilhite, George Jones
  40.             greatly modified by Daniel Lawrence
  41. */
  42.  
  43. #ifndef    ESTRUCT_H
  44. #define    ESTRUCT_H
  45.  
  46.  
  47. /*    Terminal Output definitions        */
  48.  
  49. #define ANSI    0            /* ansi escape sequences    */
  50. #define VT100   0                       /* Handle VT100 style keypad.   */
  51. #define LK201   0                       /* Handle LK201 style keypad.   */
  52.  
  53. /*    Configuration options    */
  54.  
  55. #define CVMVAS  1    /* arguments to page forward/back in pages    */
  56. #define    NFWORD    1    /* forward word jumps to begining of word    */
  57. #define    TYPEAH    0    /* type ahead causes update to be skipped    */
  58. #define    REVSTA    1    /* Status line appears in reverse video        */
  59.  
  60.  
  61. /*    internal constants    */
  62.  
  63. #define    NBINDS    200            /* max # of bound keys        */
  64. #define NFILEN  80                      /* # of bytes, file name        */
  65. #define NBUFN   16                      /* # of bytes, buffer name      */
  66. #define NLINE   256                     /* # of bytes, line             */
  67. #define    NSTRING    256            /* # of bytes, string buffers    */
  68. #define NKBDM   256                     /* # of strokes, keyboard macro */
  69. #define NPAT    80                      /* # of bytes, pattern          */
  70. #undef    HUGE
  71. #define HUGE    1000                    /* Huge number                  */
  72. #define    NLOCKS    100            /* max # of file locks active    */
  73.  
  74. #define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
  75. #define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
  76. #define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
  77. #define EXITCH  0x1D                    /* Exit level,  Control-]       */
  78. #define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
  79. #define HELPCH  0x1F                    /* Help key,    Control-_       */
  80.  
  81. #undef  CTRL
  82. #define CTRL    0x0100                  /* Control flag, or'ed in       */
  83. #define META    0x0200                  /* Meta flag, or'ed in          */
  84. #define CTLX    0x0400                  /* ^X flag, or'ed in            */
  85. #define    SPEC    0x0800            /* special key (arrow's, etc)    */
  86. #define    FUNC    0x1000            /* special key (function keys)    */
  87. #if    MSDOS
  88. #define    SHFT    0x2000            /* shifted (for function keys)    */
  89. #define    ALTD    0x4000            /* ALT key...            */
  90. #endif
  91.  
  92. #define    QNORML    0x0000            /* Flag meaning no flag ;)    */
  93. #define    QFFILE    0x0001            /* Flag buffer for file neme    */
  94. #define    QDEFLT    0x0002            /* Flag to use default answer    */
  95.  
  96. #undef    FALSE
  97. #define FALSE   0                       /* False, no, bad, etc.         */
  98. #undef    TRUE
  99. #define TRUE    1                       /* True, yes, good, etc.        */
  100. #define ABORT   2                       /* Death, ^G, abort, etc.       */
  101.  
  102. #define FIOSUC  0                       /* File I/O, success.           */
  103. #define FIOFNF  1                       /* File I/O, file not found.    */
  104. #define FIOEOF  2                       /* File I/O, end of file.       */
  105. #define FIOERR  3                       /* File I/O, error.             */
  106. #define    FIOLNG    4            /*line longer than allowed len    */
  107. #define    FIODIR    5            /* File is a directory        */
  108. #define    FIONWT    6            /* File lacks write permission    */
  109. #define    FIONRD    7            /* File lacks read permission    */
  110. #define    FIONEX    8            /* File lacks exec permission    */
  111.  
  112.  
  113. #define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  114. #define CFKILL  0x0002                  /* Last command was a kill      */
  115. #define CFFILL  0x0004                  /* Last command was a kill      */
  116.  
  117. #define    BELL    0x07            /* a bell character        */
  118. #define    TAB    0x09            /* a tab character        */
  119.  
  120.  
  121. /*
  122.  * There is a window structure allocated for every active display window. The
  123.  * windows are kept in a big list, in top to bottom screen order, with the
  124.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  125.  * The flag field contains some bits that are set by commands to guide
  126.  * redisplay; although this is a bit of a compromise in terms of decoupling,
  127.  * the full blown redisplay is just too expensive to run for every input
  128.  * character.
  129.  */
  130. typedef struct  WINDOW {
  131.         struct  WINDOW *w_wndp;         /* Next window                  */
  132.         struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  133.         struct  LINE *w_linep;          /* Top line in the window       */
  134.         struct  LINE *w_dotp;           /* Line containing "."          */
  135.         short   w_doto;                 /* Byte offset for "."          */
  136.         struct  LINE *w_markp;          /* Line containing "mark"       */
  137.         short   w_marko;                /* Byte offset for "mark"       */
  138.         char    w_toprow;               /* Origin 0 top row of window   */
  139.         char    w_ntrows;               /* # of rows of text in window  */
  140.         char    w_force;                /* If NZ, forcing row.          */
  141.         char    w_flag;                 /* Flags.                       */
  142. }       WINDOW;
  143.  
  144. #define WFFORCE 0x01                    /* Window needs forced reframe  */
  145. #define WFMOVE  0x02                    /* Movement from line to line   */
  146. #define WFEDIT  0x04                    /* Editing within a line        */
  147. #define WFHARD  0x08                    /* Better to a full display     */
  148. #define WFMODE  0x10                    /* Update mode line.            */
  149.  
  150. /*
  151.  * Text is kept in buffers. A buffer header, described below, exists for every
  152.  * buffer in the system. The buffers are kept in a big list, so that commands
  153.  * that search for a buffer by name can find the buffer header. There is a
  154.  * safe store for the dot and mark in the header, but this is only valid if
  155.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  156.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  157.  * the header line in "b_linep".
  158.  *     Buffers may be "Inactive" which means the files accosiated with them
  159.  * have not been read in yet. These get read in at "use buffer" time.
  160.  */
  161. typedef struct  BUFFER {
  162.         struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  163.         struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  164.         short   b_doto;                 /* Offset of "." in above LINE  */
  165.         struct  LINE *b_markp;          /* The same as the above two,   */
  166.         short   b_marko;                /* but for the "mark"           */
  167.         struct  LINE *b_linep;          /* Link to the header LINE      */
  168.     char    b_active;        /* window activated flag    */
  169.         char    b_nwnd;                 /* Count of windows on buffer   */
  170.         char    b_flag;                 /* Flags                        */
  171.     char    b_mode;            /* editor mode of this buffer    */
  172.         char    b_fname[NFILEN];        /* File name                    */
  173.         char    b_bname[NBUFN];         /* Buffer name                  */
  174. }       BUFFER;
  175.  
  176. #if TERMCAP || TERMINFO
  177. struct  KBSTREE {
  178.     char    value;
  179.         int     func;              /* Routine to handle it         */
  180.     struct    KBSTREE *down; 
  181.     struct    KBSTREE    *left;
  182. };
  183. #endif
  184.  
  185. #define BFTEMP  0x01                    /* Internal temporary buffer    */
  186. #define BFCHG   0x02                    /* Changed since last write     */
  187.  
  188.  
  189. /*
  190.  * The starting position of a region, and the size of the region in
  191.  * characters, is kept in a region structure.  Used by the region commands.
  192.  */
  193. typedef struct  {
  194.         struct  LINE *r_linep;          /* Origin LINE address.         */
  195.         short   r_offset;               /* Origin LINE offset.          */
  196.         short   r_size;                 /* Length in characters.        */
  197. }       REGION;
  198.  
  199. /*
  200.  * All text is kept in circularly linked lists of "LINE" structures. These
  201.  * begin at the header line (which is the blank line beyond the end of the
  202.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  203.  * number of bytes in the line (the "used" size), the size of the text array,
  204.  * and the text. The end of line is not stored as a byte; it's implied. Future
  205.  * additions will include update hints, and a list of marks into the line.
  206.  */
  207. typedef struct  LINE {
  208.         struct  LINE *l_fp;             /* Link to the next line        */
  209.         struct  LINE *l_bp;             /* Link to the previous line    */
  210.         short   l_size;                 /* Allocated size               */
  211.         short   l_used;                 /* Used size                    */
  212.         char    l_text[1];              /* A bunch of characters.       */
  213. }       LINE;
  214.  
  215. #define lforw(lp)       ((lp)->l_fp)
  216. #define lback(lp)       ((lp)->l_bp)
  217. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  218. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  219. #define llength(lp)     ((lp)->l_used)
  220.  
  221. /*
  222.  * The editor communicates with the display using a high level interface. A
  223.  * "TERM" structure holds useful variables, and indirect pointers to routines
  224.  * that do useful operations. The low level get and put routines are here too.
  225.  * This lets a terminal, in addition to having non standard commands, have
  226.  * funny get and put character code too. The calls might get changed to
  227.  * "termp->t_field" style in the future, to make it possible to run more than
  228.  * one terminal type.
  229.  */
  230. typedef struct  {
  231.         short   t_nrow;                 /* Number of rows.              */
  232.         short   t_ncol;                 /* Number of columns.           */
  233.     short    t_margin;        /* min margin for extended lines*/
  234.     short    t_scrsiz;        /* size of scroll region "    */
  235.         int     (*t_open)();            /* Open terminal at the start.  */
  236.         int     (*t_close)();           /* Close terminal at end.       */
  237.         int     (*t_getchar)();         /* Get character from keyboard. */
  238.         int     (*t_putchar)();         /* Put character to display.    */
  239.         int     (*t_flush)();           /* Flush output buffers.        */
  240.         int     (*t_move)();            /* Move the cursor, origin 0.   */
  241.         int     (*t_eeol)();            /* Erase to end of line.        */
  242.         int     (*t_eeop)();            /* Erase to end of page.        */
  243.         int     (*t_beep)();            /* Beep.                        */
  244.     int    (*t_rev)();        /* set reverse video state    */
  245. }       TERM;
  246.  
  247. /*    structure for the table of initial key bindings        */
  248.  
  249. typedef struct  {
  250.         short   k_code;                 /* Key code                     */
  251.         int     (*k_fp)();              /* Routine to handle it         */
  252. }       KEYTAB;
  253.  
  254. /*    structure for the name binding table        */
  255.  
  256. typedef struct {
  257.     char *n_name;        /* name of function key */
  258.     int (*n_func)();    /* function name is bound to */
  259. }    NBIND;
  260.  
  261. #endif    /* ESTRUCT_H */
  262.