home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / edit / point20 / globals.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-04  |  12.6 KB  |  399 lines

  1. #include "pt.h"
  2. #include "time.h"
  3.  
  4. /* remember the menu number of the topline menu */
  5. int toplineMenu = 0;
  6.  
  7. /* to support automatic saving */
  8. time_t timeOfLastSave;
  9.  
  10. /* alternate open file table so we can open more than 20 files */
  11. unsigned char far * fileHandleTable;
  12.  
  13. /* for finding TAGS */
  14. unsigned char tagPattern[64];
  15. unsigned char tagMarker[32];
  16. unsigned char lastTag[STRINGSIZE];
  17. unsigned char tagDTA[64];
  18. long tagLastCp = -1;
  19. int tagLastLine;
  20.  
  21. /* for finding keywords */
  22. unsigned char lastKeyword[STRINGSIZE];
  23. unsigned char keywordDTA[64];
  24. long keywordLastCp = -1;
  25. int keywordLastLine;
  26.  
  27. /* So that multiple ones will reduce to one message (used in pt.c) */
  28. int supressFileMsgs = 0;
  29.  
  30. #ifdef OVERLAYS
  31. /* names of the overlays */
  32. unsigned char primaryOverlay[70];
  33. unsigned char secondaryOverlay[70];
  34. unsigned char overlayString[128];
  35. unsigned char *overlayArguments;
  36. int overlayState;
  37. int quitExecuted = 0;
  38. /* 0 ==> no overlay is active */
  39. /* 1 ==> primary overlay only is loaded */
  40. /* 2 ==> secondary overlay only is loaded */
  41. /* 3 ==> primary and secondary overlays are both loaded */
  42. /* 4 ==> unloading secondary overlay */
  43.  
  44. /* files to reopen after the overlay returns */
  45. int filesToOpen = 0;
  46. int primaryFilesToOpen = 0;
  47. struct openFile *ffsToOpen[20];
  48.  
  49. /* overlay command pointers */
  50. unsigned char *overlayMap[56];
  51.  
  52. #endif
  53.  
  54. /* to allow programming of the mouse sensitive window parts */
  55. unsigned char windowPoints[10] = {28, 88, 28, 88, 28, 88, 28, 88, 66, 27};
  56. /* windowPoints[0] => top left corner, left button */
  57. /* windowPoints[1] => top left corner, middle button */
  58. /* windowPoints[2] => top right corner, left button */
  59. /* windowPoints[3] => top right corner, middle button */
  60. /* windowPoints[4] => bottom left corner, left button */
  61. /* windowPoints[5] => bottom left corner, middle button */
  62. /* windowPoints[6] => bottom right corner, left button */
  63. /* windowPoints[7] => bottom right corner, middle button */
  64. /* windowPoints[8] => right border, left button */
  65. /* windowPoints[9] => right border, right button */
  66.  
  67. /* character table for fillLine (in windtext.c) */
  68. unsigned char charTable[256];
  69.  
  70. /* stack location */
  71. unsigned char *stktop;
  72.  
  73. /* scratch file name */
  74. unsigned char scratchFileName[FILENAMESIZE];
  75.  
  76. /* remember directories during getFileName */
  77. unsigned char startDirectory[FILENAMESIZE];
  78. unsigned char startDrive;
  79. unsigned char currentDirectory[FILENAMESIZE];
  80. unsigned char currentDrive;
  81.  
  82. /* keep records so we can move cursor consistently in vertical direction */
  83. int lastColumn = -1;
  84. int lastFn = 0;
  85.  
  86. /* mouse speed parameter */
  87. int mouseSpeed = 4;
  88.  
  89. /* mouse motion parameters */
  90. int quad22 = 25;
  91. int quad45 = 45;
  92. int quad67 = 175;
  93.  
  94. /* mouse motion commands */
  95. int mouseVec1[9] = {
  96. FCOPY, FBACKSEARCH, FDELETE, FMOVETO, FINSKEY,
  97. FREPSEARCH, FREDO, FCOPYTO, FUNDO,
  98. };
  99.  
  100. int mouseVec2[9] = {
  101. FEXTEND, FGOBACKTO, FDELNOSCRAP, FEXCHSCRAP, FCANCEL,
  102. FCONTEXTMENU, FBOTTOM, FCOPYSCRAP, FCLOSEWINDOW,
  103. };
  104.  
  105. /* keyboard macro */
  106. unsigned char macroText[102];
  107. int macroIndex = 0;
  108. int macroSize = 0;
  109. int macroState = 0;
  110.  
  111. /* longjmp here in case of crtl-break */
  112. jmp_buf breakEnv;
  113.  
  114. /* remember is there is a message showing on the bottom line */
  115. int isMessage = 0;
  116.  
  117. /* file id for the "pt.msg" command descriptions file */
  118. int descrFileId = -1;
  119.  
  120. /* remember whether to erase the description message */
  121. int lastOnTopline = 0;
  122.  
  123. /* remember the last command the user selected (for help) */
  124. int lastCommand = FHELP;
  125.  
  126. /* remember the top line menu that is currently showing */
  127. int menuShowing = 0;    /* default to no menu */
  128.  
  129. /* for mouse button events */
  130. int evhead, evtail;
  131. struct event *evaddr;
  132. struct event events[NEVENTS];
  133.  
  134. int passEvhead;
  135. long passCp;
  136.  
  137. /* variable to remember the last character we ignored */
  138. unsigned char lastIgnored;
  139.  
  140. /* current screen size */
  141. int scrRows = 25;
  142. int scrCols = 80;
  143.  
  144. /* piece table */
  145. struct piece *freePList;
  146. unsigned int bytesLeft;
  147. unsigned int piecesLeft;
  148.  
  149. /* save the old video mode */
  150. unsigned char saveVideoMode;
  151.  
  152. /* the globals additions file */
  153. unsigned char addFile[65];
  154. int addHandle;
  155. long addPosition;
  156.  
  157. /* colors for window things -- global versions */
  158. unsigned char textColor    = 0x07;    /* normal text */
  159. unsigned char selColor    = 0x70;    /* selection */
  160. unsigned char bannerColor= 0x70;    /* top line banner */
  161. unsigned char borderColor= 0x07;    /* borders (other than the top) */
  162. unsigned char elevColor    = 0x0F;    /* left border elevator */
  163.  
  164. struct colorCycle colorCycles[NCOLORCYCLES];
  165. unsigned char maxTextCycles = 0;
  166. unsigned char maxBorderCycles = 0;
  167.  
  168. /* global message colors */
  169. unsigned char errorColor = 0xF0;    /* error messages */
  170. unsigned char promptColor= 0x0F;    /* prompt messages */
  171. unsigned char msgColor      = 0x07;    /* informational messages */
  172. unsigned char topColor   = 0x07;    /* top menu line */
  173.  
  174. /* mouse menus */
  175.  
  176. /* space for menu items read from pt.ini (allocated in far * space) */
  177. unsigned char far *menuSpace;
  178. int nextSpace = 0;
  179.  
  180. struct menuBlock far *menus[NMENUS];
  181. /* menu 0 is for dynamic menus (TOPLIST and help) */
  182. /* menus 1 to NMENUS-1 are for users */
  183.  
  184. /* what to do with button presses inside or outside a window */
  185. unsigned char buttonVector[64];
  186.  
  187. /* what to do with button presses on the top line */
  188. unsigned char toplineVector[64];
  189.  
  190. /* debugging flag */
  191. int debug = 0;
  192.  
  193. /* some option flags */
  194. int autoSaveInterval = 0;
  195. int autoScrollRate = 2;
  196. int autoIndent = 1;
  197. int nBuffers = 50;
  198. int centerMenus = 0;
  199. int cursorMouse = 0;
  200. int doubleClickDelay = 50;
  201. int fileSort = 2;
  202. int findWholeWords = 0;
  203. unsigned char fsDirs[200];
  204. unsigned char fsPatterns[128];
  205. unsigned char filePattern[64];
  206. int fsMenu = 1;
  207. int pathNames = 1;
  208. int helpMode = 2;
  209. int ignoreCase = 1;
  210. int initialWindows = 0;
  211. #ifdef OVERLAYS
  212. int overlayVector = 0x61;
  213. #endif
  214. int maxFiles = 20;
  215. int menuLine = 0;
  216. int i43lines = 0;
  217. int overType = 0;
  218. int readOnly = 0;
  219. int reSearch = 0;
  220. int rightMargin = 999;
  221. int scrollDelay = 75;
  222. int scrollRate = 0;
  223. int searchMode = 0;
  224.     /* not an option, used to make backwards search circular */
  225.     int realSearchMode = -1;
  226. int smoothScroll = 1;
  227. int tabWidth = 8;
  228. int topOnFind = 0;
  229. int linesOverFind = 4;
  230. int undoSize = NHISTORY;
  231. int unixMode = 0;
  232. int videoMode = 0;
  233.  
  234. struct optionItem options[] = {
  235. {"43lines",        O43LINES, &i43lines,    OBOOLEAN, FI43LINES},
  236. {"findWholeWords", 0,     &findWholeWords, OBOOLEAN, FFINDWHOLEWORDS},
  237. {"ignoreCase",     0,     &ignoreCase,     OBOOLEAN, FIGNORECASE},
  238. {"searchMode",     0,     &searchMode,     OINTEGER, FSEARCHMODE},
  239. {"topOnFind",      0,     &topOnFind,      OBOOLEAN, FTOPONFIND},
  240. {"linesOverFind",  0,     &linesOverFind,  OINTEGER, FLINESOVERFIND},
  241. {"filePattern",  0,(int *)&filePattern[0], OSTRING,  FFILEPATTERN},
  242. {"autoSaveInterval",0,    &autoSaveInterval,OINTEGER,FAUTOSAVEINTERVAL},
  243. {"autoScrollRate", 0,     &autoScrollRate, OINTEGER, FAUTOSCROLLRATE},
  244. {"tabWidth",       0,     &tabWidth,       OINTEGER, FTABWIDTH},
  245. {"autoIndent",     0,     &autoIndent,     OBOOLEAN, FAUTOINDENT},
  246. {"rightMargin",    0,     &rightMargin,    OINTEGER, FRIGHTMARGIN},
  247. {"overType",       0,     &overType,       OBOOLEAN, FOVERTYPE},
  248. {"pathNames",      0,     &pathNames,      OBOOLEAN, FPATHNAMES},
  249. {"doubleClickDelay",0,    &doubleClickDelay,OINTEGER,FDOUBLECLICKDELAY},
  250. {"smoothScroll",   0,     &smoothScroll,   OBOOLEAN, FSMOOTHSCROLL},
  251. {"centerMenus",    0,     ¢erMenus,    OBOOLEAN, FCENTERMENUS},
  252. {"helpMode",       0,     &helpMode,       OINTEGER, FHELPMODE},
  253. {"textColors",     OTEXTCOLORS, &debug,    OOTHERS,  FTEXTCOLORS},
  254. {"readOnly",       0,     &readOnly,       OBOOLEAN, FOREADONLY},
  255. {"reSearch",       0,     &reSearch,       OBOOLEAN, FRESEARCH},
  256. {"Redefine ...",   OREDEFINE, &debug,      OOTHERS,  FREDEFINE},
  257. {"scrollRate",     0,     &scrollRate,     OINTEGER, FSCROLLRATE},
  258. {"scrollDelay",    0,     &scrollDelay,    OINTEGER, FSCROLLDELAY},
  259. {"borderColors",   OBORDERCOLORS, &debug,  OOTHERS,  FBORDERCOLORS},
  260. {"msgColors",      OMSGCOLORS, &debug,     OOTHERS,  FMSGCOLORS},
  261. {"tagPattern",     0,(int *)&tagPattern[0],OSTRING,  FTAGPATTERN},
  262. {"fsPatterns",     OFSPATTERNS,&debug,     OOTHERS,  FFSPATTERNS},
  263. {"buffers",        ONBUFFERS, &nBuffers,   OOTHERS,  -1},
  264. {"fileSort",       0,     &fileSort,       OINTEGER, FFILESORT},
  265. {"fsMenu",         0,     &fsMenu,         OINTEGER, FFSMENU},
  266. {"fsDirs",         OFSDIRS,&debug,         OOTHERS,  FFSDIRS},
  267. {"initialWindows", 0,     &initialWindows, OINTEGER, -1},
  268. #ifdef OVERLAYS
  269. {"overlayVector",  0,     &overlayVector,  OINTEGER, FOVERLAYVECTOR},
  270. #endif
  271. {"maxFiles",       0,     &maxFiles,       OINTEGER, -1},
  272. {"tagMarker",      0,(int *)&tagMarker[0], OSTRING,  FTAGMARKER},
  273. {"undoSize",       0,     &undoSize,       OINTEGER, -1},
  274. {"unixMode",       0,     &unixMode,       OINTEGER, FUNIXMODE},
  275. {"videoMode",      0,     &videoMode,      OINTEGER, FVIDEOMODE},
  276. {"workDrive",      0,  (int *)&addFile[0], OSTRING,  -1},
  277. {"",               OLASTITEM, &debug,      OINTEGER, FLASTOPTION}
  278. };
  279.  
  280. /* location of the screen bit map */
  281. unsigned int dispMemory;
  282.  
  283. /* save spaces */
  284. int menuRow, menuCol;
  285.  
  286. /* some status (or mode) flags and move/copy pending data */
  287. int mousePresent;
  288. int mouseHorizontal, mouseVertical;
  289. int movePending = 0;
  290. int copyPending = 0;
  291. struct window *pendWindow;
  292. long pendPosition;
  293.  
  294. /* border types */
  295. unsigned char border1[] = {222, 219, 221, 179, 179, 192, 196, 217};
  296. unsigned char border2[] = {201, 205, 187, 186, 186, 200, 205, 188};
  297. unsigned char border3[] = {178, 178, 178, 178, 178, 178, 178, 178};
  298.  
  299. /* screen masking buffer */
  300. unsigned char sscreenMap[MAXROWS*MAXCOLS];
  301. unsigned char *screenMap = sscreenMap;
  302.  
  303. /* value to reset screenMap to when a char is written */
  304. unsigned char scrMapReset = 0;
  305.  
  306. /* screen buffer */
  307. unsigned char sscreenChars[MAXROWS*(MAXCOLS<<1)];
  308. unsigned char *screenChars = sscreenChars;
  309.  
  310. /* screen line buffer */
  311. unsigned char screenLine[MAXCOLS<<1];
  312.  
  313. /* text line buffer */
  314. unsigned char textBuffer[MSGBUFFERSIZE];
  315.  
  316. /* message buffer */
  317. unsigned char msgBuffer[MSGBUFFERSIZE];
  318.  
  319. /* areas for bios calls */
  320. union REGS rin, rout;
  321.  
  322. /* segment registers */
  323. struct SREGS segRegs;
  324.  
  325. /* the list of active windows, top to bottom */
  326. struct window *windowList = NULL;
  327.  
  328. /* the list of hidden windows, top to bottom */
  329. struct window *hiddenList;
  330.  
  331. /* the active window */
  332. struct window *activeWindow;
  333.  
  334. /* the window structures */
  335. struct window *windows;
  336.  
  337. /* the open files */
  338. struct openFile *files;
  339.  
  340. struct changeItem schange[NHISTORY];
  341. struct changeItem *change = schange;
  342. int nextChange = 0;
  343. int tailChange = 0;
  344.  
  345. /* the scrap buffer */
  346. struct changeItem scrapBuffer;
  347. int scrapMode = SELCHAR;
  348.  
  349. /* the globals selection */
  350. struct window *selWindow = NULL;
  351. long selBegin, selEnd;
  352. int selMode;
  353.  
  354. /* the file block buffers */
  355. struct diskBuffer sBuffers[NBUFFERS];
  356. struct diskBuffer *buffers = sBuffers;
  357. unsigned char *bufferSpace;
  358. int nextBuffer;        /* the next buffer to reuse */
  359.  
  360. /* buffer hash tables */
  361. struct diskBuffer *bufHash[NBUFHASH];
  362.  
  363. int keyMap[133] = {
  364. 0,0,0,0/*nul*/,0,
  365. 0,0,0,0,0,
  366. 0,0,0,0,0,
  367. /* alt letters 16-50 */
  368. 0/*s-TAB*/,FQUITASK/*a-Q*/,FWRITEFILE/*a-W*/,FEXCHSCRAP/*a-E*/,FREPLACE/*a-R*/,
  369. FI43LINES/*a-T*/,FDEBUG/*a-Y*/,FUNDO/*a-U*/,FINFORM/*a-I*/,FOVERTYPE/*a-O*/,
  370. FPLAYMACRO/*a-P*/,0,0,0,0,
  371. FASCII/*a-A*/,FSAVEFILE/*a-S*/,FEXECSHELL/*a-D*/,0/*a-F*/,FGOTO/*a-G*/,
  372. FHELP/*a-H*/,0/*a-J*/,0/*a-K*/,FLOADFILE/*a-L*/,0,
  373. 0,0,0,0,FZOOM/*a-Z*/,
  374. FHIDE/*a-X*/,FCLOSEWINDOW/*a-C*/,0/*a-V*/,FBOTTOM/*a-B*/,FNEWWINDOW/*a-N*/,
  375. FRECORDMACRO/*a-M*/,0,0,0,0,
  376. 0,0,0,0,FDELETE/*F1*/,
  377. FINSKEY/*F2*/,FQUITSAVE/*F3*/,FCOPY/*F4*/,FKEYWORDSEL/*F5*/,FREPSEARCH/*F6*/,
  378. FGOBACKTO/*F7*/,FREDO/*F8*/,FUNDO/*F9*/,FREDRAW/*F10*/,0,
  379. 0,FBEGINLINE/*Home*/,FCURUP/*up*/,FPGUP/*PgUp*/,0,
  380. FCURLEFT/*left*/,0,FCURRIGHT/*right*/,0,FENDLINE/*End*/,
  381. FCURDOWN/*down*/,FPGDN/*PgDn*/,FINSKEY/*Ins*/,FDELETE/*Del*/,
  382. FDELNOSCRAP/*s-F1*/,
  383. 0/*s-F2*/,FQUITNOSAVE/*s-F3*/,FCOPYSCRAP/*s-F4*/,FKEYWORD/*s-F5*/,
  384.                             FSEARCH/*s-F6*/,
  385. FGOTOSELECTION/*s-F7*/,FMATCHCHAR/*s-F8*/,FUNDOBACK/*s-F9*/,FLOADSEL/*s-F0*/,
  386. 0/*c-F1*/,0/*c-F2*/,FQUITASK/*c-F3*/,FMOVE/*c-F4*/,FTAGSEL/*c-F5*/,
  387.                             FBACKSEARCH/*c-F6*/,    
  388. FGOTO/*c-F7*/,FTAG/*c-F8*/,FSELGOTO/*c-F9*/,FNEWSEL/*c-F0*/,0/*a-F1*/,
  389. 0/*a-F2*/,FQUITASK/*a-F3*/,FMOVE/*a-F4*/,FTAGSEL/*a-F5*/,FBACKSEARCH/*a-F6*/,
  390. FGOTO/*a-F7*/,FTAG/*a-F8*/,FSELGOTO/*a-F9*/,FNEWSEL/*a-F0*/,0/*c-PrtSc*/,
  391. FWORDLEFT/*c-left*/,FWORDRIGHT/*c-right*/,
  392. 0/*c-End*/,FBOTFILE/*c-PgDn*/,0/*c-Home*/,
  393. 0/*a-1*/,0/*a-2*/,0/*a-3*/,0/*a-4*/,0/*a-5*/,
  394. 0/*a-6*/,0/*a-7*/,0/*a-8*/,0/*a-9*/,0/*a-0*/,
  395. 0/*a--*/,0/*a-=*/,FTOPFILE/*c-PgUp*/
  396. };
  397.  
  398. int asciiMap[132];
  399.