home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 198_01 / estruct.h < prev    next >
C/C++ Source or Header  |  1990-01-23  |  25KB  |  731 lines

  1. /*    ESTRUCT:    Structure and preprocesser defined for
  2.             MicroEMACS 3.9
  3.  
  4.             written by Dave G. Conroy
  5.             modified by Steve Wilhite, George Jones
  6.             substantially modified by Daniel Lawrence
  7. */
  8.  
  9. #ifdef    LATTICE
  10. #undef    LATTICE        /* don't use their definitions...use ours    */
  11. #endif
  12. #ifdef    MSDOS
  13. #undef    MSDOS
  14. #endif
  15. #ifdef    CPM
  16. #undef    CPM
  17. #endif
  18. #ifdef    AMIGA
  19. #undef    AMIGA
  20. #endif
  21. #ifdef    EGA
  22. #undef    EGA
  23. #endif
  24.  
  25. /*    Program Identification.....
  26.  
  27.     PROGNAME should always be MicroEMACS for a distibrution
  28.     unmodified version. People using MicroEMACS as a shell
  29.     for other products should change this to reflect their
  30.     product. Macros can query this via the $progname variable
  31. */
  32.  
  33. #define    PROGNAME    "MicroEMACS"
  34. #define    VERSION        "3.9"
  35.  
  36. /*    Machine/OS definitions            */
  37.  
  38. #define AMIGA   0                       /* AmigaDOS            */
  39. #define ST520   0                       /* ST520, TOS                   */
  40. #define MSDOS   1                       /* MS-DOS                       */
  41. #define V7      0                       /* V7 UNIX or Coherent or BSD4.2*/
  42. #define    BSD    0            /* UNIX BSD 4.2    and ULTRIX    */
  43. #define    BSD29    0            /* BSD2.9 - also needs BSD set    */
  44. #define    USG    0            /* UNIX system V        */
  45. #define VMS     0                       /* VAX/VMS                      */
  46. #define CPM     0                       /* CP/M-86                      */
  47. #define    FINDER    0            /* Macintosh OS            */
  48. #define    WMCS    0            /* Wicat's MCS            */
  49. #define    DECUSC    0            /* RSX11M with DECUS C compiler */
  50.  
  51. /*    Compiler definitions            */
  52. #define    UNIX    0    /* a random UNIX compiler */
  53. #define MWC86   0    /* marc williams compiler */
  54. #define    LATTICE    0    /* Lattice 2.14 thruough 3.0 compilers */
  55. #define    AZTEC    0    /* Aztec C 3.20e */
  56. #define    MSC    0    /* MicroSoft C compile version 3, 4 & 5 + Xenix */
  57. #define    TURBO    1    /* Turbo C/MSDOS */
  58. #define    DTL    0    /* DataLight C v3.12 */
  59. #define MEGAMAX    0    /* Megamax C compiler */
  60. #define    C86    0    /* CI compiler */
  61.  
  62. /*    Debugging options    */
  63. #define    RAMSIZE    0    /* dynamic RAM memory usage tracking */
  64. #define    RAMSHOW    0    /* auto dynamic RAM reporting */
  65.  
  66. /*   Special keyboard definitions            */
  67.  
  68. #define WANGPC    0        /* WangPC - mostly escape sequences     */
  69.  
  70. /*    Terminal Output definitions        */
  71.  
  72. #define ANSI    0            /* ANSI escape sequences    */
  73. #define    HP150    0            /* HP150 screen driver        */
  74. #define    HP110    0            /* HP110 screen driver        */
  75. #define    VMSVT    0            /* various VMS terminal entries    */
  76. #define VT52    0                       /* VT52 terminal (Zenith).      */
  77. #define VT100   0                       /* Handle VT100 style keypad.   */
  78. #define RAINBOW 0                       /* Use Rainbow fast video.      */
  79. #define TERMCAP 0                       /* Use TERMCAP                  */
  80. #define    IBMPC    1            /* IBM-PC CGA/MONO/EGA driver    */
  81. #define    DG10    0            /* Data General system/10    */
  82. #define    TIPC    0            /* TI Profesional PC driver    */
  83. #define    Z309    0            /* Zenith 100 PC family    driver    */
  84. #define    MAC    0            /* Macintosh            */
  85. #define    ATARI    0            /* Atari 520/1040ST screen    */
  86.  
  87. /*    Configuration options    */
  88.  
  89. #define CVMVAS  1    /* arguments to page forward/back in pages    */
  90. #define    CLRMSG    0    /* space clears the message line with no insert    */
  91. #define    CFENCE    1    /* fench matching in CMODE            */
  92. #define    ACMODE    1    /* auto C mode on .C and .H files        */
  93. #define    TYPEAH    1    /* type ahead causes update to be skipped    */
  94. #define DEBUGM    1    /* $debug triggers macro debugging        */
  95. #define    LOGFLG    0    /* send all executed commands to EMACS.LOG    */
  96. #define    VISMAC    0    /* update display during keyboard macros    */
  97. #define    CTRLZ    0    /* add a ^Z at end of files under MSDOS only    */
  98.  
  99. #define    REVSTA    1    /* Status line appears in reverse video        */
  100. #define    COLOR    1    /* color commands and windows            */
  101.  
  102. #define    FILOCK    0    /* file locking under unix BSD 4.2        */
  103. #define    ISRCH    1    /* Incremental searches like ITS EMACS        */
  104. #define    WORDPRO    1    /* Advanced word processing features        */
  105. #define    FLABEL    0    /* function key label code [HP150]        */
  106. #define    APROP    1    /* Add code for Apropos command            */
  107. #define    CRYPT    1    /* file encryption enabled?            */
  108. #define MAGIC    1    /* include regular expression matching?        */
  109. #define    AEDIT    1    /* advanced editing options: en/detabbing    */
  110. #define    PROC    1    /* named procedures                */
  111. #define    ABACKUP    1    /* auto-saved files written to .ASV        */
  112. #define    MENUS    0    /* pull down menus                */
  113. #define    DECEDT    1    /* simulate DEC EDT keypad editor        */
  114. #define    CALLABLE 0    /* make a callable interface            */
  115. #define    BCOMPL    1    /* buffer name completion            */
  116.  
  117. #define ASCII    1    /* always using ASCII char sequences for now    */
  118. #define EBCDIC    0    /* later IBM mainfraim versions will use EBCDIC    */
  119.  
  120. /*    System dependant library redefinitions, structures and includes    */
  121.  
  122. #define    itoa    int_asc
  123. #define    atoi    asc_int
  124.  
  125. #if    TURBO
  126. #include      <dos.h>
  127. #include      <mem.h>
  128. #undef peek
  129. #undef poke
  130. #define       peek(a,b,c,d)   movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  131. #define       poke(a,b,c,d)   movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  132. #endif
  133.  
  134. #if    VMS
  135. #define    abs    xabs
  136. #define    getname    xgetname
  137. #endif
  138.  
  139. #if    LATTICE
  140. #define    unsigned
  141. #endif
  142.  
  143. #if    AZTEC
  144. #undef    fputc
  145. #undef    fgetc
  146. #if    MSDOS
  147. #define    fgetc    a1getc
  148. #else
  149. #define    fgetc    agetc
  150. #endif
  151. #define    fputc    aputc
  152. #define    int86    sysint
  153. #define    intdos(a, b)    sysint(33, a, b)
  154. #define    inp    inportb
  155. #define    outp    outportb
  156.  
  157. struct XREG {
  158.     int ax,bx,cx,dx,si,di,ds,es;
  159. };
  160.  
  161. struct HREG {
  162.     char al,ah,bl,bh,cl,ch,dl,dh,d1,d2,e1,e2;
  163. };
  164.  
  165. struct SREG {
  166.     unsigned cs, ss, ds, es;
  167. };
  168. union REGS {
  169.     struct XREG x;
  170.     struct HREG h;
  171. };
  172. #endif
  173.  
  174. #if    MSDOS & DTL
  175. #include <dos.h>
  176. #endif
  177.  
  178. #if    MSDOS & MWC86
  179. #include    <dos.h>
  180. #define    int86(a, b, c)    intcall(b, c, a)
  181. #define    intdos(a, b)    intcall(a, b, DOSINT)
  182. #define    inp(a)    in(a)
  183. #define    outp(a, b)    out(a, b)
  184. #define movmem(a, b, c)    memcpy(b, a, c)
  185.  
  186. struct XREG {
  187.     unsigned int ax,bx,cx,dx,si,di,ds,es,flags;
  188. };
  189.  
  190. struct HREG {
  191.     char al,ah,bl,bh,cl,ch,dl,dh;
  192.     unsigned int ds,es,flags;
  193. };
  194.  
  195. union REGS {
  196.     struct XREG x;
  197.     struct HREG h;
  198. };
  199. #endif
  200.  
  201. #if    MSDOS & MSC
  202. #include    <dos.h>
  203. #include    <memory.h>
  204. #define    peek(a,b,c,d)    movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  205. #define    poke(a,b,c,d)    movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  206. #define    movmem(a, b, c)        memcpy(b, a, c)
  207. #endif
  208.  
  209. #if    MSDOS & LATTICE
  210. #undef    CPM
  211. #undef    LATTICE
  212. #include    <dos.h>
  213. #undef    CPM
  214. #endif
  215.  
  216. #if    MSDOS & C86
  217. #include    <dos.h>
  218. #define    intdos    sysint21
  219. #define    int86    sysint
  220. #define    inp    inportb
  221. #define    outp    outportb
  222.  
  223. struct XREG {
  224.     int ax,bx,cx,dx,si,di,ds,es,flags;
  225. };
  226.  
  227. struct HREG {
  228.     char al,ah,bl,bh,cl,ch,dl,dh;
  229.     int ds,es,flags;
  230. };
  231.  
  232. union REGS {
  233.     struct XREG x;
  234.     struct HREG h;
  235. };
  236. #endif
  237.  
  238. #if    VMS
  239. #define    unlink(a)    delete(a)
  240.  
  241. /* define input and output buffer sizes */
  242. #define    NIBUF    128        /* input buffer size */
  243. #define    NOBUF    1024        /* output buffer size */
  244. #endif
  245.  
  246. /*    define some ability flags */
  247.  
  248. #if    IBMPC | Z309
  249. #define    MEMMAP    1
  250. #else
  251. #define    MEMMAP    0
  252. #endif
  253.  
  254. #if    ((MSDOS) & (LATTICE | AZTEC | MSC | TURBO)) | V7 | USG | BSD | VMS
  255. #define    ENVFUNC    1
  256. #else
  257. #define    ENVFUNC    0
  258. #endif
  259.  
  260. /*    internal constants    */
  261.  
  262. #if    DECEDT
  263. #define    NBINDS    512            /* max # of bound keys        */
  264. #else
  265. #define    NBINDS    300            /* max # of bound keys        */
  266. #endif
  267. #define    NFBIND    0x80            /* # of bindings in fast lookup    */
  268. #define NFILEN  80                      /* # of bytes, file name        */
  269. #define NBUFN   16                      /* # of bytes, buffer name      */
  270. #define NLINE   256                     /* # of bytes, input line       */
  271. #define    NSTRING    128            /* # of bytes, string buffers    */
  272. #define NKBDM   256                     /* # of strokes, keyboard macro */
  273. #define NPAT    128                     /* # of bytes, pattern          */
  274. #define HUGE    1000                    /* Huge number                  */
  275. #define    NLOCKS    100            /* max # of file locks active    */
  276. #define    NCOLORS    8            /* number of supported colors    */
  277. #define    KBLOCK    250            /* sizeof kill buffer chunks    */
  278. #define    NBLOCK    16            /* line block chunk size    */
  279. #define    NVSIZE    10            /* max #chars in a var name    */
  280.  
  281. #define CTRL    0x0100                  /* Control flag, or'ed in       */
  282. #define META    0x0200                  /* Meta flag, or'ed in          */
  283. #define CTLX    0x0400                  /* ^X flag, or'ed in            */
  284. #define    SPEC    0x0800            /* special key (function keys)    */
  285. #define    MOUS    0x1000            /* alternate input device (mouse) */
  286. #define    SHFT    0x2000            /* shifted (for function keys)    */
  287. #define    ALTD    0x4000            /* ALT key...            */
  288.  
  289. #define    FUNC    (SPEC|CTLX|META)    /* prefix for special functions */
  290.  
  291. #ifdef    FALSE
  292. #undef    FALSE
  293. #endif
  294. #ifdef    TRUE
  295. #undef    TRUE
  296. #endif
  297.  
  298. #define FALSE   0                       /* False, no, bad, etc.         */
  299. #define TRUE    1                       /* True, yes, good, etc.        */
  300. #define ABORT   2                       /* Death, ^G, abort, etc.       */
  301. #define    FAILED    3            /* not-quite fatal false return    */
  302. #define    HOOK    4            /* execute called with FUNC    */
  303.  
  304. #define    STOP    0            /* keyboard macro not in use    */
  305. #define    PLAY    1            /*          playing    */
  306. #define    RECORD    2            /*          recording    */
  307.  
  308. /*    Directive definitions    */
  309.  
  310. #define    DIF        0
  311. #define DELSE        1
  312. #define DENDIF        2
  313. #define DGOTO        3
  314. #define DRETURN        4
  315. #define DENDM        5
  316. #define DWHILE        6
  317. #define    DENDWHILE    7
  318. #define    DBREAK        8
  319. #define DFORCE        9
  320.  
  321. #define NUMDIRS        10
  322.  
  323. /*
  324.  * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for
  325.  * the scan routines.
  326.  */
  327. #define    PTBEG    0    /* Leave the point at the beginning on search    */
  328. #define    PTEND    1    /* Leave the point at the end on search        */
  329. #define    FORWARD    0            /* forward direction        */
  330. #define REVERSE    1            /* backwards direction        */
  331.  
  332. #define FIOSUC  0                       /* File I/O, success.           */
  333. #define FIOFNF  1                       /* File I/O, file not found.    */
  334. #define FIOEOF  2                       /* File I/O, end of file.       */
  335. #define FIOERR  3                       /* File I/O, error.             */
  336. #define    FIOMEM    4            /* File I/O, out of memory    */
  337. #define    FIOFUN    5            /* File I/O, eod of file/bad line*/
  338. #define    FIODEL    6            /* Can't delete/rename file    */
  339.  
  340. #define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  341. #define CFKILL  0x0002                  /* Last command was a kill      */
  342.  
  343. #define    BELL    0x07            /* a bell character        */
  344. #define    TAB    0x09            /* a tab character        */
  345.  
  346. #if    V7 | USG | BSD
  347. #define    PATHCHR    ':'
  348. #else
  349. #if    WMCS
  350. #define    PATHCHR    ','
  351. #else
  352. #define    PATHCHR    ';'
  353. #endif
  354. #endif
  355.  
  356. #define    INTWIDTH    sizeof(int) * 3
  357.  
  358. /*    Macro argument token types                    */
  359.  
  360. #define    TKNUL    0            /* end-of-string        */
  361. #define    TKARG    1            /* interactive argument        */
  362. #define    TKBUF    2            /* buffer argument        */
  363. #define    TKVAR    3            /* user variables        */
  364. #define    TKENV    4            /* environment variables    */
  365. #define    TKFUN    5            /* function....            */
  366. #define    TKDIR    6            /* directive            */
  367. #define    TKLBL    7            /* line label            */
  368. #define    TKLIT    8            /* numeric literal        */
  369. #define    TKSTR    9            /* quoted string literal    */
  370. #define    TKCMD    10            /* command name            */
  371.  
  372. /*    Internal defined functions                    */
  373.  
  374. #define    nextab(a)    (a & ~7) + 8
  375. #ifdef    abs
  376. #undef    abs
  377. #endif
  378.  
  379. /* DIFCASE represents the integer difference between upper
  380.    and lower case letters.  It is an xor-able value, which is
  381.    fortunate, since the relative positions of upper to lower
  382.    case letters is the opposite of ascii in ebcdic.
  383. */
  384.  
  385. #ifdef    islower
  386. #undef    islower
  387. #endif
  388.  
  389. #if    ASCII
  390.  
  391. #define    DIFCASE        0x20
  392. #define isletter(c)    (('a' <= c && 'z' >= c) || ('A' <= c && 'Z' >= c))
  393. #define islower(c)    (('a' <= c && 'z' >= c))
  394. #endif
  395.  
  396. #if    EBCDIC
  397.  
  398. #define    DIFCASE        0x40
  399. #define isletter(c)    (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c) || ('A' <= c && 'I' >= c) || ('J' <= c && 'R' >= c) || ('S' <= c && 'Z' >= c))
  400. #define islower(c)    (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c))
  401. #endif
  402.  
  403. /*    Dynamic RAM tracking and reporting redefinitions    */
  404.  
  405. #if    RAMSIZE
  406. #define    malloc    allocate
  407. #define    free    release
  408. #endif
  409.  
  410. /* patch for bug in MSC for XENIX */
  411.  
  412. #if    USG & MSC
  413. typedef short shrt;
  414. #else
  415. typedef char shrt;
  416. #endif
  417.  
  418. /*
  419.  * There is a window structure allocated for every active display window. The
  420.  * windows are kept in a big list, in top to bottom screen order, with the
  421.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  422.  * The flag field contains some bits that are set by commands to guide
  423.  * redisplay. Although this is a bit of a compromise in terms of decoupling,
  424.  * the full blown redisplay is just too expensive to run for every input
  425.  * character.
  426.  */
  427. typedef struct  WINDOWTAG {
  428.         struct  WINDOWTAG *w_wndp;    /* Next window                  */
  429.         struct  BUFFERTAG *w_bufp;    /* Buffer displayed in window   */
  430.         struct  LINETAG *w_linep;    /* Top line in the window       */
  431.         struct  LINETAG *w_dotp;    /* Line containing "."          */
  432.         short   w_doto;                 /* Byte offset for "."          */
  433.         struct  LINETAG *w_markp;    /* Line containing "mark"       */
  434.         short   w_marko;                /* Byte offset for "mark"       */
  435.         shrt    w_toprow;               /* Origin 0 top row of window   */
  436.         shrt    w_ntrows;               /* # of rows of text in window  */
  437.         shrt    w_force;                /* If NZ, forcing row.          */
  438.         shrt    w_flag;                 /* Flags.                       */
  439. #if    COLOR
  440.     shrt    w_fcolor;        /* current forground color    */
  441.     shrt    w_bcolor;        /* current background color    */
  442. #endif
  443.         int    w_fcol;            /* first col to display        */
  444. }       WINDOW;
  445.  
  446. #define WFFORCE 0x01                    /* Window needs forced reframe  */
  447. #define WFMOVE  0x02                    /* Movement from line to line   */
  448. #define WFEDIT  0x04                    /* Editing within a line        */
  449. #define WFHARD  0x08                    /* Better to a full display     */
  450. #define WFMODE  0x10                    /* Update mode line.            */
  451. #define    WFCOLR    0x20            /* Needs a color change        */
  452.  
  453. /*
  454.  * Text is kept in buffers. A buffer header, described below, exists for every
  455.  * buffer in the system. The buffers are kept in a big list, so that commands
  456.  * that search for a buffer by name can find the buffer header. There is a
  457.  * safe store for the dot and mark in the header, but this is only valid if
  458.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  459.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  460.  * the header line in "b_linep".
  461.  *     Buffers may be "Inactive" which means the files associated with them
  462.  * have not been read in yet. These get read in at "use buffer" time.
  463.  */
  464. typedef struct  BUFFERTAG {
  465.         struct  BUFFERTAG *b_bufp;    /* Link to next BUFFER          */
  466.         struct  LINETAG *b_dotp;    /* Link to "." LINE structure   */
  467.         short   b_doto;                 /* Offset of "." in above LINE  */
  468.         struct  LINETAG *b_markp;    /* The same as the above two,   */
  469.         short   b_marko;                /* but for the "mark"           */
  470.         int    b_fcol;            /* first col to display        */
  471.         struct  LINETAG *b_linep;    /* Link to the header LINE      */
  472.         struct    LINETAG *b_topline;    /* Link to narrowed top text    */
  473.         struct    LINETAG *b_botline;    /* Link to narrows bottom text    */
  474.     shrt    b_active;        /* window activated flag    */
  475.         shrt    b_nwnd;                 /* Count of windows on buffer   */
  476.         shrt    b_flag;                 /* Flags                        */
  477.     int    b_mode;            /* editor mode of this buffer    */
  478.         char    b_fname[NFILEN];        /* File name                    */
  479.         char    b_bname[NBUFN];         /* Buffer name                  */
  480.     int    b_fmode;        /* Mode of file            */
  481. #if    VMS
  482.     char    b_fab_rfm;        /* vms record format        */
  483.     char    b_fab_rat;        /* vms record attribute        */
  484. #endif
  485. #if    CRYPT
  486.     char    b_key[NPAT];        /* current encrypted key    */
  487. #endif
  488. }       BUFFER;
  489.  
  490. #define BFINVS  0x01                    /* Internal invisable buffer    */
  491. #define BFCHG   0x02                    /* Changed since last write     */
  492. #define    BFTRUNC 0x04            /* buffer was truncated when read */
  493. #define    BFNAROW 0x08            /* buffer has been narrowed    */
  494.  
  495. /*    mode flags    */
  496. #define    NUMMODES    10        /* # of defined modes        */
  497.  
  498. #define    MDWRAP    0x0001            /* word wrap            */
  499. #define    MDCMOD    0x0002            /* C indentation and fence match*/
  500. #define    MDSPELL    0x0004            /* spell error parsing        */
  501. #define    MDEXACT    0x0008            /* Exact matching for searches    */
  502. #define    MDVIEW    0x0010            /* read-only buffer        */
  503. #define MDOVER    0x0020            /* overwrite mode        */
  504. #define MDMAGIC    0x0040            /* regular expresions in search */
  505. #define    MDCRYPT    0x0080            /* encrytion mode active    */
  506. #define    MDASAVE    0x0100            /* auto-save mode        */
  507. #define MDBINARY 0x0200            /* fopen in binary mode        */
  508.  
  509. /*
  510.  * The starting position of a region, and the size of the region in
  511.  * characters, is kept in a region structure.  Used by the region commands.
  512.  */
  513. typedef struct  {
  514.         struct  LINETAG *r_linep;    /* Origin LINE address.         */
  515.         short   r_offset;               /* Origin LINE offset.          */
  516.         long    r_size;                 /* Length in characters.        */
  517. }       REGION;
  518.  
  519. /*
  520.  * All text is kept in circularly linked lists of "LINE" structures. These
  521.  * begin at the header line (which is the blank line beyond the end of the
  522.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  523.  * number of bytes in the line (the "used" size), the size of the text array,
  524.  * and the text. The end of line is not stored as a byte; it's implied. Future
  525.  * additions will include update hints, and a list of marks into the line.
  526.  */
  527. typedef struct  LINETAG {
  528.         struct  LINETAG *l_fp;        /* Link to the next line        */
  529.         struct  LINETAG *l_bp;        /* Link to the previous line    */
  530.         short   l_size;                 /* Allocated size               */
  531.         short   l_used;                 /* Used size                    */
  532.         char    l_text[1];              /* A bunch of characters.       */
  533. }       LINE;
  534.  
  535. #define lforw(lp)       ((lp)->l_fp)
  536. #define lback(lp)       ((lp)->l_bp)
  537. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  538. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  539. #define llength(lp)     ((lp)->l_used)
  540.  
  541. /*
  542.  * The editor communicates with the display using a high level interface. A
  543.  * "TERM" structure holds useful variables, and indirect pointers to routines
  544.  * that do useful operations. The low level get and put routines are here too.
  545.  * This lets a terminal, in addition to having non standard commands, have
  546.  * funny get and put character code too. The calls might get changed to
  547.  * "termp->t_field" style in the future, to make it possible to run more than
  548.  * one terminal type.
  549.  */
  550. typedef struct  {
  551.     short    t_mrow;            /* max number of rows allowable */
  552.         short   t_nrow;                 /* current number of rows used  */
  553.         short   t_mcol;                 /* max Number of columns.       */
  554.         short   t_ncol;                 /* current Number of columns.   */
  555.     short    t_margin;        /* min margin for extended lines*/
  556.     short    t_scrsiz;        /* size of scroll region "    */
  557.     int    t_pause;        /* # times thru update to pause */
  558.         int     (*t_open)();            /* Open terminal at the start.  */
  559.         int     (*t_close)();           /* Close terminal at end.       */
  560.     int    (*t_kopen)();        /* Open keyboard        */
  561.     int    (*t_kclose)();        /* close keyboard        */
  562.         int     (*t_getchar)();         /* Get character from keyboard. */
  563.         int     (*t_putchar)();         /* Put character to display.    */
  564.         int     (*t_flush)();           /* Flush output buffers.        */
  565.         int     (*t_move)();            /* Move the cursor, origin 0.   */
  566.         int     (*t_eeol)();            /* Erase to end of line.        */
  567.         int     (*t_eeop)();            /* Erase to end of page.        */
  568.         int     (*t_beep)();            /* Beep.                        */
  569.     int    (*t_rev)();        /* set reverse video state    */
  570.     int    (*t_rez)();        /* change screen resolution    */
  571. #if    COLOR
  572.     int    (*t_setfor)();        /* set forground color        */
  573.     int    (*t_setback)();        /* set background color        */
  574. #endif
  575. }       TERM;
  576.  
  577. /*    TEMPORARY macros for terminal I/O  (to be placed in a machine
  578.                         dependant place later)    */
  579.  
  580. #define    TTopen        (*term.t_open)
  581. #define    TTclose        (*term.t_close)
  582. #define    TTkopen        (*term.t_kopen)
  583. #define    TTkclose    (*term.t_kclose)
  584. #define    TTgetc        (*term.t_getchar)
  585. #define    TTputc        (*term.t_putchar)
  586. #define    TTflush        (*term.t_flush)
  587. #define    TTmove        (*term.t_move)
  588. #define    TTeeol        (*term.t_eeol)
  589. #define    TTeeop        (*term.t_eeop)
  590. #define    TTbeep        (*term.t_beep)
  591. #define    TTrev        (*term.t_rev)
  592. #define    TTrez        (*term.t_rez)
  593. #if    COLOR
  594. #define    TTforg        (*term.t_setfor)
  595. #define    TTbacg        (*term.t_setback)
  596. #endif
  597.  
  598. /*    structure for the table of initial key bindings        */
  599.  
  600. typedef struct  {
  601.         short   k_code;                 /* Key code                     */
  602.         int     (*k_fp)();              /* Routine to handle it         */
  603. }       KEYTAB;
  604.  
  605. /*    structure for the name binding table        */
  606.  
  607. typedef struct {
  608.     char *n_name;        /* name of function key */
  609.     int (*n_func)();    /* function name is bound to */
  610. }    NBIND;
  611.  
  612. /*    The editor holds deleted text chunks in the KILL buffer. The
  613.     kill buffer is logically a stream of ascii characters, however
  614.     due to its unpredicatable size, it gets implemented as a linked
  615.     list of chunks. (The d_ prefix is for "deleted" text, as k_
  616.     was taken up by the keycode structure)
  617. */
  618.  
  619. typedef    struct KILLTAG {
  620.     struct KILLTAG *d_next;    /* link to next chunk, NULL if last */
  621.     char d_chunk[KBLOCK];    /* deleted text */
  622. } KILL;
  623.  
  624. /*    When emacs' command interpetor needs to get a variable's name,
  625.     rather than it's value, it is passed back as a VDESC variable
  626.     description structure. The v_num field is a index into the
  627.     appropriate variable table.
  628. */
  629.  
  630. typedef struct VDESCTAG {
  631.     int v_type;    /* type of variable */
  632.     int v_num;    /* ordinal pointer to variable in list */
  633. } VDESC;
  634.  
  635. /*    The !WHILE directive in the execution language needs to
  636.     stack references to pending whiles. These are stored linked
  637.     to each currently open procedure via a linked list of
  638.     the following structure
  639. */
  640.  
  641. typedef struct WHBLKTAG {
  642.     LINE *w_begin;        /* ptr to !while statement */
  643.     LINE *w_end;        /* ptr to the !endwhile statement*/
  644.     int w_type;        /* block type */
  645.     struct WHBLKTAG *w_next;    /* next while */
  646. } WHBLOCK;
  647.  
  648. #define    BTWHILE        1
  649. #define    BTBREAK        2
  650.  
  651. /*
  652.  * Incremental search defines.
  653.  */
  654. #if    ISRCH
  655.  
  656. #define    CMDBUFLEN    256    /* Length of our command buffer */
  657.  
  658. #define    IS_ABORT    0x07    /* Abort the isearch */
  659. #define IS_BACKSP    0x08    /* Delete previous char */
  660. #define    IS_TAB        0x09    /* Tab character (allowed search char) */
  661. #define IS_NEWLINE    0x0D    /* New line from keyboard (Carriage return) */
  662. #define    IS_QUOTE    0x11    /* Quote next character */
  663. #define IS_REVERSE    0x12    /* Search backward */
  664. #define    IS_FORWARD    0x13    /* Search forward */
  665. #define    IS_VMSQUOTE    0x16    /* VMS quote character */
  666. #define    IS_VMSFORW    0x18    /* Search forward for VMS */
  667. #define    IS_QUIT        0x1B    /* Exit the search */
  668. #define    IS_RUBOUT    0x7F    /* Delete previous character */
  669.  
  670. /* IS_QUIT is no longer used, the variable metac is used instead */
  671.  
  672. #endif
  673.  
  674. /* HICHAR - 1 is the largest character we will deal with.
  675.  * HIBYTE represents the number of bytes in the bitmap.
  676.  */
  677.  
  678. #define    HICHAR        256
  679. #define    HIBYTE        HICHAR >> 3
  680.  
  681. #define    CHCASE(c)    ((c) ^ DIFCASE)    /* Toggle the case of a letter.*/
  682.  
  683. #if    MAGIC
  684.  
  685. /*
  686.  * Defines for the metacharacters in the regular expressions in search
  687.  * routines.
  688.  */
  689.  
  690. #define    MCNIL        0    /* Like the '\0' for strings.*/
  691. #define    LITCHAR        1
  692. #define    ANY        2
  693. #define    CCL        3
  694. #define    NCCL        4
  695. #define    BOL        5
  696. #define    EOL        6
  697. #define    DITTO        7
  698. #define    CLOSURE        256    /* An or-able value.*/
  699. #define    MASKCL        CLOSURE - 1
  700.  
  701. #define    MC_ANY        '.'    /* 'Any' character (except newline).*/
  702. #define    MC_CCL        '['    /* Character class.*/
  703. #define    MC_NCCL        '^'    /* Negate character class.*/
  704. #define    MC_RCCL        '-'    /* Range in character class.*/
  705. #define    MC_ECCL        ']'    /* End of character class.*/
  706. #define    MC_BOL        '^'    /* Beginning of line.*/
  707. #define    MC_EOL        '$'    /* End of line.*/
  708. #define    MC_CLOSURE    '*'    /* Closure - does not extend past newline.*/
  709.  
  710. #define    MC_DITTO    '&'    /* Use matched string in replacement */
  711. #define    MC_ESC        '\\'    /* Escape - suppress meta-meaning.*/
  712.  
  713. #define    BIT(n)        (1 << (n))    /* An integer with one bit set.*/
  714.  
  715. typedef char    *BITMAP;
  716.  
  717. typedef    struct {
  718.     short        mc_type;
  719.     union {
  720.         int    lchar;
  721.         BITMAP    cclmap;
  722.     } u;
  723. } MC;
  724.  
  725. typedef struct {
  726.     short        mc_type;
  727.     char *rstr;
  728. } RMC;
  729. #endif
  730.  
  731.