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