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