home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / textutil / microemacs / Source / h / estruct < prev    next >
Encoding:
Text File  |  1991-09-14  |  28.0 KB  |  967 lines

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