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