home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / UE311H.ZIP / ESTRUCT.H < prev    next >
C/C++ Source or Header  |  1991-10-25  |  29KB  |  935 lines

  1. /*    ESTRUCT:    Structure and preprocesser defined for
  2.             MicroEMACS 3.11
  3.  
  4.             written by Daniel Lawrence
  5.             based on code by Dave G. Conroy,
  6.                 Steve Wilhite and George Jones
  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 distribution
  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.11"
  35.  
  36. /*    Machine/OS definitions            */
  37. /*    [Set one of these!!]            */
  38.  
  39. #define AMIGA    0            /* AmigaDOS            */
  40. #define AOSVS    0            /* Data General AOS/VS        */
  41. #define AVIION    0            /* Data General AViiON        */
  42. #define BSD    0            /* UNIX BSD 4.2 and ULTRIX    */
  43. #define FINDER    0            /* Macintosh OS         */
  44. #define HPUX    0            /* HPUX HP 9000 minicomputer    */
  45. #define MPE    0            /* HP MPE/XL            */
  46. #define MSDOS    0            /* MS-DOS            */
  47. #define OS2    0            /* Microsoft or IBM OS/2    */
  48. #define SMOS    0            /* Supermax UNIX System V    */
  49. #define SUN    0            /* SUN v4.0            */
  50. #define TOS    0            /* ST520, TOS            */
  51. #define USG    0            /* UNIX system V        */
  52. #define V7    0            /* V7 UNIX or Coherent or BSD4.2*/ 
  53. #define VMS    0            /* VAX/VMS            */
  54. #define WMCS    0            /* Wicat's MCS            */
  55. #define XENIX    0            /* IBM-PC SCO XENIX        */
  56.  
  57. /*    Compiler definitions            */
  58. /*    [Set one of these!!]            */
  59. #define    ALCYON    0    /* ALCYON Atari ST compiler */ 
  60. #define    DGC    0    /* Data General AOS/VS C... */
  61. #define AZTEC    0    /* Aztec C 3.20e */
  62. #define DTL    0    /* DataLight C v3.12 */
  63. #define GCC    0    /* the GNU C compiler */
  64. #define LATTICE 0    /* Lattice 2.14 through 3.0 compilers */
  65. #define MSC    0    /* MicroSoft C compile version 3 & 4 & 5.1 */
  66. #define MWC    0    /* Mark Williams C */
  67. #define TURBO    0    /* Turbo C/MSDOS */
  68. #define UNIX    0    /* a standard UNIX compiler (cc) */
  69. #define    ZTC    0    /* Zortech C/C++ 1.02 thru 2.10 under MSDOS */
  70.  
  71. /*      Machine stack growth direction.                     */
  72. /*  [Set this to 1 if your machine stack grows UP!!!]       */
  73. /*      data general mv/eclipse series stack grows up.      */
  74. /*      dec vax series stack grows down... got it???        */
  75.  
  76. #define STACK_GROWS_UP  0
  77.  
  78. /*    Debugging options    */
  79. #define    RAMSIZE    0    /* dynamic RAM memory usage tracking */
  80. #define    RAMSHOW    0    /* auto dynamic RAM reporting */
  81. #define    RAMTRCK    0    /* send debug info to MALLOC.DAT */
  82.  
  83. /*   Special keyboard/network definitions         */
  84.  
  85. #define ATKBD    0        /* AT-style keyboard with F11, F12 & grey keys */
  86. #define WANGPC    0        /* WangPC - mostly escape sequences    */
  87. #define VT100    0        /* Handle VT100 style keypad - NOT VMS.    */
  88. #define    NOVELL    0        /* IBMPC Novell NetWare flag! */
  89. #define KEYPAD    0        /* VMS - turn on and off application    */
  90.                 /* keypad automatically */
  91. #define XONDATA    0        /* VMS - set to force /NOTTSYNC/NOHOSTSY */
  92. #define    RMSIO    0        /* VMS - skip the rotten C runtime and    */
  93.                 /* use RMS directly            */
  94. #define OPTMEM    0        /* VMS 5.0 and up - use a less standard */
  95.                 /* but more efficient memory allocator    */
  96.  
  97. /*    Terminal Output definitions        */
  98. /*    [Set one of these!!]            */
  99.  
  100. #define ANSI    0            /* ANSI escape sequences    */
  101. #define DASHER    0            /* DG Dasher 2xx/4xx crts    */
  102. #define DG10    0            /* Data General system/10    */
  103. #define FMR    0            /* Fujitsu FMR series driver    */
  104. #define HP110    0            /* HP110 screen driver        */
  105. #define HP150    0            /* HP150 screen driver        */
  106. #define IBMPC    0            /* IBM-PC CGA/MONO/EGA/VGA drvr    */
  107. #define MAC    0            /* Macintosh            */
  108. #define NEC    0            /* NEC-9801VM driver        */
  109. #define OS2NPM    0            /* OS/2 non-Presentation Mgr.    */
  110. #define RAINBOW 0            /* Use Rainbow fast video.    */
  111. #define SMG    0            /* SMG library on VMS        */
  112. #define ST52    0            /* Atari 520/1040ST screen    */
  113. #define TERMCAP 0            /* Use TERMCAP            */
  114. #define TIPC    0            /* TI Profesional PC driver    */
  115. #define VT52    0            /* VT52 terminal (Zenith).    */
  116. #define Z309    0            /* Zenith 100 PC family    driver    */
  117.  
  118. /*    Windowing system style (pick one)                */
  119.  
  120. #define    WINDOW_TEXT    0        /* Text mode.... simple updates    */
  121. #define    WINDOW_XVT    0        /* using XVT/any platform    */
  122. #define    WINDOW_MSWIN    0        /* MicroSoft Windows        */
  123. #define    WINDOW_X    0        /* X/Unix            */
  124.  
  125. /*    Language text options    (pick one)                */
  126.  
  127. #define ENGLISH 1
  128. #define    FRENCH    0
  129. #define    SPANISH    0
  130. #define    GERMAN    0
  131. #define    DUTCH    0
  132. #define PLATIN    0
  133. #define    JAPAN    0
  134. #define    LATIN    0
  135.  
  136. /*    Configuration options    */
  137.  
  138. #define    TYPEAH    1    /* type ahead causes update to be skipped    */
  139. #define DEBUGM    1    /* $debug triggers macro debugging        */
  140. #define    LOGFLG    0    /* send all executed commands to EMACS.LOG    */
  141. #define    VISMAC    0    /* update display during keyboard macros    */
  142. #define    CTRLZ    0    /* add a ^Z at end of files under MSDOS only    */
  143. #define    CLEAN    0    /* de-alloc memory on exit            */
  144. #define    CALLED    0    /* is emacs a called subroutine? or stand alone */
  145.  
  146. #define REVSTA    1    /* Status line appears in reverse video     */
  147. #define    COLOR    1    /* color commands and windows            */
  148.  
  149. #define FILOCK    1    /* file locking under unix BSD 4.2        */
  150. #define    ISRCH    1    /* Incremental searches like ITS EMACS        */
  151. #define    FLABEL    1    /* function key label code [HP150]        */
  152. #define    CRYPT    1    /* file encryption enabled?            */
  153. #define MAGIC    1    /* include regular expression matching?        */
  154. #define MOUSE    1     /* Include routines for mouse actions        */
  155. #define    NOISY    1    /* Use a fancy BELL if it exists        */
  156. #define CTAGS    0    /* include vi-like tagging?            */
  157. #define    SPEECH    0    /* spoken EMACS, for the sight impared [not ready] */
  158. #define    VARARG    1    /* use varargs.h for mlwrite()            */
  159.  
  160. /*    Character set options        */
  161. /*    [Set one of these!!]        */
  162. #define ASCII    1    /* always using ASCII char sequences for now    */
  163. #define EBCDIC    0    /* later IBM mainfraim versions will use EBCDIC    */
  164.  
  165. /* handle constant and voids properly */
  166.  
  167. #if    VMS
  168. #define    CONST    readonly
  169. #define    VOID    void
  170. #define NOSHARE noshare
  171. #else
  172. #if    AOSVS
  173. #define CONST $shared $align(1)     /* fake a  const */
  174. #define    VOID
  175. #define NOSHARE $low32k $align(1)   /* attempt to optimize read/write vars. */
  176. #else
  177. #ifdef    __STDC__
  178. #define    CONST    const
  179. #define    VOID    void
  180. #define    NOSHARE
  181. #else
  182. #define    CONST
  183. #define    VOID
  184. #define NOSHARE
  185. #endif
  186. #endif
  187. #endif
  188.  
  189. /*    System dependant library redefinitions, structures and includes */
  190.  
  191. /*    the following define allows me to initialize unions...
  192.     otherwise we make them structures (like the keybinding table)  */
  193.  
  194. /*    multibyte character support?    */
  195.  
  196. #if    NEC || FMR
  197. #define    DBCS    1    /* double byte character sets enabled */
  198. #define    INSDEL    1    /* use insert/delete line display optimizations */
  199.  
  200. /* define DBCS prefix bytes */
  201. #define    is2char(ch) (((ch&0xff) >= 0x81 && (ch&0xff) <= 0x9f) || ((ch&0xff) >=0xe0 && (ch&0xff) <= 0xfc))
  202.  
  203. #else
  204. #define    DBCS    0
  205. #define    INSDEL    0
  206. #endif
  207.  
  208. /*    Prototypes in use?    */
  209.  
  210. #if    MSC || TURBO || DTL || VMS || GCC || ZTC
  211. #define    PROTO    1
  212. #else
  213. #define    PROTO    0
  214. #endif
  215.  
  216. #if    __STDC__ && (GCC == 0)    /* if ANSI C compatible */
  217. #define    ETYPE    union
  218. #else
  219. #define    ETYPE    struct
  220. #endif
  221.  
  222. #if MSDOS & (TURBO | MSC | TIPC)
  223. #define    NEAR
  224. #define    DNEAR
  225. #define    PASCAL pascal
  226. #define    CDECL cdecl
  227. #else
  228. #if MSDOS & ZTC
  229. #define    NEAR
  230. #define    DNEAR
  231. #define    PASCAL _pascal
  232. #define    CDECL _cdecl
  233. #else
  234. #define NEAR
  235. #define    DNEAR
  236. #define    PASCAL
  237. #define    CDECL
  238. #endif
  239. #endif
  240.  
  241. #if    TURBO
  242. #include      <dos.h>
  243. #include      <mem.h>
  244. #undef peek
  245. #undef poke
  246. #define       peek(a,b,c,d)   movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  247. #define       poke(a,b,c,d)   movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  248. #endif
  249.  
  250. #if    LATTICE & MSDOS
  251. /* you may have to remove this one definition with LATTICE version
  252.    3.2 and above                          */
  253. #define    unsigned
  254. #endif
  255.  
  256. #if    AZTEC
  257. #undef    putc
  258. #undef    getc
  259. #if    MSDOS
  260. #define    getc    a1getc
  261. #define    int86    sysint
  262. #define    intdos(a, b)    sysint(33, a, b)
  263. #define    inp    inportb
  264. #define    outp    outportb
  265. #else
  266. #define getc    agetc
  267. #endif
  268. #define putc    aputc
  269.  
  270. struct XREG {
  271.     unsigned ax,bx,cx,dx,si,di,ds,es;
  272. };
  273.  
  274. struct HREG {
  275.     char al,ah,bl,bh,cl,ch,dl,dh,d1,d2,e1,e2;
  276. };
  277.  
  278. union REGS {
  279.     struct XREG x;
  280.     struct HREG h;
  281. };
  282.  
  283. struct SREGS {
  284.     unsigned cs, ss, ds, es;
  285. };
  286. #endif
  287.  
  288. #if    MSDOS & DTL
  289. #include    <dos.h>
  290. #endif
  291.  
  292. #if    MSDOS & MWC
  293. #include    <dos.h>
  294. #define    int86(a, b, c)    intcall(b, c, a)
  295. #define    intdos(a, b)    intcall(a, b, DOSINT)
  296. #define    inp(a)        in(a)
  297. #define    outp(a, b)    out(a, b)
  298. #define    movmem(a, b, c)    memcpy(b, a, c)
  299.  
  300. struct XREG {
  301.     unsigned int ax,bx,cx,dx,si,di,ds,es,flags;
  302. };
  303.  
  304. struct HREG {
  305.     char al,ah,bl,bh,cl,ch,dl,dh;
  306.     unsigned int ds,es,flags;
  307. };
  308.  
  309. union REGS {
  310.     struct XREG x;
  311.     struct HREG h;
  312. };
  313. #endif
  314.  
  315. #if    MSDOS & MSC
  316. #include    <dos.h>
  317. #include    <memory.h>
  318. #define    peek(a,b,c,d)    movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  319. #define    poke(a,b,c,d)    movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  320. #define    movmem(a, b, c)        memcpy(b, a, c)
  321. #endif
  322.  
  323. #if    MSDOS & LATTICE
  324. #undef    CPM
  325. #undef    LATTICE
  326. #include    <dos.h>
  327. #undef    CPM
  328. #endif
  329.  
  330. /* System V doesn't name this the same as others */
  331. #if    USG | SUN | (OS2 & MSC)
  332. #define    movmem(a, b, c)        memcpy(b, a, c)
  333. #endif
  334.  
  335. /* this keeps VMS happy */
  336. #if    VMS
  337. #define    getname xgetname
  338. #define    unlink(a)    delete(a)
  339. #endif
  340.  
  341. /* some options for AOS/VS */
  342. #if     AOSVS
  343. #define ORMDNI  1
  344. #endif
  345.  
  346. /*    define some ability flags */
  347.  
  348. #if    IBMPC | Z309 | FMR | TIPC
  349. #define    MEMMAP    1
  350. #else
  351. #define MEMMAP    0
  352. #endif
  353.  
  354. #if    MSDOS | OS2 | V7 | USG | SMOS | HPUX | BSD | (TOS & MWC) | WMCS | SUN | MPE
  355. #define    ENVFUNC    1
  356. #else
  357. #define ENVFUNC 0
  358. #endif
  359.  
  360. #if    MPE
  361. #define DIRSEPSTR    "."
  362. #define DIRSEPCHAR    '.'
  363. #else
  364. #if    TOS || MSDOS || OS2
  365. #define    DIRSEPSTR    "\\"
  366. #define    DIRSEPCHAR    '\\'
  367. #else
  368. #define DIRSEPSTR    "/"
  369. #define    DIRSEPCHAR    '/'
  370. #endif
  371. #endif
  372.  
  373. #define    DRIVESEPCHAR    ':'
  374.  
  375. #if    VARARG
  376. #if    USG || BSD || SUN || XENIX || HPUX || AVIION || MPE
  377. #define    VARG    1
  378. #define    SARG    0
  379. #include    <varargs.h>
  380. #else
  381. #define    VARG    0
  382. #define    SARG    1
  383. #include    <stdarg.h>
  384. #endif
  385. #endif
  386.  
  387. #if ZTC
  388. #include     <dos.h>
  389. #define      movmem(a, b, c) memcpy(b, a, c)
  390. #endif
  391.  
  392. /*    Emacs global flag bit definitions (for gflags)    */
  393.  
  394. #define GFREAD    1    /* read first file in at startup */
  395. #define GFSDRAW    2    /* suppress a screen redraw */
  396.  
  397. /*    internal constants    */
  398.  
  399. #define NBINDS    300            /* max # of bound keys        */
  400. #if    AOSVS | VMS
  401. #define    NFILEN    256
  402. #else
  403. #define NFILEN    80            /* # of bytes, file name    */
  404. #endif
  405. #define NBUFN    32            /* # of bytes, buffer name    */
  406. #define NLINE    256            /* # of bytes, input line    */
  407. #define    NSTRING    128            /* # of bytes, string buffers    */
  408. #define NKBDM    256            /* # of strokes, keyboard macro */
  409. #define NPAT    128            /* # of bytes, pattern        */
  410. #define HUGE    1000            /* Huge number            */
  411. #define    NLOCKS    100            /* max # of file locks active    */
  412. #define    NCOLORS    16            /* number of supported colors    */
  413. #define    KBLOCK    250            /* sizeof kill buffer chunks    */
  414. #define    NBLOCK    16            /* line block chunk size    */
  415. #define    NVSIZE    10            /* max #chars in a var name    */
  416. #define NMARKS    10            /* number of marks        */
  417.  
  418. #define CTRL    0x0100        /* Control flag, or'ed in        */
  419. #define META    0x0200        /* Meta flag, or'ed in            */
  420. #define CTLX    0x0400        /* ^X flag, or'ed in            */
  421. #define SPEC    0x0800        /* special key (function keys)        */
  422. #define MOUS    0x1000        /* alternative input device (mouse)    */
  423. #define    SHFT    0x2000        /* shifted (for function keys)        */
  424. #define    ALTD    0x4000        /* ALT key...                */
  425.  
  426. #define    BINDNUL    0        /* not bount to anything        */
  427. #define    BINDFNC    1        /* key bound to a function        */
  428. #define    BINDBUF    2        /* key bound to a buffer        */
  429.  
  430. #define    FORWARD        0    /* doing things forward            */
  431. #define    BACKWARD    -1    /* doing things in reverse        */
  432.  
  433. #ifdef    FALSE
  434. #undef    FALSE
  435. #endif
  436. #ifdef    TRUE
  437. #undef    TRUE
  438. #endif
  439.  
  440. #define FALSE    0            /* False, no, bad, etc.     */
  441. #define TRUE    1            /* True, yes, good, etc.    */
  442. #define ABORT    2            /* Death, ^G, abort, etc.    */
  443. #define    FAILED    3            /* not-quite fatal false return    */
  444.  
  445. #define STOP    0            /* keyboard macro not in use    */
  446. #define    PLAY    1            /*          playing    */
  447. #define    RECORD    2            /*          recording    */
  448.  
  449. /*    Competion types        */
  450.  
  451. #define    CMP_BUFFER    0
  452. #define    CMP_COMMAND    1
  453. #define    CMP_FILENAME    2
  454.  
  455. /*    Directive definitions    */
  456.  
  457. #define DIF        0
  458. #define DELSE        1
  459. #define DENDIF        2
  460. #define DGOTO        3
  461. #define DRETURN        4
  462. #define DENDM        5
  463. #define DWHILE        6
  464. #define    DENDWHILE    7
  465. #define    DBREAK        8
  466. #define DFORCE        9
  467.  
  468. #define NUMDIRS     10
  469.  
  470. /*
  471.  * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for
  472.  * the scan routines.
  473.  */
  474. #define PTBEG    0    /* Leave the point at the beginning on search    */
  475. #define    PTEND    1    /* Leave the point at the end on search        */
  476. #define    FORWARD    0            /* forward direction        */
  477. #define REVERSE    1            /* backwards direction        */
  478.  
  479. #define FIOSUC    0            /* File I/O, success.        */
  480. #define FIOFNF    1            /* File I/O, file not found.    */
  481. #define FIOEOF    2            /* File I/O, end of file.    */
  482. #define FIOERR    3            /* File I/O, error.        */
  483. #define    FIOMEM    4            /* File I/O, out of memory    */
  484. #define    FIOFUN    5            /* File I/O, eod of file/bad line*/
  485. #define    FIODEL    6            /* Can't delete/rename file    */
  486.  
  487. #define CFCPCN    0x0001            /* Last command was C-P, C-N    */
  488. #define CFKILL    0x0002            /* Last command was a kill    */
  489. #define    CFSRCH    0x0004            /* last command was a search    */
  490.  
  491. #define    SRNORM    0            /* end past, begin front    */
  492. #define    SRBEGIN    1            /* always at front        */
  493. #define    SREND    2            /* always one past end        */
  494.  
  495. #define BELL    0x07            /* a bell character        */
  496. #define    TAB    0x09            /* a tab character        */
  497.  
  498. #if    V7 | USG | SMOS | HPUX | BSD | SUN | XENIX | AVIION
  499. #define    PATHCHR    ':'
  500. #else
  501. #if    WMCS || MPE
  502. #define    PATHCHR ','
  503. #else
  504. #define PATHCHR ';'
  505. #endif
  506. #endif
  507.  
  508. #define INTWIDTH    sizeof(int) * 3
  509.  
  510. /*    Macro argument token types                    */
  511.  
  512. #define TKNUL    0            /* end-of-string        */
  513. #define    TKARG    1            /* interactive argument        */
  514. #define    TKBUF    2            /* buffer argument        */
  515. #define    TKVAR    3            /* user variables        */
  516. #define    TKENV    4            /* environment variables    */
  517. #define    TKFUN    5            /* function....            */
  518. #define    TKDIR    6            /* directive            */
  519. #define    TKLBL    7            /* line label            */
  520. #define    TKLIT    8            /* numeric literal        */
  521. #define    TKSTR    9            /* quoted string literal    */
  522. #define    TKCMD    10            /* command name            */
  523.  
  524. /*    Internal defined functions                    */
  525.  
  526. #define nextab(a)    (a - (a % tabsize)) + tabsize
  527.  
  528. /* DIFCASE represents the integer difference between upper
  529.    and lower case letters.  It is an xor-able value, which is
  530.    fortunate, since the relative positions of upper to lower
  531.    case letters is the opposite of ascii in ebcdic.
  532. */
  533.  
  534. #ifdef    islower
  535. #undef    islower
  536. #endif
  537. #ifdef    isupper
  538. #undef    isupper
  539. #endif
  540.  
  541. #if    ASCII
  542. #define    DIFCASE     0x20
  543. #else
  544. #define DIFCASE        0x40
  545. #endif
  546.  
  547. /* and keep the new sun compiler happy.... */
  548. #if    SUN
  549. #undef    isupper
  550. #undef    islower
  551. #define    isupper(a)    isucase(a)
  552. #define    islower(a)    islcase(a)
  553. #endif
  554.  
  555. /*    Dynamic RAM tracking and reporting redefinitions    */
  556.  
  557. #if    RAMSIZE
  558. #define    malloc    allocate
  559. #define    free    release
  560. #else
  561. #if    VMS & OPTMEM
  562. #define malloc     VAXC$MALLOC_OPT
  563. #define free    VAXC$FREE_OPT
  564. #define calloc    VAXC$CALLOC_OPT
  565. #define realloc VAXC$REALLOC_OPT
  566. #define cfree   VAXC$CFREE_OPT
  567. #endif
  568. #endif
  569.  
  570. /*
  571.  * There is a window structure allocated for every active display window. The
  572.  * windows are kept in a big list, in top to bottom screen order, with the
  573.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  574.  * The flag field contains some bits that are set by commands to guide
  575.  * redisplay. Although this is a bit of a compromise in terms of decoupling,
  576.  * the full blown redisplay is just too expensive to run for every input
  577.  * character.
  578.  */
  579. typedef struct    WINDOW {
  580.     struct    WINDOW *w_wndp;     /* Next window            */
  581.     struct    BUFFER *w_bufp;     /* Buffer displayed in window    */
  582.     struct    LINE *w_linep;        /* Top line in the window    */
  583.     struct    LINE *w_dotp;        /* Line containing "."        */
  584.     short    w_doto;         /* Byte offset for "."        */
  585.     struct    LINE *w_markp[NMARKS];    /* Line containing "mark"    */
  586.     short    w_marko[NMARKS];    /* Byte offset for "mark"    */
  587.     char    w_toprow;        /* Origin 0 top row of window    */
  588.     char    w_ntrows;        /* # of rows of text in window    */
  589.     char    w_force;        /* If NZ, forcing row.        */
  590.     char    w_flag;         /* Flags.            */
  591. #if    COLOR
  592.     char    w_fcolor;        /* current forground color      */
  593.     char    w_bcolor;        /* current background color    */
  594. #endif
  595.     int    w_fcol;         /* first column displayed    */
  596. }    WINDOW;
  597.  
  598. #define WFFORCE 0x01            /* Window needs forced reframe    */
  599. #define WFMOVE    0x02            /* Movement from line to line    */
  600. #define WFEDIT    0x04            /* Editing within a line    */
  601. #define WFHARD    0x08            /* Better to a full display    */
  602. #define WFMODE    0x10            /* Update mode line.        */
  603. #define    WFCOLR    0x20            /* Needs a color change        */
  604.  
  605. /*
  606.  *    This structure holds the information about each separate "screen"
  607.  * within the current editing session.  On a character based system, these
  608.  * screens overlay each other, and can individually be brought to front.
  609.  * On a windowing system like MicroSoft Windows 3.0, OS/2, the Macintosh,
  610.  * Intuition, Sunview or X-windows, each screen is represented in an OS
  611.  * window.  The terminolgy is wrong in emacs.....
  612.  *
  613.  *    EMACS        The outside World
  614.  *    screen        window
  615.  *    window        pane
  616.  */
  617.  
  618. typedef struct SCREEN {
  619.     struct SCREEN *s_next_screen;    /* link to next screen in list */
  620.     WINDOW *s_first_window;        /* head of linked list of windows */
  621.     WINDOW *s_cur_window;        /* current window in this screen */
  622.     char *s_screen_name;        /* name of the current window */
  623.     short s_roworg;            /* row origin of stored screen */
  624.     short s_colorg;            /* column origin of stored screen */
  625.     short s_nrow;            /* row width of stored screen */
  626.     short s_ncol;            /* column origin of stored screen */
  627. } SCREEN;
  628.  
  629. /*
  630.  * Text is kept in buffers. A buffer header, described below, exists for every
  631.  * buffer in the system. The buffers are kept in a big list, so that commands
  632.  * that search for a buffer by name can find the buffer header. There is a
  633.  * safe store for the dot and mark in the header, but this is only valid if
  634.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  635.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  636.  * the header line in "b_linep"    Buffers may be "Inactive" which means the files associated with them
  637.  * have not been read in yet. These get read in at "use buffer" time.
  638.  */
  639. typedef struct    BUFFER {
  640.     struct    BUFFER *b_bufp;     /* Link to next BUFFER        */
  641.     struct    LINE *b_dotp;        /* Link to "." LINE structure    */
  642.     short    b_doto;         /* Offset of "." in above LINE    */
  643.     struct    LINE *b_markp[NMARKS];    /* The same as the above two,    */
  644.     short    b_marko[NMARKS];    /* but for the "mark"        */
  645.     int    b_fcol;            /* first col to display        */
  646.     struct    LINE *b_linep;        /* Link to the header LINE    */
  647.     struct    LINE *b_topline;    /* Link to narrowed top text    */
  648.     struct    LINE *b_botline;    /* Link to narrowed bottom text    */
  649.     char    b_active;        /* window activated flag    */
  650.     char    b_nwnd;         /* Count of windows on buffer    */
  651.     char     b_exec;            /* how many active executions    */
  652.     char    b_flag;         /* Flags            */
  653.     int    b_mode;            /* editor mode of this buffer    */
  654.     char    b_fname[NFILEN];    /* File name            */
  655.     char    b_bname[NBUFN];     /* Buffer name            */
  656. #if    CRYPT
  657.     char   b_key[NPAT];           /* current encrypted key        */
  658. #endif
  659. }    BUFFER;
  660.  
  661. #define BFINVS    0x01            /* Internal invisable buffer    */
  662. #define BFCHG    0x02            /* Changed since last write    */
  663. #define    BFTRUNC    0x04            /* buffer was truncated when read */
  664. #define    BFNAROW    0x08            /* buffer has been narrowed    */
  665.  
  666. /*    mode flags    */
  667. #define    NUMMODES    10           /* # of defined modes           */
  668.  
  669. #define MDWRAP    0x0001            /* word wrap            */
  670. #define    MDCMOD    0x0002            /* C indentation and fence match*/
  671. #define    MDSPELL    0x0004            /* spell error parsing        */
  672. #define    MDEXACT    0x0008            /* Exact matching for searches    */
  673. #define    MDVIEW    0x0010            /* read-only buffer        */
  674. #define MDOVER    0x0020            /* overwrite mode        */
  675. #define MDMAGIC    0x0040            /* regular expresions in search */
  676. #define    MDCRYPT    0x0080            /* encrytion mode active    */
  677. #define    MDASAVE    0x0100            /* auto-save mode        */
  678. #define    MDREPL    0x0200            /* replace mode            */
  679.  
  680. /*
  681.  * The starting position of a region, and the size of the region in
  682.  * characters, is kept in a region structure.  Used by the region commands.
  683.  */
  684. typedef struct    {
  685.     struct    LINE *r_linep;        /* Origin LINE address.     */
  686.     short    r_offset;        /* Origin LINE offset.        */
  687.     long    r_size;         /* Length in characters.    */
  688. }    REGION;
  689.  
  690. /*
  691.  * All text is kept in circularly linked lists of "LINE" structures. These
  692.  * begin at the header line (which is the blank line beyond the end of the
  693.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  694.  * number of bytes in the line (the "used" size), the size of the text array,
  695.  * and the text. The end of line is not stored as a byte; it's implied.
  696.  */
  697. typedef struct    LINE {
  698.     struct    LINE *l_fp;        /* Link to the next line    */
  699.     struct    LINE *l_bp;        /* Link to the previous line    */
  700.     short    l_size;         /* Allocated size        */
  701.     short    l_used;         /* Used size            */
  702.     char    l_text[1];        /* A bunch of characters.    */
  703. }    LINE;
  704.  
  705. #define lforw(lp)    ((lp)->l_fp)
  706. #define lback(lp)    ((lp)->l_bp)
  707. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  708. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  709. #define llength(lp)    ((lp)->l_used)
  710.  
  711. /*
  712.  * The editor communicates with the display using a high level interface. A
  713.  * "TERM" structure holds useful variables, and indirect pointers to routines
  714.  * that do useful operations. The low level get and put routines are here too.
  715.  * This lets a terminal, in addition to having non standard commands, have
  716.  * funny get and put character code too. The calls might get changed to
  717.  * "termp->t_field" style in the future, to make it possible to run more than
  718.  * one terminal type.
  719.  */
  720. typedef struct    {
  721.     short    t_mrow;          /* max number of rows allowable */
  722.     short    t_nrow;         /* current number of rows used    */
  723.     short    t_mcol;         /* max Number of columns.    */
  724.     short    t_ncol;         /* current Number of columns.    */
  725.     short    t_roworg;        /* origin row (normally zero)    */
  726.     short    t_colorg;        /* origin column (normally zero)*/
  727.     short    t_margin;        /* min margin for extended lines*/
  728.     short    t_scrsiz;        /* size of scroll region "    */
  729.     int    t_pause;        /* # times thru update to pause */
  730.     int (PASCAL NEAR *t_open)();    /* Open terminal at the start.    */
  731.     int (PASCAL NEAR *t_close)();    /* Close terminal at end.    */
  732.     int (PASCAL NEAR *t_kopen)();    /* Open keyboard        */
  733.     int (PASCAL NEAR *t_kclose)();    /* close keyboard        */
  734.     int (PASCAL NEAR *t_getchar)(); /* Get character from keyboard. */
  735.     int (PASCAL NEAR *t_putchar)(); /* Put character to display.    */
  736.     int (PASCAL NEAR *t_flush)();    /* Flush output buffers.    */
  737.     int (PASCAL NEAR *t_move)();    /* Move the cursor, origin 0.    */
  738.     int (PASCAL NEAR *t_eeol)();    /* Erase to end of line.    */
  739.     int (PASCAL NEAR *t_eeop)();    /* Erase to end of page.    */
  740.     int (PASCAL NEAR *t_clrdesk)();    /* Clear the page totally    */
  741.     int (PASCAL NEAR *t_beep)();    /* Beep.            */
  742.     int (PASCAL NEAR *t_rev)();    /* set reverse video state    */
  743.     int (PASCAL NEAR *t_rez)();    /* change screen resolution    */
  744. #if    COLOR
  745.     int (PASCAL NEAR *t_setfor)();     /* set forground color        */
  746.     int (PASCAL NEAR *t_setback)();    /* set background color        */
  747. #endif
  748. #if    INSDEL
  749.     int (PASCAL NEAR *t_insline)();    /* insert a screen line        */
  750.     int (PASCAL NEAR *t_delline)();    /* delete a screen line        */
  751. #endif
  752. }    TERM;
  753.  
  754. /*    TEMPORARY macros for terminal I/O  (to be placed in a machine
  755.                         dependant place later) */
  756.  
  757. #define TTopen        (*term.t_open)
  758. #define    TTclose        (*term.t_close)
  759. #define    TTkopen        (*term.t_kopen)
  760. #define    TTkclose    (*term.t_kclose)
  761. #define    TTgetc        (*term.t_getchar)
  762. #define    TTputc        (*term.t_putchar)
  763. #define    TTflush        (*term.t_flush)
  764. #define    TTmove        (*term.t_move)
  765. #define    TTeeol        (*term.t_eeol)
  766. #define    TTeeop        (*term.t_eeop)
  767. #define    TTclrdesk    (*term.t_clrdesk)
  768. #define    TTbeep        (*term.t_beep)
  769. #define    TTrev        (*term.t_rev)
  770. #define    TTrez        (*term.t_rez)
  771. #if    COLOR
  772. #define    TTforg        (*term.t_setfor)
  773. #define    TTbacg        (*term.t_setback)
  774. #endif
  775.  
  776. /*    Structure for the table of current key bindings     */
  777.  
  778. ETYPE EPOINTER {
  779.     int (PASCAL NEAR *fp)();    /* C routine to invoke */
  780.     BUFFER *buf;            /* buffer to execute */
  781. };
  782.  
  783. typedef struct    {
  784.     short k_code;         /* Key code            */
  785.     short k_type;        /* binding type (C function or EMACS buffer) */
  786.     ETYPE EPOINTER k_ptr;    /* ptr to thing to execute */
  787. }    KEYTAB;
  788.  
  789. /*    structure for the name binding table        */
  790.  
  791. typedef struct {
  792.     char *n_name;            /* name of function key */
  793.     int (PASCAL NEAR *n_func)();    /* function name is bound to */
  794. }    NBIND;
  795.  
  796. /*    The editor holds deleted text chunks in the KILL buffer. The
  797.     kill buffer is logically a stream of ascii characters, however
  798.     due to its unpredicatable size, it gets implemented as a linked
  799.     list of chunks. (The d_ prefix is for "deleted" text, as k_
  800.     was taken up by the keycode structure)
  801. */
  802.  
  803. typedef struct KILL {
  804.     struct KILL *d_next;   /* link to next chunk, NULL if last */
  805.     char d_chunk[KBLOCK];    /* deleted text */
  806. } KILL;
  807.  
  808. /*    When emacs' command interpetor needs to get a variable's name,
  809.     rather than it's value, it is passed back as a VDESC variable
  810.     description structure. The v_num field is a index into the
  811.     appropriate variable table.
  812. */
  813.  
  814. typedef struct VDESC {
  815.     int v_type;    /* type of variable */
  816.     int v_num;    /* ordinal pointer to variable in list */
  817. } VDESC;
  818.  
  819. /*    The !WHILE directive in the execution language needs to
  820.     stack references to pending whiles. These are stored linked
  821.     to each currently open procedure via a linked list of
  822.     the following structure
  823. */
  824.  
  825. typedef struct WHBLOCK {
  826.     LINE *w_begin;        /* ptr to !while statement */
  827.     LINE *w_end;        /* ptr to the !endwhile statement*/
  828.     int w_type;        /* block type */
  829.     struct WHBLOCK *w_next;    /* next while */
  830. } WHBLOCK;
  831.  
  832. #define BTWHILE     1
  833. #define    BTBREAK        2
  834.  
  835.  
  836. /* HICHAR - 1 is the largest character we will deal with.
  837.  * HIBYTE represents the number of bytes in the bitmap.
  838.  */
  839. #define HICHAR        256
  840. #if OS2
  841. #define    HIBYTE_        HICHAR >> 3
  842. #else
  843. #define    HIBYTE        HICHAR >> 3
  844. #endif
  845.  
  846. #if    MAGIC
  847. /*
  848.  * Defines for the metacharacters in the regular expression
  849.  * search routines.  MCNIL and LITCHAR are used in both search
  850.  * and replace metachar-arrays.
  851.  */
  852. #define MCNIL        0    /* Like the '\0' for strings.*/
  853. #define    LITCHAR        1    /* Literal character, or string.*/
  854. #define    ANY        2
  855. #define    CCL        3
  856. #define    NCCL        4
  857. #define    BOL        5
  858. #define    EOL        6
  859. #define    GRPBEG        0x0010    /* Toggle-able value for group begin.*/
  860. #define    GRPEND        0x0020    /* Toggle-able value for group end.*/
  861.  
  862. #define    DITTO        2    /* Replacement #define.*/
  863. #define GROUP        3    /* Replacement #define.*/
  864.  
  865. #define    CLOSURE        0x0100    /* An or-able value for a closure modifier.*/
  866. #define    CLOSURE_1    0x0200    /* An or-able value for a closure modifier.*/
  867. #define    ZEROONE        0x0400    /* An or-able value for a closure modifier.*/
  868.  
  869. #define ALLCLOS        (CLOSURE | CLOSURE_1 | ZEROONE)
  870. #define    MASKCLO        (~ALLCLOS)
  871.  
  872. #define MC_ANY        '.'    /* 'Any' character (except newline).*/
  873. #define    MC_CCL        '['    /* Character class.*/
  874. #define    MC_NCCL        '^'    /* Negate character class.*/
  875. #define    MC_RCCL        '-'    /* Range in character class.*/
  876. #define    MC_ECCL        ']'    /* End of character class.*/
  877. #define    MC_BOL        '^'    /* Beginning of line.*/
  878. #define    MC_EOL        '$'    /* End of line.*/
  879. #define    MC_CLOSURE    '*'    /* Closure - zero to many characters match.*/
  880. #define    MC_CLOSURE_1    '+'    /* Closure - one to many characters match.*/
  881. #define    MC_ZEROONE    '?'    /* Closure - zero to one characters match.*/
  882. #define    MC_DITTO    '&'    /* Use matched string in replacement.*/
  883. #define MC_GRPBEG    '('    /* Start of group (begun with a backslash).*/
  884. #define MC_GRPEND    ')'    /* End of group (begun with a backslash).*/
  885. #define    MC_ESC        '\\'    /* Escape - suppress meta-meaning.*/
  886.  
  887. #define MAXGROUPS    10        /* 1 + maximum # of r. e. groups. */
  888. #define BIT(n)        (1 << (n))    /* An integer with one bit set.*/
  889.  
  890. /* Typedefs that define the bitmap type for searching (BITMAP),
  891.  * the meta-character structure for MAGIC mode searching (MC),
  892.  * and the meta-character structure for MAGIC mode replacment (RMC).
  893.  */
  894. typedef char    *BITMAP;
  895.  
  896. typedef struct {
  897.     short int    mc_type;
  898.     union {
  899.         int    lchar;
  900.         int    group_no;
  901.         BITMAP    cclmap;
  902.     } u;
  903. } MC;
  904.  
  905. typedef struct {
  906.     short int      mc_type;
  907.     union {
  908.         int    group_no;
  909.         char    *rstr;
  910.     } u;
  911. } RMC;
  912. #endif
  913.  
  914. /*
  915.     This is the message which should be added to any "About MicroEMACS"
  916.     boxes on any of the machines with window managers.
  917.  
  918.  
  919.     ------------------------------------------
  920.     |                     |
  921.     |     MicroEMACS v3.xx         |
  922.     |        for the ............     |
  923.     |                     |
  924.     |    Text Editor and Corrector         |
  925.     |                     |
  926.     |    written by Daniel M. Lawrence     |
  927.     |    [based on code by Dave Conroy]     |
  928.     |                     |
  929.     |    Send inquiries and donations to:     |
  930.     |    617 New York St             |
  931.     |    Lafayette, IN 47901         |
  932.     |                     |
  933.     ------------------------------------------
  934. */
  935.