home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 158_01 / qe.h < prev    next >
Text File  |  1987-10-12  |  10KB  |  291 lines

  1. /*  VERSION 0033  (DATE: 30/04/87)  (TIME: 13:17)  */
  2. /*
  3.     e (qe) screen editor
  4.  
  5.     (C) G. Nigel Gilbert, MICROLOGY, 1981
  6.     licensed for private non-profitmaking use 1983
  7.     
  8.     August-December 1981
  9.     Modified: To QE from e (ver 4.6a) by J.W. Haefner -- Oct 84-Mar 85
  10.               To QEA 26.vii.85
  11.     FILE: qe.h
  12.  
  13.     PURPOSE: standard header file, #included in all function files
  14.         (NB e does NOT require "bdscio.h")
  15.  
  16. */
  17.  
  18. #define VERSION "4.6a/QE:1.21"
  19.  
  20. /*  10.iv.87
  21.   compile with -e9080 (e10 with -o as well) [qe11+ no wwrap]
  22.   load    with -tA8b0  using l2
  23. */
  24. /* QET */
  25. /* compile: w/  qe11 (VERSION) + WWRAP=NO  use: -e9080, -tA8B0*/
  26. /* compile: w/  qe11 (VERSION) + WWRAP=YES use: -e9580, -tad80 (??)*/
  27. /* compile: w/o qe11 (VERSION) + WWRAP=YES use: -e8C80, -tA500 */
  28. /* compile: w/o qe11 (VERSION) + WWRAP=NO  use: -e8580, -t9D00 */
  29. /* QEA */
  30. /* compile: w/  qe11 (VERSION) + WWRAP=NO  use: -e8FD0, -tA880 */
  31.  
  32. #define TOP 0xA8B0            /*top of program (STACK space=TOP-Externals End)*/
  33. #define CCP 0x0800            /*length of CP/M's CCP */
  34.  
  35. #define SECSIZ 128            /*file buffer definitions*/
  36. #define NSECTS 16
  37. #define IOBUFSIZ (NSECTS * SECSIZ + 6 )
  38. #define FILELEN 16            /*max length of file name*/
  39.  
  40. #define JBUFSIZE 6            /*size of buffer required for longjumps*/
  41.  
  42. #define LLIM 255            /*max length of a line*/
  43. #define FLIM 80                /*max length of find/alter string*/
  44.  
  45. #define FAIL -1
  46. #define NULL 0
  47. #define YES 1
  48. #define NO 0
  49. #define PREV -2
  50.  
  51. /* --- major editor options flags --- */
  52. #define WWRAP (NO)            /*allow word wrap and reformatting?*/
  53. #define    SCRNDIMMD (NO)        /*yes==>highlite current line,no==>all brite */
  54. #define PRINTALL (YES)        /*yes==>send all chars to printer*/
  55. #define VRSNNUM (YES)        /*put version number at file top on save*/
  56. #define VRSNDATE (YES)        /*put version date/time w/ version num */
  57.  
  58. #define NOWLOC 0x50            /*CP/M page 0 loc for date and time*/
  59. #define NOCLOCK (YES)        /*clock for version*/
  60. #define VRSNLEN 56            /*length of verson string*/
  61.  
  62. #define SWIDTH 79            /*screen size*/
  63. #define SHEIGHT 23
  64. #define OFFWIDTH 20            /*horizontal scroll increment*/
  65. #define PAGEOVERLAP 4        /*overlap between pages with UP,DOWN-PAGE*/
  66. #define HELPLINES 8            /*top line number when help menu is on display */
  67.  
  68. #define FNPOS 8                /*status line - position of file name*/
  69. #define LNPOS 23            /*        position of line number*/
  70. #define EMPOS 32            /*        position of error message*/
  71. #define WAITPOS 32            /*        position of cursor when searching/reading*/
  72. #define REPPOS 50            /*        position of "Replace?" message*/
  73.  
  74. #define BACKSP 0x08            /*backspace*/
  75. #define ENDFILE 0x1a        /*CP/M end of text file mark */
  76. #define CTRL 0x1f            /*last control char.*/
  77. #define PARBIT 0x80            /*parity bit used as a flag by testkey() */
  78. #define NKEYS 32            /*number of key codes*/
  79. #define GOTOLEN 6            /*approx no. keys in control code <e4.8>*/
  80.  
  81.     /*internal key codes ('e' ver 4.6a key assignments in parentheses)*/
  82.  
  83. #define LEADIN 0            /*lead in chararacter to key codes -
  84.                               ignored, but following key code parity set*/
  85. #define DOWNKEY 1            /*cursor down  (X)*/
  86. #define UPKEY   2            /*cursor up (E)*/
  87. #define LEFTKEY 3            /*cursor left (S)*/
  88. #define RIGHTKEY 4            /*cursor right (D)*/
  89. #define RIGHTWKEY 5            /*cursor right one word (F) */
  90. #define LEFTWKEY 6            /*cursor left one word (A) */
  91. #define EOLKEY 7            /*cursor to end of line (P) */
  92. #define BOLKEY 8            /*cursor to beginning of line (O) */
  93. #define UPPAGE 9            /*move up a page (R) */
  94. #define DOWNPAGE 10            /*move down a page (C) */
  95. #define BOFKEY 11            /*cursor to beginning of file (U) */
  96. #define HOMEKEY 12            /*cursor to end of file (B) */
  97. #define DELLEFT 13            /*delete char to left of cursor (DEL) */
  98. #define DELRIGHT 14            /*delete char under cursor (G) */
  99. #define DELLNKEY 15            /*delete cursor line (\) */
  100. #define DELWDKEY 16            /*delete word to right of cursor (T) */
  101. #define JUMPKEY 17            /*jump to (J) */
  102. #define CRSTILL 18            /*insert newline after cursor (N) */
  103. #define QWIKKEY 19            /*quick actions (find etc) (Q) */
  104. #define SCRLDNKEY 20        /*scroll down (Z)*/
  105. #define TOPSCRKEY 21        /*top of screen (Y) */
  106. #define BOTSCRKEY 22        /*bottom of screen (V) */
  107. #define BLOCKKEY 23            /*block operations (K) */
  108. #define SCRLUPKEY 24        /*scrolll up (W) */
  109. #define REPKEY 25            /*repeat last find/alter (L) */
  110. /*#define HELPKEY 26*/            /*display help menu (V) */
  111. #define UNDELINE 26            /*inject a previously deleted line*/
  112. #define OOPSKEY 27            /*restore unedited line (_) */
  113. #define TAB 28                /*tab (I)*/
  114. #define RETRIEVE 29            /*retrieve last name etc entered here (L)*/
  115. #define CR 30                /*return (M)*/
  116. #define ESCKEY 31            /*the magic escape key (ESC)*/
  117.  
  118.     /* key codes + 0x80 (PARBIT) used in scanning strings */
  119. #define LEFTKEY_P    131
  120. #define DELLEFT_P    141
  121. #define RETRIEVE_P    157
  122. #define    CR_P        158
  123. #define ESCKEY_P    159
  124.  
  125. #define BRIDIM '|'            /*char placed in e's message strings to start/stop
  126.                                 dim (half-intensity) display */
  127.  
  128.     /* CP/M bdos function codes */
  129.  
  130. #define RESET 0
  131. #define CONIN 0x01
  132. #define CONOUT 0x02
  133. #define LSTOUT 0x05
  134. #define DIRIO 0x06
  135. #define IOBYTE 0x07
  136. #define SETIOBYTE 0x08
  137. #define PRINTS 0x09
  138. #define READBUF 0x0A
  139. #define CONSTAT 0x0B
  140. #define VERNO 0x0C
  141. #define RESETDSK 0x0D
  142. #define SELDSK 0x0E
  143. #define OPEN 0x0F
  144. #define CLOSEF 0x10
  145. #define SEARCH1 0x11
  146. #define SEARCHN 0x12
  147. #define DELETEF 0x13
  148. #define READ 0x14
  149. #define WRITE 0x15
  150. #define MAKE 0x16
  151. #define RENAME 0x17
  152. #define LOGINV 0x18
  153. #define CURDSK 0x19
  154. #define SETDMA 0x1A
  155. #define PROTECT 0x1C
  156. #define GETROV 0x1d
  157. #define DSKPARAMS 0x1F
  158. #define READR 0x21
  159. #define WRITER 0x22
  160. #define FSIZE 0x23
  161. #define SETRR 0x24
  162. #define RESETDRV 0x25
  163.  
  164. #define MAXSLOTS 128            /*virtual memory constants*/
  165. #define MAXMEMSLOTS 20            /*for 64k TPA (CP/M816); old=20*/
  166. #define PAGESIZE 1024
  167. #define PAGESECTS (PAGESIZE/SECSIZ)
  168.  
  169. #define FREE 0
  170. #define INUSE 1
  171. #define NOTAVAIL -1
  172. #define MAXINT 32767
  173. #define NOFILE (MAXINT)
  174. #define ABSOLUTE 0
  175. #define UNKNOWN (MAXINT)
  176.  
  177. #define sint char
  178.  
  179. struct addr {
  180.     sint page;
  181.     int moffset;
  182.     } *tp;                    /*address of text of each line*/
  183.  
  184. int allocp;                    /*location of next free in newpage */
  185. int pageloc[MAXSLOTS];        /*current location of each page*/
  186. int usage[MAXMEMSLOTS];        /*records usage of in memory slots*/
  187. char *slotaddr[MAXMEMSLOTS];    /*memory addr of start of each in memory slot*/
  188. sint dskslots[MAXSLOTS];    /*is disk slot free*/
  189. sint slotsinmem;            /*max no. of slots available in memory*/
  190. sint tppages;                /*no. of pages used to hold text pointers*/
  191. sint newpage;                /*page no of page being filled with text*/
  192. char *npaddr;                /*base of slot holding newpage*/
  193. int clock;                    /*counter for least recently used paging*/
  194.  
  195. int pagefd;                    /*file descriptor of paging file*/
  196. char pagingfile[FILELEN];    /*name of paging file*/
  197. char pagingdisk;            /*disk to put paging file on*/
  198.  
  199. sint curdsk;                /*currently logged in (default) disk*/
  200.  
  201. char mainmenu[JBUFSIZE];    /*for emergency longjump*/
  202. int goodline;                /*line number we know we can display */
  203. unsigned errold[4];            /*temp store for CP/M's error jump addrs*/
  204. char dskerr[JBUFSIZE];        /*for bdos disk error traps*/
  205.  
  206. char textbuf[IOBUFSIZ];        /*io buffer for file being edited*/
  207.  
  208. sint cursorx, cursory;        /*current position of cursor*/
  209. char tran[NKEYS];            /*translation table from external to internal
  210.                               key codes*/
  211. sint isdim;                    /*last char was in dim*/
  212. int lastl;                    /*number of last line of text*/
  213. int lastread;                /*last line actually read to date*/
  214. sint goteof;                /*true when eof of file being edited*/
  215. sint changed;                /*true if file has been modified*/
  216. int cline;                    /*current line*/
  217. char text[LLIM];            /*buffer for current line of text*/
  218. char textb[LLIM];            /*buffer for last deleted line*/
  219. int charn;                    /*position of current char in current line*/
  220. sint altered;                /*if YES, current line has been altered by edits*/
  221.  
  222. int pfirst, plast;            /*top and bottom line displayed on screen*/
  223. sint topline;                /*first line on screen for text*/
  224. sint offset;                /*first col. to display on screen*/
  225. sint lastoff;                /*offset last time resetcursor() was called*/
  226. sint blankedmess;            /*message area has been blanked, not overwritten*/
  227.  
  228. char inbuf[20];                /*input buffer for typeahead*/
  229. sint  inbufp;                /*pointer to next char in inbuf*/
  230.  
  231.             /*environment options*/
  232.             
  233. sint autoin;                /*do auto indentation*/
  234. sint backup;                /*at end, old version becomes file.bak*/
  235. sint readall;                /*to read as much text as possible*/
  236. sint tabwidth;                /*width between tabstops*/
  237. sint trail;                    /*don't chop trailing blanks from text lines*/
  238. sint wboot;                    /*do a warm boot on exit; else jump to CCP*/
  239. sint displaypos;            /*display line:col at top of screen*/
  240. sint helpon;                /*display help menu*/
  241. sint expert;                /*expert mode, brief prompts*/
  242. sint blockscroll;            /*horizontal scroll whole page*/
  243. #if WWRAP
  244. int  rtmarg;                /*right margin for wordwrap*/
  245. #endif
  246. #if VRSNNUM
  247. char version;                /*put version line on file top on save*/
  248. #endif
  249.  
  250. char filename[FILELEN];        /*current file being edited*/
  251. char defext[4];                /*default file extension*/
  252. char *errmess;                /*last error message*/
  253.  
  254. char ans[6];                /*line to jump to*/
  255. char patt[FLIM];            /*pattern to find*/
  256. char changeto[FLIM];        /*replacement string*/
  257. char opts[5];                /*options for alter*/
  258. sint replace;                /*last find/replace was a replace*/
  259. int findir;                    /*direction of last find*/
  260. sint nocheck;                /*don't ask for confirmation before replacing*/
  261. sint repeat;                /*repeat last find/replace*/
  262.  
  263. char name[FILELEN];            /*filename for read and write files*/
  264.  
  265. int jmpto,initjmp;            /*initial line to jump */
  266.  
  267. int from,to;                /*block start and end*/
  268. sint blocking;                /*true if block is or has been defined*/
  269.  
  270. char fbuf[IOBUFSIZ];        /*file buffer for all file ops other than edited file*/
  271.  
  272. struct iobuffer {
  273.     int _fd;
  274.     int _nleft;
  275.     char *_nextp;
  276.     char _buff[NSECTS * SECSIZ];
  277.     };                        /*the structure of the file buffers*/
  278.     
  279. /* globals for version control compile option*/
  280. #if VRSNNUM
  281. char comnt[5];                /*comment symbols for version line*/
  282. char *comntsym();            /*get comment symbol for this file*/
  283. char date[9];                /*version date*/
  284. char time[6];                /*version time*/
  285. #endif
  286.  
  287. char *getline(), *strcpy(),*firstwhite();
  288. char getkey(),getlow(),getscankey(),inkey(),testkey(),testlow();
  289.  
  290. /*end of standard header*/
  291. t options