home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / pine / pico / estruct.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-06  |  16.0 KB  |  278 lines

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