home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 133_01 / e.h < prev    next >
Text File  |  1985-03-10  |  10KB  |  278 lines

  1. /*
  2.     e screen editor
  3.  
  4.     (C) G. Nigel Gilbert, MICROLOGY, 1981
  5.     licensed for private non-profitmaking use 1983
  6.  
  7.     August-December 1981
  8.  
  9.     FILE: e.h
  10.  
  11.     PURPOSE: standard header file, #included in all function files
  12.         (NB e does NOT require "bdscio.h")
  13.  
  14. */
  15.  
  16. #define VERSION "4.8a"
  17.  
  18. /*
  19.   compile with -e7e00 (e10 with -o as well)
  20.   load      with -t 9500    using l2    (see TOP below)
  21. */
  22.  
  23. #define TOP 0x9500    /*top of program- MUST BE EQUAL TO the -t arg to l2 */
  24. #define CCP 0x0800    /*length of CP/M's CCP */
  25.  
  26. #define CURSORWAIT 1000    /*set this according to the speed of your
  27.             microprocessor clock
  28.                 - for a Z80A set to 1000
  29.                 - for an 8080 set to 500
  30.                 - for a Z80B set to 1500
  31.             Note that an incorrect setting of this constant
  32.             does NOT create errors - just makes the cursor
  33.             flash too fast/slow    */
  34.  
  35. #define SECSIZ 128    /*file buffer definitions*/
  36. #define NSECTS 16
  37. #define IOBUFSIZ (NSECTS * SECSIZ + 6 )
  38. #define FILELEN 18    /*max length of file name (UU/D:FFFFFFFF.xxx\0)*/
  39. #define INBUFLEN 20    /*length of type-in buffer */
  40.  
  41. #define JBUFSIZE 6    /*size of buffer required for longjumps*/
  42.  
  43. #define LLIM 255    /*max length of a line*/
  44. #define FLIM 80        /*max length of find/alter string*/
  45.  
  46. #define FAIL -1
  47. #define NULL 0
  48. #define YES 1
  49. #define NO 0
  50. #define PREV -2
  51.  
  52. #define HISTLEN 40    /*history stack of commands for undoing */
  53. #define HISTINSERT 1    /*type of command on history stack */
  54. #define HISTDELETE 2
  55. #define HISTREPLACE 3
  56.  
  57. #define SWIDTH 79    /*screen size*/
  58. #define SHEIGHT 23
  59. #define OFFWIDTH 20    /*horizontal scroll increment*/
  60. #define PAGEOVERLAP 4    /*overlap between pages with UP,DOWN-PAGE*/
  61. #define HELPLINES 8    /*top line number when help menu is on display */
  62.  
  63. #define FNPOS 8        /*status line - position of file name*/
  64. #define LNPOS 23    /*        position of line number*/
  65. #define EMPOS 32    /*        position of error message*/
  66. #define WAITPOS 32    /*        position of cursor when searching/reading*/
  67. #define REPPOS 50    /*        position of "Replace?" message*/
  68.  
  69. #define BACKSP 0x08    /*backspace*/
  70. #define ENDFILE 0x1a    /*CP/M end of text file mark */
  71. #define CTRL 0x1f    /*last control char.*/
  72. #define PARBIT 0x80    /*parity bit used as a flag by testkey() */
  73. #define NOPARITY 0x7f    /*mask to strip parity bit */
  74. #define NKEYS 32    /*number of key codes*/
  75. #define GOTOLEN 6    /*approx number of chars in control code string for
  76.                 cursor addressing*/
  77.  
  78.     /*internal key codes (recommended key assignments in brackets)*/
  79.  
  80. #define LEADIN 0    /*lead in chararacter to key codes -
  81.                 ignored, but following key code parity set*/
  82. #define DOWNKEY 1    /*cursor down */
  83. #define UPKEY    2    /*cursor up*/
  84. #define LEFTKEY 3    /*cursor left*/
  85. #define RIGHTKEY 4    /*cursor right*/
  86. #define RIGHTWKEY 5    /*cursor right one word (D) */
  87. #define LEFTWKEY 6    /*cursor left one word (S) */
  88. #define EOLKEY 7    /*cursor to end of line (E) */
  89. #define BOLKEY 8    /*cursor to beginning of line (B) */
  90. #define UPPAGE 9    /*scroll up a page (W) */
  91. #define DOWNPAGE 10    /*scroll down a page (Z) */
  92. #define BOFKEY 11    /*cursor to beginning of file (U) */
  93. #define HOMEKEY 12    /*cursor to end of file (HOME) */
  94. #define DELLEFT 13    /*delete char to left of cursor (DEL) */
  95. #define DELRIGHT 14    /*delete char under cursor (G) */
  96. #define DELLNKEY 15    /*delete cursor line (Y) */
  97. #define DELWDKEY 16    /*delete word to right of cursor (T) */
  98. #define JUMPKEY 17    /*jump to (X) */
  99. #define CRSTILL 18    /*insert newline after cursor (N) */
  100. #define QUITKEY 19    /*quit (Q) */
  101. #define ENVIRKEY 20    /*edit and file context (C) */
  102. #define FINDKEY 21    /*find (F) */
  103. #define ALTERKEY 22    /*alter (A) */
  104. #define BLOCKKEY 23    /*block operations (O) */
  105. #define RDFILEKEY 24    /*read a file (P) */
  106. #define REPKEY 25    /*repeat last find/alter (R) */
  107. #define HELPKEY 26    /*display help menu (V) */
  108. #define UNDOKEY 27    /*undo history of commands (\) */
  109. #define TAB 28        /*tab (I)*/
  110. #define RETRIEVE 29    /*retrieve last name etc entered here (R)*/
  111. #define CR 30        /*return (M)*/
  112. #define ESCKEY 31    /*the magic escape key (ESC)*/
  113.  
  114. #define BRIDIM '|'    /*char placed in e's message strings to start/stop
  115.                 dim (half-intensity) display */
  116. #define DEBUGSCR NO    /*display control chars as numeric literals for
  117.                 testing screen displays*/
  118.  
  119.     /* CP/M bdos function codes */
  120.  
  121. #define RESET 0
  122. #define CONIN 0x01
  123. #define CONOUT 0x02
  124. #define LSTOUT 0x05
  125. #define DIRIO 0x06
  126. #define IOBYTE 0x07
  127. #define SETIOBYTE 0x08
  128. #define PRINTS 0x09
  129. #define READBUF 0x0A
  130. #define CONSTAT 0x0B
  131. #define VERNO 0x0C
  132. #define RESETDSK 0x0D
  133. #define SELDSK 0x0E
  134. #define OPEN 0x0F
  135. #define CLOSEF 0x10
  136. #define SEARCH1 0x11
  137. #define SEARCHN 0x12
  138. #define DELETEF 0x13
  139. #define READ 0x14
  140. #define WRITE 0x15
  141. #define MAKE 0x16
  142. #define RENAME 0x17
  143. #define LOGINV 0x18
  144. #define CURDSK 0x19
  145. #define SETDMA 0x1A
  146. #define PROTECT 0x1C
  147. #define GETROV 0x1d
  148. #define DSKPARAMS 0x1F
  149. #define USERCODE 0x20
  150. #define READR 0x21
  151. #define WRITER 0x22
  152. #define FSIZE 0x23
  153. #define SETRR 0x24
  154. #define RESETDRV 0x25
  155.  
  156. #define CPM3ERRORMODE 45    /*set error mode to return and display
  157.                     (specific to CP/M Plus) */
  158.  
  159. #define MAXSLOTS 128    /*virtual memory constants*/
  160. #define MAXMEMSLOTS 20
  161. #define PAGESIZE 1024
  162. #define PAGESECTS (PAGESIZE/SECSIZ)
  163.  
  164. #define FREE 0
  165. #define INUSE 1
  166. #define NOTAVAIL -1
  167. #define MAXINT 32767
  168. #define NOFILE (MAXINT)
  169. #define ABSOLUTE 0
  170. #define UNKNOWN (MAXINT)
  171.  
  172. #define sint char
  173.  
  174. struct addr {
  175.     sint page;
  176.     int moffset;
  177.     } *tp;            /*address of text of each line*/
  178.     
  179. sint cpm2x;            /*operating system is CP/M 2.x*/
  180. int allocp;            /*location of next free in newpage */
  181. int pageloc[MAXSLOTS];        /*current location of each page*/
  182. int usage[MAXMEMSLOTS];        /*records usage of in memory slots*/
  183. char *slotaddr[MAXMEMSLOTS];    /*memory addr of start of each in memory slot*/
  184. sint dskslots[MAXSLOTS];    /*is disk slot free*/
  185. sint slotsinmem;        /*max no. of slots available in memory*/
  186. sint tppages;            /*no. of pages used to hold text pointers*/
  187. sint newpage;            /*page no of page being filled with text*/
  188. char *npaddr;            /*base of slot holding newpage*/
  189. int clock;            /*counter for least recently used paging*/
  190.  
  191. int pagefd;            /*file descriptor of paging file*/
  192. char pagingfile[FILELEN];    /*name of paging file*/
  193. char pagingdisk;        /*disk to put paging file on*/
  194.  
  195. sint curdsk;            /*currently logged in (default) disk*/
  196.  
  197. unsigned ncommand;        /*count of commands executed since startup*/
  198. char mainmenu[JBUFSIZE];    /*for emergency longjump*/
  199. int goodline;            /*line number we know we can display */
  200. unsigned errold[4];        /*temp store for CP/M's error jump addrs*/
  201. char dskerr[JBUFSIZE];        /*for bdos disk error traps*/
  202.  
  203. char textbuf[IOBUFSIZ];        /*io buffer for file being edited*/
  204.  
  205. struct histstep {        /*command history stack for undoing */
  206.     struct addr histp;    /*address of text modified by command*/
  207.     int histline;        /*line number of modified text*/
  208.     sint histtype;        /*type of command (insert,delete,replace)*/
  209.     sint histcomm;        /*number of command modulo 256 */
  210.     } history[HISTLEN];
  211. int histptr;            /*pointer into history stack*/
  212. sint histcnt;            /*number of commands on stack*/
  213. sint storehist;            /*commands only stored on history when true*/
  214.  
  215. sint cursorx, cursory;        /*current position of cursor*/
  216. char tran[NKEYS];        /*translation table from external to internal
  217.                 key codes*/
  218. sint isdim;            /*last char was in dim*/
  219. int lastl;            /*number of last line of text*/
  220. int lastread;            /*last line actually read to date*/
  221. sint goteof;            /*true when eof of file being edited*/
  222. int cline;            /*current line*/
  223. char text[LLIM];        /*buffer for current line of text*/
  224. int charn;            /*position of current char in current line*/
  225. sint altered;            /*if YES, current line has been altered by edits*/
  226.  
  227. int pfirst, plast;        /*top and bottom line displayed on screen*/
  228. sint topline;            /*first line on screen for text*/
  229. sint offset;            /*first col. to display on screen*/
  230. sint lastoff;            /*offset last time resetcursor() was called*/
  231. sint blankedmess;        /*message area has been blanked, not overwritten*/
  232.  
  233. char inbuf[INBUFLEN];        /*input buffer for typeahead*/
  234. sint  inbufp;            /*pointer to next free in inbuf*/
  235.  
  236.             /*environment options*/
  237.             
  238. sint autoin;            /*do auto indentation*/
  239. sint backup;            /*at end, old version becomes file.bak*/
  240. sint tabwidth;            /*width between tabstops*/
  241. sint trail;            /*don't chop trailing blanks from text lines*/
  242. sint wboot;            /*do a warm boot on exit; else jump to CCP*/
  243. sint displaypos;        /*display line:col at top of screen*/
  244. sint blockscroll;        /*horizontal scroll whole page*/
  245. sint hilight;            /*make current line bright, rest dim*/
  246.  
  247. char filename[FILELEN];        /*current file being edited*/
  248. char *errmess;            /*last error message*/
  249.  
  250. char ans[6];            /*line to jump to*/
  251. char patt[FLIM];        /*pattern to find*/
  252. char changeto[FLIM];        /*replacement string*/
  253. char opts[5];            /*options for alter*/
  254. sint replace;            /*last find/replace was a replace*/
  255. int findir;            /*direction of last find*/
  256. sint nocheck;            /*don't ask for confirmation before replacing*/
  257. sint repeat;            /*repeat last find/replace*/
  258. sint nocase;            /*ignore case in comparison*/
  259.  
  260. char name[FILELEN];        /*filename for read and write files*/
  261.  
  262. sint helpon;            /*display help menu*/
  263.  
  264. int from,to;            /*block start and end*/
  265. sint blocking;            /*true if block is or has been defined*/
  266.  
  267. char fbuf[IOBUFSIZ];        /*file buffer for all file ops other than edited file*/
  268.  
  269. struct iobuffer {
  270.     int _fd;
  271.     int _nleft;
  272.     char *_nextp;
  273.     char _buff[NSECTS * SECSIZ];
  274.     };            /*the structure of the file buffers*/
  275.     
  276. /*end of standard header*/
  277. e;            /*current line*/
  278. char text[LLIM];        /*buffer for curren