home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 331_01 / ged.h < prev    next >
Text File  |  1990-06-15  |  16KB  |  378 lines

  1. /*
  2. HEADER:         CUG000.01;
  3. TITLE:          header file for se.c;
  4. DATE:           5/19/87;
  5. FILENAME:       GED.H;
  6. AUTHORS:        G. Nigel Gilbert, James W. Haefner, Mel Tearle G. Osborn;
  7. */
  8.  
  9. /*
  10.      e/qed/ged screen editor
  11.  
  12.     (C) G. Nigel Gilbert, MICROLOGY, 1981
  13.            licensed for private non-profitmaking use 1983
  14.            August-December 1981
  15.  
  16.     Modified: Aug-Dec   1984:  BDS-C 'e'(vers 4.6a) to 'qe' (J.W. Haefner)
  17.               March     1985:  BDS-C 'qe' to DeSmet-C 'qed' (J.W.Haefner)
  18.               May       1986:  converted to ged - Mel Tearle
  19.               June      1990:  G. Osborn
  20.     FILE:     ged.h
  21.  
  22.     PURPOSE:  standard header file, #included in all function files
  23. */
  24.  
  25. /*
  26.  * All static variables and #defines were at one time in this file.
  27.  * Variables which are not truely global in function are being removed
  28.  * from here and placed in the individual files.  Parameters which, though
  29.  * sometimes local, are useful for configuring the program without studying
  30.  * the details remain here.     g.o.
  31.  */
  32.  
  33.  
  34. #define max(a,b) (a >= b) ? a : b
  35. #define min(a,b) (a <= b) ? a : b
  36. #define abs(x)   (x >= 0) ? x : -x
  37.  
  38. #define VERSION   "4.6b"
  39.  
  40. /* Microsoft 4.00 mixed memory model */
  41. #define FAR far
  42. #define HUGE huge
  43. /* use the following two lines instead of the preceeding two if the compiler
  44.  * does not support mixed memory models.  The empty definitions
  45.  * remove all occurences of the far and huge keyword, causing
  46.  * the small memory model to be used.
  47.  */
  48. /*
  49.  *#define FAR
  50.  *#define HUGE
  51.  */
  52.  
  53.  
  54.  
  55. #define SECSIZ      512      /* file buffer definitions */
  56. #define NSECTS        4
  57. #define FILELEN      64      /* max length of file name */
  58.  
  59. #define JBUFSIZE   6     /* size of buffer required for longjumps, not used */
  60. #define BUFFER    12     /* size of typeahead buffer */
  61. #define FLIM      80     /*  */
  62. #define LLIM     255     /* max length of a line. count includes null marker */
  63.  
  64. #define FAIL      -1
  65. /* disc fail.  This value is internal and compiler independent */
  66. #define DFAIL     -2
  67. #define ENDCHAR    0x1a    /* end of text file mark. automatic option on input */
  68. #define ENDFILE    -1      /* end of input file */
  69. #define YES        1
  70. #define NO         0
  71. #define FALSE      0
  72. #define TRUE       1
  73. #define PREV      -2
  74.  
  75. #define PAGEOVERLAP   0    /* overlap between pages with UP,DOWN-PAGE */
  76. #define OFFWIDTH      1    /* horizontal scroll increment */
  77.  
  78. #define SHEIGHT      24    /* screen height */
  79. #define SWIDTH       79    /* screen width */
  80.  
  81. #define NLINES        6    /* number of lines to skip at bottom of printer page */
  82. #define PAGELEN      66    /* length of printer page, used in listfile() & roff() */
  83.  
  84. #define EMPOS         0    /* position of error message */
  85. #define WAITPOS       0    /* position of cursor when searching/reading */
  86. #define LNPOS         7    /* position of line number */
  87. #define COLPOS       18    /* position of column number */
  88. #define REPPOS       19
  89. #define FNPOS        43    /* status line - position of file name */
  90. #define TIMEPOS      72    /* position of current time */
  91.  
  92. #define BACKSP     0x08    /* backspace */
  93. #define CTRL       0x1f    /* last control char */
  94. #define PARBIT     0x80    /* parity bit used as a flag by testkey() */
  95. #define NKEYS        32    /* number of key codes */
  96.  
  97. #define HISTLEN     100    /* history stack of commands for undoing */
  98. #define HISTINSERT    1    /* type of command on history stack */
  99. #define HISTDELETE    2
  100. #define HISTREPLACE   3
  101.  
  102. /* Internal key codes - recommended key assignments in brackets
  103.  */
  104. #define LEADIN     0     /* lead in chararacter to key codes -
  105. ignored, but following key code parity set */
  106. #define DOWNKEY    1     /* cursor down */
  107. #define UPKEY      2     /* cursor up */
  108. #define LEFTKEY    3     /* cursor left */
  109. #define RIGHTKEY   4     /* cursor right */
  110. #define RIGHTWKEY  5     /* cursor right one word (D) */
  111. #define LEFTWKEY   6     /* cursor left one word (S) */
  112. #define EOLKEY     7     /* cursor to end of line (E) */
  113. #define BOLKEY     8     /* cursor to beginning of line (B) */
  114. #define UPPAGE     9     /* scroll up a page (W) */
  115. #define DOWNPAGE  10     /* scroll down a page (Z) */
  116. #define BOFKEY    11     /* cursor to beginning of file (U) */
  117. #define HOMEKEY   12     /* cursor to end of file (HOME) */
  118. #define DELLEFT   13     /* delete char to left of cursor (DEL) */
  119. #define DELRIGHT  14     /* delete char under cursor (G) */
  120. #define DELLNKEY  15     /* delete cursor line (Y) */
  121. #define DELWDKEY  16     /* delete word to right of cursor (T) */
  122. #define JUMPKEY   17     /* jump to (X) */
  123. #define CRSTILL   18     /* insert newline after cursor (N) */
  124. #define QWIKKEY   19     /* quit (Q) */
  125. #define WINDUP    20     /* window up one line */
  126. #define TOPSCRKEY 1000   /*not fully implemented  */
  127. #define BOTSCRKEY 1001   /*  */
  128. #define POP       21
  129. #define CPOP      22
  130. #define BLOCKKEY  23     /* block operations (K) */
  131. #define WINDDOWN  24     /* window down one line */
  132. #define REPKEY    25     /* repeat last find/alter (L) */
  133. #define INSKEY    26     /* char insert/replace */
  134. #define OOPSKEY   27     /* restore unedited line (_) */
  135. #define TAB       28     /* tab (I) */
  136. #define RETRIEVE  29     /* retrieve last name etc entered here */
  137. #define CR        30     /* return (M) */
  138. #define ESCKEY    31     /* the magic escape key (ESC) */
  139. #define HELPKEY   1002   /* not implemented.  The F1 help key is implemeted. */
  140.  
  141. /* key codes + 0x80 (PARBIT) - used in scanning strings of ctrl chars */
  142. #define LEFTKEY_P   131
  143. #define DELLEFT_P   141
  144. #define RETRIEVE_P  157
  145. #define CR_P        158
  146. #define ESCKEY_P    159
  147.  
  148. /* function keys */
  149. #define F1KEY     210
  150. #define F2KEY     211  /* f2 = search */
  151. #define F3KEY     212  /* f3=backward */
  152. #define F4KEY     213  /* f4=forward  */
  153. #define F5KEY     214
  154. #define F6KEY     215
  155. #define F7KEY     216
  156. #define F8KEY     217
  157. #define F9KEY     218   /* f9 exit */
  158. #define F10KEY    219   /* f10 save */
  159.  
  160. /*
  161.  * The video parameters in this file were originally set for a Hercules
  162.  * video card, then changed for a VGA card with a NEC grey scale monitor.
  163.  * The UNDERLINE attribute was used for the status line on the Hercules
  164.  * card, but is not supported by the VGA card.  The values selected in
  165.  * this version will work on all systems, but are not the best choices
  166.  * for any one system.  The first four bits and the second four bits of
  167.  * the attribute byte are independently selected.  Experiment with them.
  168.  */
  169.  
  170. /*
  171.  * normal screen color/intensity.  selected by a call to colornorm()
  172.  */
  173. #define ATTR0  0x07    /* PC default.  White on black.*/
  174.  
  175. /* a screen attribute used like highlighting or italics.
  176.  * The significance to the program is that it is abnormal, not whether it
  177.  * is bright or dim.  On the PC it is brighter than normal.
  178.  * Selected by a call to color1();
  179.  */
  180. #define ATTR1 0x0F    /* bright white on black */
  181.  
  182. /* Reverse field.  Used for marking blocks and for error messages.  Affects
  183.  * whitespace so that the spaces within block boundaries can be seen.
  184.  * Selected by a call to colorblock().  Also selected by colorerr(); in
  185.  * this version.  (0x70 and 0x78 are the only codes which will reverse
  186.  * field a PC monochrome display, excluding colored error messages if
  187.  * compatibility is a consideration).
  188.  */
  189. #define ATTR2 0x70   /* reverse field, normal intensity */
  190.  
  191. /* Was used only to underline the header to seperate it from the
  192.  * text.  Could also be used for conventional underlining of text.
  193.  */
  194. /* #define ATTR3 0x01 */    /* normal intensity, underlined (Hercules & other early cards) */
  195. /* vga, temporary +++ */
  196. #define ATTR3 0x70
  197.  
  198. /*#define ATTR4 0x09 */    /* bright and underlined (Hercules) */
  199. /* vga grey scale for header, temporary +++ */
  200. #define ATTR4 0x60
  201.  
  202. /* Virtual memory constants.  The following are sized with a fixed
  203.  * disc system and 640kb of RAM in mind.  There is a small memory savings in
  204.  * reducing the magnitude of the constants for smaller systems,
  205.  * but, other than for optimizaton, it is not necessary to adjust the
  206.  * values to match the resources.  The maximum document size in bytes
  207.  * is PAGESIZE*MAXSLOTS, with a 16384 line limit.
  208.  */
  209.  
  210. /* PAGESIZE should be a multiple of the disc sector size for efficiency.
  211.  * It is helpful also if it holds more than a screenful of text.
  212.  * The size must be evenly divisible into 64 k in this version.
  213.  */
  214. #define PAGESIZE    0x800
  215.  
  216. /* Max allowable number of pagess in RAM.  The actual amount
  217.  * of available RAM is determined by halloc(), and need not be
  218.  * specified here.  If the document is too big to be held in RAM then
  219.  * a temporary disc file is used.  Unmodified RAM pages usually have
  220.  * a corresponding disc image, requiring a disc area large enough for
  221.  * the entire document.
  222.  */
  223. #define RAMSLOTS   250
  224.  
  225. #define MAXSLOTS   1500
  226.  
  227.  
  228.  
  229. /* --- */
  230.  
  231. #define MAXINT     0x7FFF   /* largest possible positive integer */
  232. #define NOFILE   (MAXINT)
  233.  
  234.  
  235. /* the structure of the file buffers */
  236. struct iobuffer  {
  237.     int   fdes;
  238.     int   nleft;
  239.     unsigned char  *nextp;
  240.     unsigned char  buff[NSECTS * SECSIZ];
  241. } fbuf1, tbuf1;
  242.  
  243. struct iobuffer *fbuf;
  244. struct iobuffer *textbuf;
  245.  
  246. /* The pointer to the tp array must be type huge (not far) in the large
  247.  * memory model allocation or the pointer arithmetic is wrong.  This
  248.  * requirement is not the same as the problem of strings crossing 64 k
  249.  * boundaries.  In being unspecified, the Microsoft 4.0 compiler assumes
  250.  * that the array size exceeds 128 k, resulting in the restriction that the
  251.  * element size be a power of 2.  There are 12 unused bits in each
  252.  * element if expansion is needed.
  253.  */
  254. struct addr  {
  255.     int page;     /* virtual memory page number containing line of text */
  256.     int moffset;  /* line offset into page containing text */
  257. } HUGE *tp;
  258.  
  259.  
  260. /* command history stack for undo()
  261.  */
  262. struct histstep  {
  263.     struct addr histp;    /* address of text modified by command */
  264.     int histline;         /* line number of modified text */
  265.     int histtype;         /* type of command (insert,delete,replace) */
  266.     int histcomm;         /* number of command modulo 256 */
  267. }
  268. history[HISTLEN];
  269.  
  270. int histptr;            /* index into history stack */
  271. int histcnt;            /* number of commands on stack */
  272. int storehist;          /* commands only stored on history when true */
  273. unsigned ncommand;      /* count of commands executed since startup */
  274. int stkptr;             /* text stack pointer */
  275. int stkcnt;             /* no. items in stack.  (preliminary.  see pop() ) */
  276.  
  277. int fullmem;  /* max no. of kb of RAM which will be allocated. -Mnnn option */
  278. int allocp;             /* location of next free in newpage */
  279. int attr;               /* attribute for norm() and high() */
  280. int clock;              /* counter for least recently used paging */
  281. int charep;             /* zero if char replace mode, 1 if overlay mode */
  282. int eofchar;               /* write ENDCHAR on output if !eofchar */
  283. int charmask;              /* mask for zeroing bit zero of file input */
  284. int newpage;                 /* page no of page being filled with text */
  285. int pagefd;                  /* file descriptor of paging file */
  286.  
  287. int slotsinmem;              /* actual no. of slots in memory */
  288. int tpslots;                 /* no. of RAM pages in use for line vectors */
  289. int virtslot[MAXSLOTS];      /* current location of each page, RAM or disc index */
  290. int usage[RAMSLOTS];         /* records usage of ram slots */
  291. int auxloc[RAMSLOTS];        /* disc slot no. corresponding to mem slot */
  292. char dskslots[MAXSLOTS];     /* disk slot use/free flag */
  293.  
  294. char pagingfile[FILELEN];     /* name of paging file */
  295.  
  296. /* the slotaddr array must be type huge (not far) in the large
  297.  * memory model allocation or the pointer arithmetic is wrong with FAR
  298.  * arithmetic.  This requirement is unrelated to the problem of strings
  299.  * crossing 64 k boundaries.
  300.  */
  301. char HUGE *slotaddr[RAMSLOTS];  /* memory addr of start of each in-memory slot */
  302.  
  303. char altered;              /* if YES, current line has been altered by edits */
  304. char blankedmess;          /* message area has been blanked, not overwritten */
  305. int  displine;             /* last displayed line number */
  306. int  dispcol;              /* last displayed column number */
  307. char dskerr[JBUFSIZE];     /* for bdos disk error traps, unused */
  308.  
  309. char goteof;               /* true when eof found */
  310. unsigned char inbuf[BUFFER]; /* input buffer for typeahead */
  311. char isdim;                /* last char was in dim */
  312.  
  313. char mainmenu[JBUFSIZE];   /* for emergency longjump, unused */
  314. char text[LLIM];           /* buffer for current line of text */
  315. unsigned char tran[NKEYS]; /* translation table from external to internal
  316.                               key codes */
  317.  
  318. int  charn;                /* position of current char in current line */
  319. int  cline;                /* current line */
  320. int  curdsk;               /* currently logged in (default) disk */
  321. int  cursorx, cursory;     /* current position of cursor */
  322.  
  323. int  goodline;          /* line number we know we can display */
  324. int  inbufp;            /* pointer to next char in inbuf */
  325.  
  326. int  lastl;             /* number of last line of text */
  327. int  lastoff;           /* offset the last time resetcursor() was called */
  328. int  lastc;             /* last line number changed, for jump cmd */
  329. int  linem1;            /* marked line numbers for line jump */
  330. int  linem2;
  331. int  linem3;
  332.  
  333. int  offset;            /* first col. to display on screen */
  334. int  pfirst, plast;     /* top and bottom line displayed on screen */
  335. int  topline;           /* first line on screen for text */
  336.  
  337. /* --------------->>  environment options  <<--------------- */
  338.  
  339. char autoin;            /* do auto indentation */
  340. char backup;            /* at end, old version becomes file.bak */
  341. char blockscroll;       /* horizontal scroll whole page */
  342.  
  343. char displaypos;        /* display line:col at top of screen */
  344. int tabwidth;           /* width between tabstops */
  345. char trail;             /* don't chop trailing blanks from text lines */
  346. char ctrl;              /* Control characters allowed if true */
  347. char ans[6];            /* line to jump to */
  348. char blocking;          /* true if block is or has been defined */
  349. char defext[5];         /* default file extension, saved from last file. */
  350.                         /*     ".xxx\0" */
  351.                         /* hardcoded defaults .c and .doc in this version */
  352.  
  353. char filename[FILELEN]; /* current file being edited */
  354. char justfile[15];      /* filename w/o path */
  355.  
  356. char name[FILELEN];     /* filename for read and write files */
  357. char nocheck;           /* don't ask for confirmation before replacing */
  358. char opts[5];           /* options for alter */
  359. char patt[FLIM];        /* test string */
  360. char repeat;            /* repeat last find/replace */
  361. char replace;           /* last find/replace was a replace */
  362.  
  363. int  findir;            /* direction of last find */
  364. int  vbord1,vbord2;     /* block start and end */
  365. int  jmpto, initjmp;    /* initial line to jump */
  366.  
  367.  
  368. char  *getline(), *strcpy();
  369. unsigned char   getlow();
  370. unsigned char testlow();
  371.  
  372. /* registers for syscall() in term.c */
  373. unsigned int  rax, rbx, rcx, rdx, rsi, rdi, res, rds;
  374. unsigned char  carryf, zerof;
  375.  
  376.  
  377. /* end of standard header */
  378.