home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / unix / pine4.10.tar.gz / pine4.10.tar / pine4.10 / pico / estruct.h < prev    next >
C/C++ Source or Header  |  1998-08-05  |  15KB  |  383 lines

  1. /*
  2.  * $Id: estruct.h,v 4.40 1998/08/05 18:20:08 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.  *
  18.  * Pine and Pico are registered trademarks of the University of Washington.
  19.  * No commercial use of these trademarks may be made without prior written
  20.  * permission of the University of Washington.
  21.  * 
  22.  * Pine, Pico, and Pilot software and its included text are Copyright
  23.  * 1989-1998 by the University of Washington.
  24.  * 
  25.  * The full text of our legal notices is contained in the file called
  26.  * CPYRIGHT, included with this distribution.
  27.  *
  28.  */
  29. /*    ESTRUCT:    Structure and preprocesser defined for
  30.             MicroEMACS 3.6
  31.  
  32.             written by Dave G. Conroy
  33.             modified by Steve Wilhite, George Jones
  34.             greatly modified by Daniel Lawrence
  35. */
  36.  
  37. #ifndef    ESTRUCT_H
  38. #define    ESTRUCT_H
  39.  
  40. /*    Configuration options    */
  41.  
  42. #define CVMVAS  1    /* arguments to page forward/back in pages    */
  43. #define    NFWORD    1    /* forward word jumps to begining of word    */
  44. #define    TYPEAH    0    /* type ahead causes update to be skipped    */
  45. #define    REVSTA    1    /* Status line appears in reverse video        */
  46.  
  47.  
  48. /*    internal constants    */
  49.  
  50. #define    NBINDS    50            /* max # of bound keys        */
  51. #ifdef    MAXPATHLEN
  52. #define NFILEN  MAXPATHLEN              /* # of bytes, file name        */
  53. #else
  54. #define NFILEN  80                      /* # of bytes, file name        */
  55. #endif
  56. #define NBUFN   16                      /* # of bytes, buffer name      */
  57. #define NLINE   256                     /* # of bytes, line             */
  58. #define    NSTRING    256            /* # of bytes, string buffers    */
  59. #define NPAT    80                      /* # of bytes, pattern          */
  60. #define FARAWAY 1000                    /* Huge number                  */
  61. #define    NLOCKS    100            /* max # of file locks active    */
  62.  
  63. #define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
  64. #define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
  65. #define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
  66. #define EXITCH  0x1D                    /* Exit level,  Control-]       */
  67. #define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
  68. #define HELPCH  0x1F                    /* Help key,    Control-_       */
  69.  
  70. #undef  CTRL
  71. #define CTRL    0x0100                  /* Control flag, or'ed in       */
  72. #define META    0x0200                  /* Meta flag, or'ed in          */
  73. #define CTLX    0x0400                  /* ^X flag, or'ed in            */
  74. #define    SPEC    0x0800            /* special key (arrow's, etc)    */
  75. #define    FUNC    0x1000            /* special key (function keys)    */
  76. #if    defined(DOS) || defined(OS2)
  77. #define    MENU    0x2000            /* Menu command            */
  78. #define    ALTD    0x4000            /* ALT key...            */
  79. #endif
  80.  
  81. #define    QNORML    0x0000            /* Flag meaning no flag ;)    */
  82. #define    QFFILE    0x0001            /* Flag buffer for file neme    */
  83. #define    QDEFLT    0x0002            /* Flag to use default answer    */
  84. #define    QBOBUF    0x0004            /* Start with cursor at BOL    */
  85. #define QNODQT  0x0008                /* Don't accept double quotes   */
  86.  
  87. #undef    FALSE
  88. #define FALSE   0                       /* False, no, bad, etc.         */
  89. #undef    TRUE
  90. #define TRUE    1                       /* True, yes, good, etc.        */
  91. #define ABORT   2                       /* Death, ^G, abort, etc.       */
  92.  
  93. #define FIOSUC  0                       /* File I/O, success.           */
  94. #define FIOFNF  1                       /* File I/O, file not found.    */
  95. #define FIOEOF  2                       /* File I/O, end of file.       */
  96. #define FIOERR  3                       /* File I/O, error.             */
  97. #define    FIOLNG    4            /*line longer than allowed len    */
  98. #define    FIODIR    5            /* File is a directory        */
  99. #define    FIONWT    6            /* File lacks write permission    */
  100. #define    FIONRD    7            /* File lacks read permission    */
  101. #define    FIONEX    8            /* File lacks exec permission    */
  102. #define    FIOSYM    9            /* File is a symbolic link    */
  103. #define    FIOPER    10            /* Generic permission denied    */
  104.  
  105.  
  106. #define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  107. #define CFKILL  0x0002                  /* Last command was a kill      */
  108. #define CFFILL  0x0004                  /* Last command was a kill      */
  109.  
  110. #define BACKSPACE    '\b'         /* backspace character  */
  111. #define TAB        '\t'            /* tab character        */
  112. #define RETURN        '\r'         /* carriage return char */
  113. #define LINE_FEED    '\n'         /* line feed character  */
  114. #define FORMFEED    '\f'         /* form feed (^L) char  */
  115. #define COMMA        ','        /* comma character      */
  116. #define SPACE        ' '        /* space character      */
  117. #define ESCAPE        '\033'        /* the escape        */
  118. #define    BELL        '\007'        /* the bell        */
  119. #define LPAREN        '('        /* left parenthesis    */
  120. #define RPAREN        ')'        /* right parenthesis    */
  121. #define BSLASH        '\\'        /* back slash        */
  122. #define QUOTE        '"'        /* double quote char    */
  123. #define DEL        '\177'        /* delete        */
  124.  
  125.  
  126. /*
  127.  * macros to help filter character input
  128.  */
  129. #define    LOBIT_CHAR(C)    ((C) > 0x1f && (C) < 0x7f)
  130. #define    HIBIT_CHAR(C)    ((C) > 0x7f && (C) <= 0xff)
  131. #define    HIBIT_OK(C)    (!(gmode & MDHBTIGN))
  132. #define    VALID_KEY(C)    (LOBIT_CHAR(C) || (HIBIT_OK(C) && HIBIT_CHAR(C)))
  133. #define ctrl(c)         ((c) & 0x1f)    /* control character mapping */
  134.  
  135. #define STDIN_FD    0
  136. #define STDOUT_FD    1
  137. #define STDERR_FD    2
  138.  
  139.  
  140. /*
  141.  * Placeholders for keymenu tags used in some ports  (well, only in the
  142.  * windows port for now) to turn on commands in the Menu Bar.
  143.  */
  144. #ifndef    KS_OSDATAVAR
  145. #define    KS_OSDATAVAR
  146. #define    KS_OSDATAGET(X)
  147. #define    KS_OSDATASET(X, Y)
  148.  
  149. #define KS_NONE
  150. #define KS_VIEW
  151. #define KS_EXPUNGE
  152. #define KS_ZOOM
  153. #define KS_SORT
  154. #define KS_HDRMODE
  155. #define KS_MAINMENU
  156. #define KS_FLDRLIST
  157. #define KS_FLDRINDEX
  158. #define KS_COMPOSER
  159. #define KS_PREVPAGE
  160. #define KS_PREVMSG
  161. #define KS_NEXTMSG
  162. #define KS_ADDRBOOK
  163. #define KS_WHEREIS
  164. #define KS_PRINT
  165. #define KS_REPLY
  166. #define KS_FORWARD
  167. #define KS_BOUNCE
  168. #define KS_DELETE
  169. #define KS_UNDELETE
  170. #define KS_FLAG
  171. #define KS_SAVE
  172. #define KS_EXPORT
  173. #define KS_TAKEADDR
  174. #define KS_SELECT
  175. #define KS_APPLY
  176. #define KS_POSTPONE
  177. #define KS_SEND
  178. #define KS_CANCEL
  179. #define KS_ATTACH
  180. #define KS_TOADDRBOOK
  181. #define KS_READFILE
  182. #define KS_JUSTIFY
  183. #define KS_ALTEDITOR
  184. #define KS_GENERALHELP
  185. #define KS_SCREENHELP
  186. #define KS_EXIT
  187. #define KS_NEXTPAGE
  188. #define KS_SAVEFILE
  189. #define KS_CURPOSITION
  190. #define KS_GOTOFLDR
  191. #define KS_JUMPTOMSG
  192. #define KS_RICHHDR
  193. #define KS_EXITMODE
  194. #define KS_REVIEW
  195. #define KS_KEYMENU
  196. #define KS_SELECTCUR
  197. #define KS_UNDO
  198. #define KS_SPELLCHK
  199. #endif
  200.  
  201.  
  202. /*
  203.  * There is a window structure allocated for every active display window. The
  204.  * windows are kept in a big list, in top to bottom screen order, with the
  205.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  206.  * The flag field contains some bits that are set by commands to guide
  207.  * redisplay; although this is a bit of a compromise in terms of decoupling,
  208.  * the full blown redisplay is just too expensive to run for every input
  209.  * character.
  210.  */
  211. typedef struct  WINDOW {
  212.         struct  WINDOW *w_wndp;         /* Next window                  */
  213.         struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  214.         struct  LINE *w_linep;          /* Top line in the window       */
  215.         struct  LINE *w_dotp;           /* Line containing "."          */
  216.         int     w_doto;                 /* Byte offset for "."          */
  217.         struct  LINE *w_markp;          /* Line containing "mark"       */
  218.         int    w_marko;                /* Byte offset for "mark"       */
  219.         struct  LINE *w_imarkp;         /* INTERNAL Line with "mark"    */
  220.         int    w_imarko;               /* INTERNAL "mark" byte offset  */
  221.         char    w_toprow;               /* Origin 0 top row of window   */
  222.         char    w_ntrows;               /* # of rows of text in window  */
  223.         char    w_force;                /* If NZ, forcing row.          */
  224.         char    w_flag;                 /* Flags.                       */
  225. }       WINDOW;
  226.  
  227. #define WFFORCE 0x01                    /* Window needs forced reframe  */
  228. #define WFMOVE  0x02                    /* Movement from line to line   */
  229. #define WFEDIT  0x04                    /* Editing within a line        */
  230. #define WFHARD  0x08                    /* Better to a full display     */
  231. #define WFMODE  0x10                    /* Update mode line.            */
  232.  
  233. /*
  234.  * Text is kept in buffers. A buffer header, described below, exists for every
  235.  * buffer in the system. The buffers are kept in a big list, so that commands
  236.  * that search for a buffer by name can find the buffer header. There is a
  237.  * safe store for the dot and mark in the header, but this is only valid if
  238.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  239.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  240.  * the header line in "b_linep".
  241.  *     Buffers may be "Inactive" which means the files accosiated with them
  242.  * have not been read in yet. These get read in at "use buffer" time.
  243.  */
  244. typedef struct  BUFFER {
  245.     struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  246.     struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  247.     int    b_doto;                 /* Offset of "." in above LINE  */
  248.     struct  LINE *b_markp;          /* The same as the above two,   */
  249.         int    b_marko;                /* but for the "mark"           */
  250.     struct  LINE *b_linep;          /* Link to the header LINE      */
  251.     long    b_linecnt;        /* Lines in buffer (mswin only)    */
  252.     long    b_mode;            /* editor mode of this buffer    */
  253.     char    b_active;        /* window activated flag    */
  254.     char    b_nwnd;                 /* Count of windows on buffer   */
  255.     char    b_flag;                 /* Flags                        */
  256.     char    b_fname[NFILEN];        /* File name                    */
  257.     char    b_bname[NBUFN];         /* Buffer name                  */
  258. }    BUFFER;
  259.  
  260. #define BFTEMP     0x01                    /* Internal temporary buffer     */
  261. #define BFCHG      0x02                    /* Changed since last write      */
  262. #define BFWRAPOPEN 0x04                    /* Wordwrap should open new line */
  263.  
  264.  
  265. /*
  266.  * The starting position of a region, and the size of the region in
  267.  * characters, is kept in a region structure.  Used by the region commands.
  268.  */
  269. typedef struct  {
  270.         struct  LINE *r_linep;          /* Origin LINE address.         */
  271.         int    r_offset;               /* Origin LINE offset.          */
  272.         long    r_size;                 /* Length in characters.        */
  273. }       REGION;
  274.  
  275.  
  276. /*
  277.  * character and attribute pair.  The basic building block
  278.  * of the editor.  The bitfields may have to be changed to a char
  279.  * and short if there are problems...
  280.  */
  281. typedef    struct CELL {
  282.     unsigned int c : 8;        /* Character value in cell      */
  283.     unsigned int a : 8;        /* Its attributes               */
  284. } CELL;
  285.  
  286.  
  287. /*
  288.  * All text is kept in circularly linked lists of "LINE" structures. These
  289.  * begin at the header line (which is the blank line beyond the end of the
  290.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  291.  * number of bytes in the line (the "used" size), the size of the text array,
  292.  * and the text. The end of line is not stored as a byte; it's implied. Future
  293.  * additions will include update hints, and a list of marks into the line.
  294.  */
  295. typedef struct  LINE {
  296.         struct  LINE *l_fp;             /* Link to the next line        */
  297.         struct  LINE *l_bp;             /* Link to the previous line    */
  298.         int     l_size;                 /* Allocated size               */
  299.         int     l_used;                 /* Used size                    */
  300.         CELL    l_text[1];              /* A bunch of characters.       */
  301. }       LINE;
  302.  
  303. #define lforw(lp)       ((lp)->l_fp)
  304. #define lback(lp)       ((lp)->l_bp)
  305. #define lgetc(lp, n)    ((lp)->l_text[(n)])
  306. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  307. #define llength(lp)     ((lp)->l_used)
  308.  
  309. /*
  310.  * The editor communicates with the display using a high level interface. A
  311.  * "TERM" structure holds useful variables, and indirect pointers to routines
  312.  * that do useful operations. The low level get and put routines are here too.
  313.  * This lets a terminal, in addition to having non standard commands, have
  314.  * funny get and put character code too. The calls might get changed to
  315.  * "termp->t_field" style in the future, to make it possible to run more than
  316.  * one terminal type.
  317.  */
  318. typedef struct  {
  319.         short   t_nrow;                 /* Number of rows - 1.          */
  320.         short   t_ncol;                 /* Number of columns.           */
  321.     short    t_margin;        /* min margin for extended lines*/
  322.     short    t_scrsiz;        /* size of scroll region "    */
  323.         short   t_mrow;                 /* Number of rows in menu       */
  324.         int     (*t_open)();            /* Open terminal at the start.  */
  325.         int    (*t_terminalinfo)();    /* Set up terminal info         */
  326.         int     (*t_close)();           /* Close terminal at end.       */
  327.         int     (*t_getchar)();         /* Get character from keyboard. */
  328.         int     (*t_putchar)();         /* Put character to display.    */
  329.         int     (*t_flush)();           /* Flush output buffers.        */
  330.         int     (*t_move)();            /* Move the cursor, origin 0.   */
  331.         int     (*t_eeol)();            /* Erase to end of line.        */
  332.         int     (*t_eeop)();            /* Erase to end of page.        */
  333.         int     (*t_beep)();            /* Beep.                        */
  334.     int    (*t_rev)();        /* set reverse video state    */
  335. }       TERM;
  336.  
  337. /*    structure for the table of initial key bindings        */
  338.  
  339. typedef struct  {
  340.         short   k_code;                 /* Key code                     */
  341.         int     (*k_fp)();              /* Routine to handle it         */
  342. }       KEYTAB;
  343.  
  344. /*      sturcture used for key menu painting         */
  345.  
  346. typedef struct {
  347.     char    *name;            /* key to display          */
  348.     char    *label;            /* function name key envokes    */
  349.     KS_OSDATAVAR            /* port-specific data */
  350. }    KEYMENU;
  351.  
  352. typedef struct {
  353.     char    *name;            /* key to display          */
  354.     char    *label;            /* function name key envokes    */
  355.     int    key;            /* what to watch for and return    */
  356.     KS_OSDATAVAR            /* port-specific data */
  357. }    EXTRAKEYS;
  358.  
  359. typedef struct    VIDEO {
  360.     short    v_flag;            /* Flags */
  361.     CELL    v_text[1];        /* Screen data. */
  362. }    VIDEO;
  363.  
  364. typedef    struct _file_io_data {
  365.     FILE *fp;            /* stdio stream into file */
  366.         long  flags;            /* state flags */
  367.     char *name;            /* pointer to file name */
  368. }    FIOINFO;
  369.  
  370. #define    FIOINFO_READ    0x01
  371. #define    FIOINFO_WRITE    0x02
  372.  
  373. #ifdef    MOUSE
  374.  
  375. /* Test if mouse position (R, C) is in menu item (X) */
  376. #define    M_ACTIVE(R, C, X)    (((unsigned)(R)) >= (X)->tl.r       \
  377.                     && ((unsigned)(R)) <= (X)->br.r \
  378.                     && ((unsigned)(C)) >= (X)->tl.c \
  379.                     && ((unsigned)(C)) < (X)->br.c)
  380. #endif    /* MOUSE */
  381.  
  382. #endif    /* ESTRUCT_H */
  383.