home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume1 / 8711 / microemacs-3.9 / 16 < prev    next >
Text File  |  1987-11-20  |  31KB  |  975 lines

  1. Article 93 of comp.sources.misc:
  2. Path: tut!osu-cis!cbosgd!mandrill!hal!ncoast!allbery
  3. From: nwd@j.cc.purdue.edu (Daniel Lawrence)
  4. Newsgroups: comp.sources.misc
  5. Subject: MicroEmacs 3.9 (Part 16 of 16)
  6. Message-ID: <5692@ncoast.UUCP>
  7. Date: 17 Nov 87 02:37:35 GMT
  8. Sender: allbery@ncoast.UUCP
  9. Lines: 960
  10. Approved: allbery@ncoast.UUCP
  11. X-Archive: comp.sources.misc/microemacs-3.9/15
  12.  
  13. # This is a shar archive.
  14. # Remove everything above this line.
  15. # Run the file through sh, not csh.
  16. # (type `sh mes.16')
  17. # If you do not see the message
  18. #    `mes.16 completed!'
  19. # then the file was incomplete.
  20. echo extracting - epath.h
  21. sed 's/^X//' > epath.h << 'FRIDAY_NIGHT'
  22. X/*    EPATH:    This file contains certain info needed to locate the
  23. X        MicroEMACS files on a system dependant basis.
  24. X
  25. X                                    */
  26. X
  27. X/*    possible names and paths of help files under different OSs    */
  28. X
  29. Xchar *pathname[] =
  30. X
  31. X#if    AMIGA
  32. X{
  33. X    ".emacsrc",
  34. X    "emacs.hlp",
  35. X    "",
  36. X    "sys:c/",
  37. X    "sys:t/",
  38. X    "sys:s/",
  39. X    "c:/",
  40. X    ":t/",
  41. X    ":s/"
  42. X};
  43. X#endif
  44. X
  45. X#if    ST520
  46. X{
  47. X    "emacs.rc",
  48. X    "emacs.hlp",
  49. X    "\\",
  50. X    "\\bin\\",
  51. X    "\\util\\",
  52. X    ""
  53. X};
  54. X#endif
  55. X
  56. X#if    FINDER
  57. X{
  58. X    "emacs.rc",
  59. X    "emacs.hlp",
  60. X    "/bin",
  61. X    "/sys/public",
  62. X    ""
  63. X};
  64. X#endif
  65. X
  66. X#if    MSDOS
  67. X{
  68. X    "emacs.rc",
  69. X    "emacs.hlp",
  70. X    "\\sys\\public\\",
  71. X    "\\usr\\bin\\",
  72. X    "\\bin\\",
  73. X    "\\",
  74. X    ""
  75. X};
  76. X#endif
  77. X
  78. X#if    V7 | BSD | USG
  79. X{
  80. X    ".emacsrc",
  81. X    "emacs.hlp",
  82. X    "/usr/local/",
  83. X    "/usr/lib/",
  84. X    ""
  85. X};
  86. X#endif
  87. X
  88. X#if    VMS
  89. X{
  90. X    "emacs.rc",
  91. X    "emacs.hlp",
  92. X    "",
  93. X    "sys$sysdevice:[vmstools]"
  94. X};
  95. X#endif
  96. X
  97. X#define    NPNAMES    (sizeof(pathname)/sizeof(char *))
  98. FRIDAY_NIGHT
  99. echo extracting - estruct.h
  100. sed 's/^X//' > estruct.h << 'FRIDAY_NIGHT'
  101. X/*      ESTRUCT:        Structure and preprocesser defined for
  102. X                        MicroEMACS 3.9
  103. X
  104. X                        written by Dave G. Conroy
  105. X                        modified by Steve Wilhite, George Jones
  106. X                        substantially modified by Daniel Lawrence
  107. X*/
  108. X
  109. X#ifdef    LATTICE
  110. X#undef    LATTICE        /* don't use their definitions...use ours    */
  111. X#endif
  112. X#ifdef    MSDOS
  113. X#undef    MSDOS
  114. X#endif
  115. X#ifdef    CPM
  116. X#undef    CPM
  117. X#endif
  118. X#ifdef    AMIGA
  119. X#undef    AMIGA
  120. X#endif
  121. X#ifdef    EGA
  122. X#undef    EGA
  123. X#endif
  124. X#ifdef    CTRLZ
  125. X#undef    CTRLZ
  126. X#endif
  127. X
  128. X/*    Program Identification.....
  129. X
  130. X    PROGNAME should always be MicroEMACS for a distibrution
  131. X    unmodified version. People using MicroEMACS as a shell
  132. X    for other products should change this to reflect their
  133. X    product. Macros can query this via the $progname variable
  134. X*/
  135. X
  136. X#define    PROGNAME    "MicroEMACS"
  137. X#define    VERSION        "3.9e"
  138. X
  139. X/*    Machine/OS definitions            */
  140. X
  141. X#define AMIGA   0                       /* AmigaDOS            */
  142. X#define ST520   0                       /* ST520, TOS                   */
  143. X#define MSDOS   1                       /* MS-DOS                       */
  144. X#define V7      0                       /* V7 UNIX or Coherent or BSD4.2*/
  145. X#define    BSD    0            /* UNIX BSD 4.2    and ULTRIX    */
  146. X#define    USG    0            /* UNIX system V        */
  147. X#define VMS     0                       /* VAX/VMS                      */
  148. X#define CPM     0                       /* CP/M-86                      */
  149. X#define    FINDER    0            /* Macintosh OS            */
  150. X
  151. X/*    Compiler definitions            */
  152. X#define    UNIX    0    /* a random UNIX compiler */
  153. X#define MWC    0    /* Marc Williams C */
  154. X#define    LATTICE    0    /* Lattice 2.14 thruough 3.0 compilers */
  155. X#define    AZTEC    1    /* Aztec C 3.20e */
  156. X#define    MSC    0    /* MicroSoft C compile version 3 & 4 */
  157. X#define    TURBO    0    /* Turbo C/MSDOS */
  158. X
  159. X/*    Debugging options    */
  160. X#define    RAMSIZE    0    /* dynamic RAM memory usage tracking */
  161. X#define    RAMSHOW    0    /* auto dynamic RAM reporting */
  162. X
  163. X/*   Special keyboard definitions            */
  164. X
  165. X#define WANGPC    0        /* WangPC - mostly escape sequences     */
  166. X#define VT100   0               /* Handle VT100 style keypad.   */
  167. X
  168. X/*    Terminal Output definitions        */
  169. X
  170. X#define ANSI    0            /* ANSI escape sequences    */
  171. X#define    HP150    0            /* HP150 screen driver        */
  172. X#define    HP110    0            /* HP110 screen driver        */
  173. X#define    VMSVT    0            /* various VMS terminal entries    */
  174. X#define VT52    0                       /* VT52 terminal (Zenith).      */
  175. X#define RAINBOW 0                       /* Use Rainbow fast video.      */
  176. X#define TERMCAP 0                       /* Use TERMCAP                  */
  177. X#define    IBMPC    1            /* IBM-PC CGA/MONO/EGA driver    */
  178. X#define    DG10    0            /* Data General system/10    */
  179. X#define    TIPC    0            /* TI Profesional PC driver    */
  180. X#define    Z309    0            /* Zenith 100 PC family    driver    */
  181. X#define    MAC    0            /* Macintosh            */
  182. X#define    ATARI    0            /* Atari 520/1040ST screen    */
  183. X
  184. X/*    Configuration options    */
  185. X
  186. X#define CVMVAS  1    /* arguments to page forward/back in pages    */
  187. X#define    CLRMSG    0    /* space clears the message line with no insert    */
  188. X#define    CFENCE    1    /* fench matching in CMODE            */
  189. X#define    TYPEAH    1    /* type ahead causes update to be skipped    */
  190. X#define DEBUGM    1    /* $debug triggers macro debugging        */
  191. X#define    VISMAC    0    /* update display during keyboard macros    */
  192. X#define    CTRLZ    0    /* add a ^Z at end of files under MSDOS only    */
  193. X#define ADDCR    0    /* ajout d'un CR en fin de chaque ligne (ST520) */
  194. X#define    NBRACE    1    /* new style brace matching command        */
  195. X
  196. X#define    REVSTA    1    /* Status line appears in reverse video        */
  197. X#define    COLOR    1    /* color commands and windows            */
  198. X
  199. X#define    FILOCK    0    /* file locking under unix BSD 4.2        */
  200. X#define    ISRCH    1    /* Incremental searches like ITS EMACS        */
  201. X#define    WORDPRO    1    /* Advanced word processing features        */
  202. X#define    FLABEL    0    /* function key label code [HP150]        */
  203. X#define    APROP    1    /* Add code for Apropos command            */
  204. X#define    CRYPT    1    /* file encryption enabled?            */
  205. X#define MAGIC    1    /* include regular expression matching?        */
  206. X#define    AEDIT    1    /* advanced editing options: en/detabbing    */
  207. X#define    PROC    1    /* named procedures                */
  208. X#define    CLEAN    0    /* de-alloc memory on exit            */
  209. X#define    CALLED    0    /* is emacs a called subroutine? or stand alone */
  210. X
  211. X#define ASCII    1    /* always using ASCII char sequences for now    */
  212. X#define EBCDIC    0    /* later IBM mainfraim versions will use EBCDIC    */
  213. X
  214. X/*    System dependant library redefinitions, structures and includes    */
  215. X
  216. X#if    TURBO
  217. X#include      <dos.h>
  218. X#include      <mem.h>
  219. X#undef peek
  220. X#undef poke
  221. X#define       peek(a,b,c,d)   movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  222. X#define       poke(a,b,c,d)   movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  223. X#endif
  224. X
  225. X#if    VMS
  226. X#define    atoi    xatoi
  227. X#define    abs    xabs
  228. X#define    getname    xgetname
  229. X#endif
  230. X
  231. X#if    LATTICE
  232. X#define    unsigned
  233. X#endif
  234. X
  235. X#if    AZTEC
  236. X#undef    fputc
  237. X#undef    fgetc
  238. X#if    MSDOS
  239. X#define    fgetc    a1getc
  240. X#define    int86    sysint
  241. X#define    intdos(a, b)    sysint(33, a, b)
  242. X#define    inp    inportb
  243. X#define    outp    outportb
  244. X#else
  245. X#define    fgetc    agetc
  246. X#endif
  247. X#define    fputc    aputc
  248. X
  249. Xstruct XREG {
  250. X    unsigned ax,bx,cx,dx,si,di,ds,es;
  251. X};
  252. X
  253. Xstruct HREG {
  254. X    char al,ah,bl,bh,cl,ch,dl,dh,d1,d2,e1,e2;
  255. X};
  256. X
  257. Xunion REGS {
  258. X    struct XREG x;
  259. X    struct HREG h;
  260. X};
  261. X
  262. Xstruct SREGS {
  263. X    unsigned cs, ss, ds, es;
  264. X};
  265. X#endif
  266. X
  267. X#if    MSDOS & MWC
  268. X#include    <dos.h>
  269. X#define    int86(a, b, c)    intcall(b, c, a)
  270. X#define    inp    in
  271. X
  272. Xstruct XREG {
  273. X    int ax,bx,cx,dx,si,di,ds,es,flags;
  274. X};
  275. X
  276. Xstruct HREG {
  277. X    char al,ah,bl,bh,cl,ch,dl,dh;
  278. X    int ds,es,flags;
  279. X};
  280. X
  281. Xunion REGS {
  282. X    struct XREG x;
  283. X    struct HREG h;
  284. X};
  285. X#endif
  286. X
  287. X#if    MSDOS & MSC
  288. X#include    <dos.h>
  289. X#include    <memory.h>
  290. X#define    peek(a,b,c,d)    movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  291. X#define    poke(a,b,c,d)    movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  292. X#define    movmem(a, b, c)        memcpy(b, a, c)
  293. X#endif
  294. X
  295. X#if    MSDOS & LATTICE
  296. X#undef    CPM
  297. X#undef    LATTICE
  298. X#include    <dos.h>
  299. X#undef    CPM
  300. X#endif
  301. X
  302. X#if    VMS
  303. X#define    unlink(a)    delete(a)
  304. X#endif
  305. X
  306. X/*    define some ability flags */
  307. X
  308. X#if    IBMPC | Z309
  309. X#define    MEMMAP    1
  310. X#else
  311. X#define    MEMMAP    0
  312. X#endif
  313. X
  314. X#if    MSDOS | V7 | USG | BSD | (ST520 & MWC)
  315. X#define    ENVFUNC    1
  316. X#else
  317. X#define    ENVFUNC    0
  318. X#endif
  319. X
  320. X/*    Emacs global flag bit definitions (for gflags)    */
  321. X
  322. X#define    GFREAD    1
  323. X
  324. X/*    internal constants    */
  325. X
  326. X#define    NBINDS    256            /* max # of bound keys        */
  327. X#define NFILEN  80                      /* # of bytes, file name        */
  328. X#define NBUFN   16                      /* # of bytes, buffer name      */
  329. X#define NLINE   256                     /* # of bytes, input line       */
  330. X#define    NSTRING    128            /* # of bytes, string buffers    */
  331. X#define NKBDM   256                     /* # of strokes, keyboard macro */
  332. X#define NPAT    128                     /* # of bytes, pattern          */
  333. X#define HUGE    1000                    /* Huge number                  */
  334. X#define    NLOCKS    100            /* max # of file locks active    */
  335. X#define    NCOLORS    8            /* number of supported colors    */
  336. X#define    KBLOCK    250            /* sizeof kill buffer chunks    */
  337. X#define    NBLOCK    16            /* line block chunk size    */
  338. X#define    NVSIZE    10            /* max #chars in a var name    */
  339. X
  340. X#define CTRL    0x0100                  /* Control flag, or'ed in       */
  341. X#define META    0x0200                  /* Meta flag, or'ed in          */
  342. X#define CTLX    0x0400                  /* ^X flag, or'ed in            */
  343. X#define    SPEC    0x0800            /* special key (function keys)    */
  344. X
  345. X#ifdef    FALSE
  346. X#undef    FALSE
  347. X#endif
  348. X#ifdef    TRUE
  349. X#undef    TRUE
  350. X#endif
  351. X
  352. X#define FALSE   0                       /* False, no, bad, etc.         */
  353. X#define TRUE    1                       /* True, yes, good, etc.        */
  354. X#define ABORT   2                       /* Death, ^G, abort, etc.       */
  355. X#define    FAILED    3            /* not-quite fatal false return    */
  356. X
  357. X#define    STOP    0            /* keyboard macro not in use    */
  358. X#define    PLAY    1            /*          playing    */
  359. X#define    RECORD    2            /*          recording    */
  360. X
  361. X/*    Directive definitions    */
  362. X
  363. X#define    DIF        0
  364. X#define DELSE        1
  365. X#define DENDIF        2
  366. X#define DGOTO        3
  367. X#define DRETURN        4
  368. X#define DENDM        5
  369. X#define DWHILE        6
  370. X#define    DENDWHILE    7
  371. X#define    DBREAK        8
  372. X#define DFORCE        9
  373. X
  374. X#define NUMDIRS        10
  375. X
  376. X/*
  377. X * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for
  378. X * the scan routines.
  379. X */
  380. X#define    PTBEG    0    /* Leave the point at the beginning on search    */
  381. X#define    PTEND    1    /* Leave the point at the end on search        */
  382. X#define    FORWARD    0            /* forward direction        */
  383. X#define REVERSE    1            /* backwards direction        */
  384. X
  385. X#define FIOSUC  0                       /* File I/O, success.           */
  386. X#define FIOFNF  1                       /* File I/O, file not found.    */
  387. X#define FIOEOF  2                       /* File I/O, end of file.       */
  388. X#define FIOERR  3                       /* File I/O, error.             */
  389. X#define    FIOMEM    4            /* File I/O, out of memory    */
  390. X#define    FIOFUN    5            /* File I/O, eod of file/bad line*/
  391. X
  392. X#define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  393. X#define CFKILL  0x0002                  /* Last command was a kill      */
  394. X
  395. X#define    BELL    0x07            /* a bell character        */
  396. X#define    TAB    0x09            /* a tab character        */
  397. X
  398. X#if    V7 | USG | BSD
  399. X#define    PATHCHR    ':'
  400. X#else
  401. X#define    PATHCHR    ';'
  402. X#endif
  403. X
  404. X#define    INTWIDTH    sizeof(int) * 3
  405. X
  406. X/*    Macro argument token types                    */
  407. X
  408. X#define    TKNUL    0            /* end-of-string        */
  409. X#define    TKARG    1            /* interactive argument        */
  410. X#define    TKBUF    2            /* buffer argument        */
  411. X#define    TKVAR    3            /* user variables        */
  412. X#define    TKENV    4            /* environment variables    */
  413. X#define    TKFUN    5            /* function....            */
  414. X#define    TKDIR    6            /* directive            */
  415. X#define    TKLBL    7            /* line label            */
  416. X#define    TKLIT    8            /* numeric literal        */
  417. X#define    TKSTR    9            /* quoted string literal    */
  418. X#define    TKCMD    10            /* command name            */
  419. X
  420. X/*    Internal defined functions                    */
  421. X
  422. X#define    nextab(a)    (a & ~7) + 8
  423. X#ifdef    abs
  424. X#undef    abs
  425. X#endif
  426. X
  427. X/* DIFCASE represents the integer difference between upper
  428. X   and lower case letters.  It is an xor-able value, which is
  429. X   fortunate, since the relative positions of upper to lower
  430. X   case letters is the opposite of ascii in ebcdic.
  431. X*/
  432. X
  433. X#ifdef    islower
  434. X#undef    islower
  435. X#endif
  436. X
  437. X#if    ASCII
  438. X
  439. X#define    DIFCASE        0x20
  440. X#define isletter(c)    (('a' <= c && 'z' >= c) || ('A' <= c && 'Z' >= c))
  441. X#define islower(c)    (('a' <= c && 'z' >= c))
  442. X#endif
  443. X
  444. X#if    EBCDIC
  445. X
  446. X#define    DIFCASE        0x40
  447. X#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))
  448. X#define islower(c)    (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c))
  449. X#endif
  450. X
  451. X/*    Dynamic RAM tracking and reporting redefinitions    */
  452. X
  453. X#if    RAMSIZE
  454. X#define    malloc    allocate
  455. X#define    free    release
  456. X#endif
  457. X
  458. X/*    De-allocate memory always on exit (if the operating system or
  459. X    main program can not
  460. X*/
  461. X
  462. X#if    CLEAN
  463. X#define    exit(a)    cexit(a)
  464. X#endif
  465. X
  466. X/*
  467. X * There is a window structure allocated for every active display window. The
  468. X * windows are kept in a big list, in top to bottom screen order, with the
  469. X * listhead at "wheadp". Each window contains its own values of dot and mark.
  470. X * The flag field contains some bits that are set by commands to guide
  471. X * redisplay. Although this is a bit of a compromise in terms of decoupling,
  472. X * the full blown redisplay is just too expensive to run for every input
  473. X * character.
  474. X */
  475. Xtypedef struct  WINDOW {
  476. X        struct  WINDOW *w_wndp;         /* Next window                  */
  477. X        struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  478. X        struct  LINE *w_linep;          /* Top line in the window       */
  479. X        struct  LINE *w_dotp;           /* Line containing "."          */
  480. X        short   w_doto;                 /* Byte offset for "."          */
  481. X        struct  LINE *w_markp;          /* Line containing "mark"       */
  482. X        short   w_marko;                /* Byte offset for "mark"       */
  483. X        char    w_toprow;               /* Origin 0 top row of window   */
  484. X        char    w_ntrows;               /* # of rows of text in window  */
  485. X        char    w_force;                /* If NZ, forcing row.          */
  486. X        char    w_flag;                 /* Flags.                       */
  487. X#if    COLOR
  488. X    char    w_fcolor;        /* current forground color    */
  489. X    char    w_bcolor;        /* current background color    */
  490. X#endif
  491. X}       WINDOW;
  492. X
  493. X#define WFFORCE 0x01                    /* Window needs forced reframe  */
  494. X#define WFMOVE  0x02                    /* Movement from line to line   */
  495. X#define WFEDIT  0x04                    /* Editing within a line        */
  496. X#define WFHARD  0x08                    /* Better to a full display     */
  497. X#define WFMODE  0x10                    /* Update mode line.            */
  498. X#define    WFCOLR    0x20            /* Needs a color change        */
  499. X
  500. X/*
  501. X * Text is kept in buffers. A buffer header, described below, exists for every
  502. X * buffer in the system. The buffers are kept in a big list, so that commands
  503. X * that search for a buffer by name can find the buffer header. There is a
  504. X * safe store for the dot and mark in the header, but this is only valid if
  505. X * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  506. X * the buffer is kept in a circularly linked list of lines, with a pointer to
  507. X * the header line in "b_linep".
  508. X *     Buffers may be "Inactive" which means the files associated with them
  509. X * have not been read in yet. These get read in at "use buffer" time.
  510. X */
  511. Xtypedef struct  BUFFER {
  512. X        struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  513. X        struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  514. X        short   b_doto;                 /* Offset of "." in above LINE  */
  515. X        struct  LINE *b_markp;          /* The same as the above two,   */
  516. X        short   b_marko;                /* but for the "mark"           */
  517. X        struct  LINE *b_linep;          /* Link to the header LINE      */
  518. X    char    b_active;        /* window activated flag    */
  519. X        char    b_nwnd;                 /* Count of windows on buffer   */
  520. X        char    b_flag;                 /* Flags                        */
  521. X    int    b_mode;            /* editor mode of this buffer    */
  522. X        char    b_fname[NFILEN];        /* File name                    */
  523. X        char    b_bname[NBUFN];         /* Buffer name                  */
  524. X#if    CRYPT
  525. X    char    b_key[NPAT];        /* current encrypted key    */
  526. X#endif
  527. X}       BUFFER;
  528. X
  529. X#define BFINVS  0x01                    /* Internal invisable buffer    */
  530. X#define BFCHG   0x02                    /* Changed since last write     */
  531. X#define    BFTRUNC    0x04            /* buffer was truncated when read */
  532. X
  533. X/*    mode flags    */
  534. X#define    NUMMODES    9        /* # of defined modes        */
  535. X
  536. X#define    MDWRAP    0x0001            /* word wrap            */
  537. X#define    MDCMOD    0x0002            /* C indentation and fence match*/
  538. X#define    MDSPELL    0x0004            /* spell error parcing        */
  539. X#define    MDEXACT    0x0008            /* Exact matching for searches    */
  540. X#define    MDVIEW    0x0010            /* read-only buffer        */
  541. X#define MDOVER    0x0020            /* overwrite mode        */
  542. X#define MDMAGIC    0x0040            /* regular expresions in search */
  543. X#define    MDCRYPT    0x0080            /* encrytion mode active    */
  544. X#define    MDASAVE    0x0100            /* auto-save mode        */
  545. X
  546. X/*
  547. X * The starting position of a region, and the size of the region in
  548. X * characters, is kept in a region structure.  Used by the region commands.
  549. X */
  550. Xtypedef struct  {
  551. X        struct  LINE *r_linep;          /* Origin LINE address.         */
  552. X        short   r_offset;               /* Origin LINE offset.          */
  553. X        long    r_size;                 /* Length in characters.        */
  554. X}       REGION;
  555. X
  556. X/*
  557. X * All text is kept in circularly linked lists of "LINE" structures. These
  558. X * begin at the header line (which is the blank line beyond the end of the
  559. X * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  560. X * number of bytes in the line (the "used" size), the size of the text array,
  561. X * and the text. The end of line is not stored as a byte; it's implied. Future
  562. X * additions will include update hints, and a list of marks into the line.
  563. X */
  564. Xtypedef struct  LINE {
  565. X        struct  LINE *l_fp;             /* Link to the next line        */
  566. X        struct  LINE *l_bp;             /* Link to the previous line    */
  567. X        short   l_size;                 /* Allocated size               */
  568. X        short   l_used;                 /* Used size                    */
  569. X        char    l_text[1];              /* A bunch of characters.       */
  570. X}       LINE;
  571. X
  572. X#define lforw(lp)       ((lp)->l_fp)
  573. X#define lback(lp)       ((lp)->l_bp)
  574. X#define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  575. X#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  576. X#define llength(lp)     ((lp)->l_used)
  577. X
  578. X/*
  579. X * The editor communicates with the display using a high level interface. A
  580. X * "TERM" structure holds useful variables, and indirect pointers to routines
  581. X * that do useful operations. The low level get and put routines are here too.
  582. X * This lets a terminal, in addition to having non standard commands, have
  583. X * funny get and put character code too. The calls might get changed to
  584. X * "termp->t_field" style in the future, to make it possible to run more than
  585. X * one terminal type.
  586. X */
  587. Xtypedef struct  {
  588. X    short    t_mrow;            /* max number of rows allowable */
  589. X        short   t_nrow;                 /* current number of rows used  */
  590. X        short   t_mcol;                 /* max Number of columns.       */
  591. X        short   t_ncol;                 /* current Number of columns.   */
  592. X    short    t_margin;        /* min margin for extended lines*/
  593. X    short    t_scrsiz;        /* size of scroll region "    */
  594. X    int    t_pause;        /* # times thru update to pause */
  595. X        int     (*t_open)();            /* Open terminal at the start.  */
  596. X        int     (*t_close)();           /* Close terminal at end.       */
  597. X    int    (*t_kopen)();        /* Open keyboard        */
  598. X    int    (*t_kclose)();        /* close keyboard        */
  599. X        int     (*t_getchar)();         /* Get character from keyboard. */
  600. X        int     (*t_putchar)();         /* Put character to display.    */
  601. X        int     (*t_flush)();           /* Flush output buffers.        */
  602. X        int     (*t_move)();            /* Move the cursor, origin 0.   */
  603. X        int     (*t_eeol)();            /* Erase to end of line.        */
  604. X        int     (*t_eeop)();            /* Erase to end of page.        */
  605. X        int     (*t_beep)();            /* Beep.                        */
  606. X    int    (*t_rev)();        /* set reverse video state    */
  607. X    int    (*t_rez)();        /* change screen resolution    */
  608. X#if    COLOR
  609. X    int    (*t_setfor)();        /* set forground color        */
  610. X    int    (*t_setback)();        /* set background color        */
  611. X#endif
  612. X}       TERM;
  613. X
  614. X/*    TEMPORARY macros for terminal I/O  (to be placed in a machine
  615. X                        dependant place later)    */
  616. X
  617. X#define    TTopen        (*term.t_open)
  618. X#define    TTclose        (*term.t_close)
  619. X#define    TTkopen        (*term.t_kopen)
  620. X#define    TTkclose    (*term.t_kclose)
  621. X#define    TTgetc        (*term.t_getchar)
  622. X#define    TTputc        (*term.t_putchar)
  623. X#define    TTflush        (*term.t_flush)
  624. X#define    TTmove        (*term.t_move)
  625. X#define    TTeeol        (*term.t_eeol)
  626. X#define    TTeeop        (*term.t_eeop)
  627. X#define    TTbeep        (*term.t_beep)
  628. X#define    TTrev        (*term.t_rev)
  629. X#define    TTrez        (*term.t_rez)
  630. X#if    COLOR
  631. X#define    TTforg        (*term.t_setfor)
  632. X#define    TTbacg        (*term.t_setback)
  633. X#endif
  634. X
  635. X/*    structure for the table of initial key bindings        */
  636. X
  637. Xtypedef struct  {
  638. X        short   k_code;                 /* Key code                     */
  639. X        int     (*k_fp)();              /* Routine to handle it         */
  640. X}       KEYTAB;
  641. X
  642. X/*    structure for the name binding table        */
  643. X
  644. Xtypedef struct {
  645. X    char *n_name;        /* name of function key */
  646. X    int (*n_func)();    /* function name is bound to */
  647. X}    NBIND;
  648. X
  649. X/*    The editor holds deleted text chunks in the KILL buffer. The
  650. X    kill buffer is logically a stream of ascii characters, however
  651. X    due to its unpredicatable size, it gets implemented as a linked
  652. X    list of chunks. (The d_ prefix is for "deleted" text, as k_
  653. X    was taken up by the keycode structure)
  654. X*/
  655. X
  656. Xtypedef    struct KILL {
  657. X    struct KILL *d_next;    /* link to next chunk, NULL if last */
  658. X    char d_chunk[KBLOCK];    /* deleted text */
  659. X} KILL;
  660. X
  661. X/*    When emacs' command interpetor needs to get a variable's name,
  662. X    rather than it's value, it is passed back as a VDESC variable
  663. X    description structure. The v_num field is a index into the
  664. X    appropriate variable table.
  665. X*/
  666. X
  667. Xtypedef struct VDESC {
  668. X    int v_type;    /* type of variable */
  669. X    int v_num;    /* ordinal pointer to variable in list */
  670. X} VDESC;
  671. X
  672. X/*    The !WHILE directive in the execution language needs to
  673. X    stack references to pending whiles. These are stored linked
  674. X    to each currently open procedure via a linked list of
  675. X    the following structure
  676. X*/
  677. X
  678. Xtypedef struct WHBLOCK {
  679. X    LINE *w_begin;        /* ptr to !while statement */
  680. X    LINE *w_end;        /* ptr to the !endwhile statement*/
  681. X    int w_type;        /* block type */
  682. X    struct WHBLOCK *w_next;    /* next while */
  683. X} WHBLOCK;
  684. X
  685. X#define    BTWHILE        1
  686. X#define    BTBREAK        2
  687. X
  688. X/*
  689. X * Incremental search defines.
  690. X */
  691. X#if    ISRCH
  692. X
  693. X#define    CMDBUFLEN    256    /* Length of our command buffer */
  694. X
  695. X#define    IS_ABORT    0x07    /* Abort the isearch */
  696. X#define IS_BACKSP    0x08    /* Delete previous char */
  697. X#define    IS_TAB        0x09    /* Tab character (allowed search char) */
  698. X#define IS_NEWLINE    0x0D    /* New line from keyboard (Carriage return) */
  699. X#define    IS_QUOTE    0x11    /* Quote next character */
  700. X#define IS_REVERSE    0x12    /* Search backward */
  701. X#define    IS_FORWARD    0x13    /* Search forward */
  702. X#define    IS_VMSQUOTE    0x16    /* VMS quote character */
  703. X#define    IS_VMSFORW    0x18    /* Search forward for VMS */
  704. X#define    IS_QUIT        0x1B    /* Exit the search */
  705. X#define    IS_RUBOUT    0x7F    /* Delete previous character */
  706. X
  707. X/* IS_QUIT is no longer used, the variable metac is used instead */
  708. X
  709. X#endif
  710. X
  711. X#if    MAGIC
  712. X/*
  713. X * Defines for the metacharacters in the regular expression
  714. X * search routines.
  715. X */
  716. X#define    MCNIL        0    /* Like the '\0' for strings.*/
  717. X#define    LITCHAR        1    /* Literal character, or string.*/
  718. X#define    ANY        2
  719. X#define    CCL        3
  720. X#define    NCCL        4
  721. X#define    BOL        5
  722. X#define    EOL        6
  723. X#define    DITTO        7
  724. X#define    CLOSURE        256    /* An or-able value.*/
  725. X#define    MASKCL        CLOSURE - 1
  726. X
  727. X#define    MC_ANY        '.'    /* 'Any' character (except newline).*/
  728. X#define    MC_CCL        '['    /* Character class.*/
  729. X#define    MC_NCCL        '^'    /* Negate character class.*/
  730. X#define    MC_RCCL        '-'    /* Range in character class.*/
  731. X#define    MC_ECCL        ']'    /* End of character class.*/
  732. X#define    MC_BOL        '^'    /* Beginning of line.*/
  733. X#define    MC_EOL        '$'    /* End of line.*/
  734. X#define    MC_CLOSURE    '*'    /* Closure - does not extend past newline.*/
  735. X#define    MC_DITTO    '&'    /* Use matched string in replacement.*/
  736. X#define    MC_ESC        '\\'    /* Escape - suppress meta-meaning.*/
  737. X
  738. X#define    BIT(n)        (1 << (n))    /* An integer with one bit set.*/
  739. X#define    CHCASE(c)    ((c) ^ DIFCASE)    /* Toggle the case of a letter.*/
  740. X
  741. X/* HICHAR - 1 is the largest character we will deal with.
  742. X * HIBYTE represents the number of bytes in the bitmap.
  743. X */
  744. X#define    HICHAR        256
  745. X#define    HIBYTE        HICHAR >> 3
  746. X
  747. X/* Typedefs that define the bitmap type for searching (BITMAP),
  748. X * the meta-character structure for MAGIC mode searching (MC),
  749. X * and the meta-character structure for MAGIC mode replacment (RMC).
  750. X */
  751. Xtypedef char    *BITMAP;
  752. X
  753. Xtypedef    struct {
  754. X    short int    mc_type;
  755. X    union {
  756. X        int    lchar;
  757. X        BITMAP    cclmap;
  758. X    } u;
  759. X} MC;
  760. X
  761. Xtypedef    struct {
  762. X    short int    mc_type;
  763. X    char    *rstr;
  764. X} RMC;
  765. X#endif
  766. X
  767. FRIDAY_NIGHT
  768. echo extracting - evar.h
  769. sed 's/^X//' > evar.h << 'FRIDAY_NIGHT'
  770. X/*    EVAR.H:    Environment and user variable definitions
  771. X        for MicroEMACS
  772. X
  773. X        written 1986 by Daniel Lawrence
  774. X*/
  775. X
  776. X/*    structure to hold user variables and their definitions    */
  777. X
  778. Xtypedef struct UVAR {
  779. X    char u_name[NVSIZE + 1];        /* name of user variable */
  780. X    char *u_value;                /* value (string) */
  781. X} UVAR;
  782. X
  783. X/*    current user variables (This structure will probably change)    */
  784. X
  785. X#define    MAXVARS        255
  786. X
  787. XUVAR uv[MAXVARS + 1];    /* user variables */
  788. X
  789. X/*    list of recognized environment variables    */
  790. X
  791. Xchar *envars[] = {
  792. X    "fillcol",        /* current fill column */
  793. X    "pagelen",        /* number of lines used by editor */
  794. X    "curcol",        /* current column pos of cursor */
  795. X    "curline",        /* current line in file */
  796. X    "ram",            /* ram in use by malloc */
  797. X    "flicker",        /* flicker supression */
  798. X    "curwidth",        /* current screen width */
  799. X    "cbufname",        /* current buffer name */
  800. X    "cfname",        /* current file name */
  801. X    "sres",            /* current screen resolution */
  802. X    "debug",        /* macro debugging */
  803. X    "status",        /* returns the status of the last command */
  804. X    "palette",        /* current palette string */
  805. X    "asave",        /* # of chars between auto-saves */
  806. X    "acount",        /* # of chars until next auto-save */
  807. X    "lastkey",        /* last keyboard char struck */
  808. X    "curchar",        /* current character under the cursor */
  809. X    "discmd",        /* display commands on command line */
  810. X    "version",        /* current version number */
  811. X    "progname",        /* returns current prog name - "MicroEMACS" */
  812. X    "seed",            /* current random number seed */
  813. X    "disinp",        /* display command line input characters */
  814. X    "wline",        /* # of lines in current window */
  815. X    "cwline",        /* current screen line in window */
  816. X    "target",        /* target for line moves */
  817. X    "search",        /* search pattern */
  818. X    "replace",        /* replacement pattern */
  819. X    "match",        /* last matched magic pattern */
  820. X    "kill",            /* kill buffer (read only) */
  821. X    "cmode",        /* mode of current buffer */
  822. X    "gmode",        /* global modes */
  823. X    "tpause",        /* length to pause for paren matching */
  824. X    "pending",        /* type ahead pending flag */
  825. X    "lwidth",        /* width of current line */
  826. X    "line",            /* text of current line */
  827. X    "gflags",        /* global internal emacs flags */
  828. X    "rval",            /* child process return value */
  829. X};
  830. X
  831. X#define    NEVARS    sizeof(envars) / sizeof(char *)
  832. X
  833. X/*     and its preprocesor definitions        */
  834. X
  835. X#define    EVFILLCOL    0
  836. X#define    EVPAGELEN    1
  837. X#define    EVCURCOL    2
  838. X#define    EVCURLINE    3
  839. X#define    EVRAM        4
  840. X#define    EVFLICKER    5
  841. X#define    EVCURWIDTH    6
  842. X#define    EVCBUFNAME    7
  843. X#define    EVCFNAME    8
  844. X#define    EVSRES        9
  845. X#define    EVDEBUG        10
  846. X#define    EVSTATUS    11
  847. X#define    EVPALETTE    12
  848. X#define    EVASAVE        13
  849. X#define    EVACOUNT    14
  850. X#define    EVLASTKEY    15
  851. X#define    EVCURCHAR    16
  852. X#define    EVDISCMD    17
  853. X#define    EVVERSION    18
  854. X#define    EVPROGNAME    19
  855. X#define    EVSEED        20
  856. X#define    EVDISINP    21
  857. X#define    EVWLINE        22
  858. X#define EVCWLINE    23
  859. X#define    EVTARGET    24
  860. X#define    EVSEARCH    25
  861. X#define    EVREPLACE    26
  862. X#define    EVMATCH        27
  863. X#define    EVKILL        28
  864. X#define    EVCMODE        29
  865. X#define    EVGMODE        30
  866. X#define    EVTPAUSE    31
  867. X#define    EVPENDING    32
  868. X#define    EVLWIDTH    33
  869. X#define    EVLINE        34
  870. X#define    EVGFLAGS    35
  871. X#define    EVRVAL        36
  872. X
  873. X/*    list of recognized user functions    */
  874. X
  875. Xtypedef struct UFUNC {
  876. X    char *f_name;    /* name of function */
  877. X    int f_type;    /* 1 = monamic, 2 = dynamic */
  878. X} UFUNC;
  879. X
  880. X#define    NILNAMIC    0
  881. X#define    MONAMIC        1
  882. X#define    DYNAMIC        2
  883. X#define    TRINAMIC    3
  884. X
  885. XUFUNC funcs[] = {
  886. X    "add", DYNAMIC,        /* add two numbers together */
  887. X    "sub", DYNAMIC,        /* subtraction */
  888. X    "tim", DYNAMIC,        /* multiplication */
  889. X    "div", DYNAMIC,        /* division */
  890. X    "mod", DYNAMIC,        /* mod */
  891. X    "neg", MONAMIC,        /* negate */
  892. X    "cat", DYNAMIC,        /* concatinate string */
  893. X    "lef", DYNAMIC,        /* left string(string, len) */
  894. X    "rig", DYNAMIC,        /* right string(string, pos) */
  895. X    "mid", TRINAMIC,    /* mid string(string, pos, len) */
  896. X    "not", MONAMIC,        /* logical not */
  897. X    "equ", DYNAMIC,        /* logical equality check */
  898. X    "les", DYNAMIC,        /* logical less than */
  899. X    "gre", DYNAMIC,        /* logical greater than */
  900. X    "seq", DYNAMIC,        /* string logical equality check */
  901. X    "sle", DYNAMIC,        /* string logical less than */
  902. X    "sgr", DYNAMIC,        /* string logical greater than */
  903. X    "ind", MONAMIC,        /* evaluate indirect value */
  904. X    "and", DYNAMIC,        /* logical and */
  905. X    "or",  DYNAMIC,        /* logical or */
  906. X    "len", MONAMIC,        /* string length */
  907. X    "upp", MONAMIC,        /* uppercase string */
  908. X    "low", MONAMIC,        /* lower case string */
  909. X    "tru", MONAMIC,        /* Truth of the universe logical test */
  910. X    "asc", MONAMIC,        /* char to integer conversion */
  911. X    "chr", MONAMIC,        /* integer to char conversion */
  912. X    "gtk", NILNAMIC,    /* get 1 charater */
  913. X    "rnd", MONAMIC,        /* get a random number */
  914. X    "abs", MONAMIC,        /* absolute value of a number */
  915. X    "sin", DYNAMIC,        /* find the index of one string in another */
  916. X    "env", MONAMIC,        /* retrieve a system environment var */
  917. X    "bin", MONAMIC,        /* loopup what function name is bound to a key */
  918. X    "exi", MONAMIC,        /* check if a file exists */
  919. X    "fin", MONAMIC,        /* look for a file on the path... */
  920. X     "ban", DYNAMIC,        /* bitwise and   9-10-87  jwm */
  921. X     "bor", DYNAMIC,        /* bitwise or    9-10-87  jwm */
  922. X     "bxo", DYNAMIC,        /* bitwise xor     9-10-87  jwm */
  923. X    "bno", MONAMIC,        /* bitwise not */
  924. X    "xla", TRINAMIC,    /* XLATE character string translation */
  925. X};
  926. X
  927. X#define    NFUNCS    sizeof(funcs) / sizeof(UFUNC)
  928. X
  929. X/*     and its preprocesor definitions        */
  930. X
  931. X#define    UFADD        0
  932. X#define    UFSUB        1
  933. X#define    UFTIMES        2
  934. X#define    UFDIV        3
  935. X#define    UFMOD        4
  936. X#define    UFNEG        5
  937. X#define    UFCAT        6
  938. X#define    UFLEFT        7
  939. X#define    UFRIGHT        8
  940. X#define    UFMID        9
  941. X#define    UFNOT        10
  942. X#define    UFEQUAL        11
  943. X#define    UFLESS        12
  944. X#define    UFGREATER    13
  945. X#define    UFSEQUAL    14
  946. X#define    UFSLESS        15
  947. X#define    UFSGREAT    16
  948. X#define    UFIND        17
  949. X#define    UFAND        18
  950. X#define    UFOR        19
  951. X#define    UFLENGTH    20
  952. X#define    UFUPPER        21
  953. X#define    UFLOWER        22
  954. X#define    UFTRUTH        23
  955. X#define    UFASCII        24
  956. X#define    UFCHR        25
  957. X#define    UFGTKEY        26
  958. X#define    UFRND        27
  959. X#define    UFABS        28
  960. X#define    UFSINDEX    29
  961. X#define    UFENV        30
  962. X#define    UFBIND        31
  963. X#define    UFEXIST        32
  964. X#define    UFFIND        33
  965. X#define UFBAND        34
  966. X#define UFBOR        35
  967. X#define UFBXOR        36
  968. X#define    UFBNOT        37
  969. X#define    UFXLATE        38
  970. FRIDAY_NIGHT
  971. echo mes.16 completed!
  972. # That's all folks!
  973.  
  974.  
  975.