PageRenderTime 71ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/hugs98-Nov2003/src/winhugs/winhugs.c

https://github.com/gitpan/Language-Haskell
C | 1997 lines | 1685 code | 188 blank | 124 comment | 40 complexity | 630223b0d3575c62abb825384980775a MD5 | raw file
Possible License(s): BSD-3-Clause, BSD-2-Clause

Large files files are truncated, but you can click here to view the full file

  1. /* --------------------------------------------------------------------------
  2. * WinHugs.c: José Enrique Gallardo Ruiz, Feb 1999
  3. * With modifications by mpj/adr for Hugs, 1995-97
  4. *
  5. * The Hugs 98 system is Copyright (c) José Enrique Gallardo, Mark P Jones,
  6. * Alastair Reid, the Yale Haskell Group, and the OGI School of
  7. * Science & Engineering at OHSU, 1994-2003, All rights reserved. It is
  8. * distributed as free software under the license in the file "License",
  9. * which is included in the distribution.
  10. *
  11. * This file contains functions for the MS-Windows GUI to Hugs
  12. * ------------------------------------------------------------------------*/
  13. #define STRICT 1
  14. #include <windows.h>
  15. #include <shellapi.h>
  16. #include <commdlg.h>
  17. #include <time.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <stdarg.h>
  21. #include <setjmp.h>
  22. #include <direct.h>
  23. #include <ctype.h>
  24. #include <signal.h>
  25. #include "prelude.h"
  26. #include "storage.h"
  27. #include "connect.h"
  28. #include "errors.h"
  29. #include "machdep.h"
  30. #include "strutil.h"
  31. #include "script.h"
  32. #include "opts.h"
  33. #include "evaluator.h"
  34. /* Hack and slash */
  35. struct options { /* command line option toggles */
  36. char c; /* table defined in main app. */
  37. #if !HASKELL_98_ONLY
  38. int h98; /* set in Haskell'98 mode? */
  39. #endif
  40. String description;
  41. Bool *flag;
  42. };
  43. extern struct options toggle[];
  44. #include "WinFrame.h"
  45. #include "WinToolB.h"
  46. #include "WinSTLN.h"
  47. #include "WinUtils.h"
  48. /* --------------------------------------------------------------------------
  49. * Local functions prototypes
  50. * ------------------------------------------------------------------------*/
  51. #ifndef __WINHUGS_H
  52. #include "WinHugs.h"
  53. #endif
  54. /* --------------------------------------------------------------------------
  55. * Nonlocal functions prototypes
  56. * ------------------------------------------------------------------------*/
  57. INT APIENTRY WinMain (HINSTANCE, HINSTANCE, LPSTR, INT);
  58. /* --------------------------------------------------------------------------
  59. * CALLBACK functions prototypes:
  60. * ------------------------------------------------------------------------*/
  61. LRESULT CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM);
  62. LRESULT CALLBACK BrowseClassesDlgProc (HWND, UINT, WPARAM, LPARAM);
  63. LRESULT CALLBACK BrowseTyconsDlgProc (HWND, UINT, WPARAM, LPARAM);
  64. LRESULT CALLBACK BrowseNamesDlgProc (HWND, UINT, WPARAM, LPARAM);
  65. LRESULT CALLBACK MainGUIWndProc (HWND, UINT, WPARAM, LPARAM);
  66. LRESULT CALLBACK OptionsDlgProc (HWND, UINT, WPARAM, LPARAM);
  67. LRESULT CALLBACK ClassesWndProc (HWND, UINT, WPARAM, LPARAM);
  68. LRESULT CALLBACK ScriptManDlgProc (HWND, UINT, WPARAM, LPARAM);
  69. /* --------------------------------------------------------------------------
  70. * Default interpreter options
  71. * ------------------------------------------------------------------------*/
  72. #define DEFAULT_ROWS 25
  73. #define DEFAULT_COLS 80
  74. #define DEFAULT_FONT "Courier New"
  75. #define DEFAULT_FONT_SIZE 9
  76. #define DEFAULT_FONT_WEIGHT FW_NORMAL
  77. #define DEFAULT_DIALOGFONT "MS Sans Serif"
  78. #define DEFAULT_DIALOGFONT_SIZE 8
  79. #define DEFAULT_PROMPT "%s> "
  80. #define DEFAULT_REPEATSTR "$$"
  81. #define DEFAULT_PREPROCESSOR ""
  82. #define DEFAULT_DOC_DIR "{Hugs}\\docs"
  83. #define HASKELL_REPORT "report\\index.html"
  84. #define HASKELL_LIBS "library\\index.html"
  85. #define HASKELL_GENTLE "tutorial\\index.html"
  86. #define HUGS_EXTS "libs\\libs.html"
  87. #define HUGS_DOCS "hugsman\\index.html"
  88. #define HASKELL_ORG "http:\\\\haskell.org"
  89. #define HUGS_HELP_FILE "hugs.hlp"
  90. /* --------------------------------------------------------------------------
  91. * Local Macros:
  92. * ------------------------------------------------------------------------*/
  93. #define DlgSendMessage(h,c,w,l) SendMessage((h),(c),MAKEWPARAM(w,(HIWORD(l))),(LOWORD(l)))
  94. #define AbortInterpreter input(BREAK); WinPuts(hWndText, "\n")
  95. #define GotoInterpreter longjmp(catch_error, 1);
  96. /* --------------------------------------------------------------------------
  97. * Local Variables:
  98. * ------------------------------------------------------------------------*/
  99. #if DOS
  100. String appName = "Hugs for Windows"; /* Text for application name */
  101. #else
  102. String appName = "Hugs for Windows 32"; /* Text for application name */
  103. #endif
  104. HANDLE hThisInstance; /* Windows instance for the application */
  105. HWND hWndMain = NULL; /* Main Window handle */
  106. HWND hWndText = NULL; /* Hugs Text Window handle */
  107. HWND hWndClasses = NULL; /* Classes Hierarchy Window handle */
  108. static HANDLE hAccelTable; /* Accelerators table */
  109. HCURSOR GarbageCursor = NULL; /* GC mouse cursor */
  110. HCURSOR SaveCursor = NULL; /* Used to save current cursor */
  111. static INT FrameWinWidth = 0,
  112. FrameWinHeight = 0; /* Size of Main Window */
  113. static INT FrameWinX, FrameWinY; /* Pos of Main Window in Screen */
  114. static INT ScreenRows = 0,
  115. ScreenCols = 0; /* Text Window size in chars */
  116. static WNDPROC PrevWndProc; /* Window Proc of Frame class */
  117. static CHAR **hugs_argv; /* Command line args */
  118. static INT hugs_argc;
  119. static HFONT hDialogFont = NULL; /* Font to use in Dialogs */
  120. #include "menusbm.c"
  121. /* --------------------------------------------------------------------------
  122. * Browse dialogs and classes hierarchy:
  123. * ------------------------------------------------------------------------*/
  124. #include "WinBrows.c"
  125. /* --------------------------------------------------------------------------
  126. * Responses to messages:
  127. * ------------------------------------------------------------------------*/
  128. /* About Hugs ... */
  129. static VOID local DoAbout(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  130. {
  131. ExecDialog(hThisInstance, ABOUTDLGBOX, AboutDlgProc);
  132. }
  133. /* Browse Classes ... */
  134. static VOID local DoBrowseClasses(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  135. {
  136. ExecDialog(hThisInstance, BROWSECLASSESDLGBOX, BrowseClassesDlgProc);
  137. }
  138. static VOID local
  139. SelectFont(HWND hWnd)
  140. {
  141. CHOOSEFONT cf;
  142. LOGFONT* pLF;
  143. pLF = (LOGFONT*) SendMessage (hWndText, WM_GETLOGFONT, 0, 0L);
  144. ZeroMemory(&cf,sizeof(CHOOSEFONT));
  145. cf.lStructSize = sizeof(CHOOSEFONT);
  146. cf.hwndOwner = hWnd;
  147. cf.lpLogFont = pLF;
  148. cf.Flags = CF_SCREENFONTS |
  149. CF_FIXEDPITCHONLY |
  150. CF_INITTOLOGFONTSTRUCT;
  151. if (ChooseFont(&cf)) {
  152. SendMessage(hWndText, WM_SETTEXTFONT,
  153. (WPARAM)pLF,
  154. (LPARAM)(cf.iPointSize/10));
  155. }
  156. }
  157. /* Browse Type Constructors ... */
  158. static VOID local DoBrowseTycons(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  159. {
  160. ExecDialog(hThisInstance, BROWSETYCONSDLGBOX, BrowseTyconsDlgProc);
  161. }
  162. /* Browse Names ... */
  163. static VOID local DoBrowseNames(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  164. {
  165. ExecDialog(hThisInstance, BROWSENAMESDLGBOX, BrowseNamesDlgProc);
  166. }
  167. /* Response to Windows WM_CLOSE message */
  168. static VOID local DoClose(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  169. {
  170. SendMessage (hWnd, WM_COMMAND, ID_EXIT, 0L);
  171. }
  172. /* Response to Menu Commands */
  173. static VOID local DoCommand(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  174. {
  175. switch (LOWORD(wParam)) {
  176. /* Open text editor for new file */
  177. case ID_NEW: AbortInterpreter;
  178. SetInterpreterCommand(":l\n:e\n");
  179. GotoInterpreter;
  180. break;
  181. /* Load a sript file from disk */
  182. case ID_OPEN: { CHAR *ScriptName;
  183. CHAR Command[2048];
  184. if ((ScriptName = GetaFileName(GetFocus(), IDS_FILTERFILE)) != NULL) {
  185. wsprintf(Command, ":l %s\n", ExpandFileName((String)ScriptName));
  186. AbortInterpreter;
  187. SetInterpreterCommand(Command);
  188. GotoInterpreter;
  189. }
  190. }
  191. break;
  192. /* Enter Script Manager */
  193. case ID_SCRIPTMAN: DoScriptMan(hWnd, msg, wParam, lParam);
  194. break;
  195. /* Load a sript file from disk (the name of the script is currently selected) */
  196. case ID_OPENSELECTED: { CHAR *ScriptName;
  197. CHAR Command[2048];
  198. ScriptName = GetSelectedText(hWndText);
  199. wsprintf(Command, ":l %s\n", ExpandFileName((String)ScriptName));
  200. AbortInterpreter;
  201. SetInterpreterCommand(Command);
  202. GotoInterpreter;
  203. }
  204. break;
  205. /* Exit Hugs interpreter */
  206. case ID_EXIT: AbortInterpreter;
  207. SetInterpreterCommand(":q\n");
  208. GotoInterpreter;
  209. break;
  210. /* Load one of the last 10 open files */
  211. case ID_EXIT+1:
  212. case ID_EXIT+2:
  213. case ID_EXIT+3:
  214. case ID_EXIT+4:
  215. case ID_EXIT+5:
  216. case ID_EXIT+6:
  217. case ID_EXIT+7:
  218. case ID_EXIT+8:
  219. case ID_EXIT+9:
  220. case ID_EXIT+10: { CHAR ScriptName[_MAX_PATH];
  221. CHAR Command[2048];
  222. strcpy(ScriptName, GetFileNameFromFileNamesMenu(&FilesMenu, wParam-ID_EXIT-1));
  223. wsprintf(Command, ":l %s\n", ExpandFileName((String)ScriptName));
  224. AbortInterpreter;
  225. SetInterpreterCommand(Command);
  226. GotoInterpreter;
  227. }
  228. break;
  229. /* Clipboard copy */
  230. case ID_COPY: SendMessage(hWndText, WM_COPY, 0, 0L);
  231. break;
  232. /* Clipboard paste */
  233. case ID_PASTE: SendMessage(hWndText, WM_PASTE, 0, 0L);
  234. break;
  235. /* Clipboard cut */
  236. case ID_CUT: SendMessage(hWndText, WM_CUT, 0, 0L);
  237. break;
  238. /* Clipboard clear */
  239. case ID_CLEAR: SendMessage(hWndText, WM_CLEAR, 0, 0L);
  240. break;
  241. /* Edit previous line */
  242. case ID_GOPREVIOUS: SendMessage(hWndText, WM_KEYDOWN, (WPARAM) VK_UP, 0x1000000L);
  243. SendMessage(hWndText, WM_KEYUP, (WPARAM) VK_UP, 0x1000000L);
  244. break;
  245. /* Edit next line */
  246. case ID_GONEXT: SendMessage(hWndText, WM_KEYDOWN, (WPARAM) VK_DOWN, 0x1000000L);
  247. SendMessage(hWndText, WM_KEYUP, (WPARAM) VK_DOWN, 0x1000000L);
  248. break;
  249. /* Change text window font */
  250. case ID_FONT:
  251. SelectFont(hWnd);
  252. break;
  253. /* Open text editor */
  254. case ID_GOEDIT: AbortInterpreter;
  255. SetInterpreterCommand(":e\n");
  256. GotoInterpreter;
  257. break;
  258. case ID_EDITSELECTED+1:
  259. case ID_EDITSELECTED+2:
  260. case ID_EDITSELECTED+3:
  261. case ID_EDITSELECTED+4:
  262. case ID_EDITSELECTED+5:
  263. case ID_EDITSELECTED+6:
  264. case ID_EDITSELECTED+7:
  265. case ID_EDITSELECTED+8:
  266. case ID_EDITSELECTED+9:
  267. case ID_EDITSELECTED+10: { CHAR ScriptName[_MAX_PATH];
  268. CHAR Command[2048];
  269. strcpy(ScriptName, GetFileNameFromFileNamesMenu(&EditMenu, wParam-ID_EDITSELECTED-1));
  270. wsprintf(Command, ":e %s\n", ExpandFileName((String)ScriptName));
  271. AbortInterpreter;
  272. SetInterpreterCommand(Command);
  273. GotoInterpreter;
  274. }
  275. break;
  276. /* Open text editor for selected text */
  277. case ID_EDITSELECTED: { CHAR Command[2048];
  278. wsprintf(Command, ":e %s\n", ExpandFileName((String)GetSelectedText(hWndText)));
  279. AbortInterpreter;
  280. SetInterpreterCommand(Command);
  281. GotoInterpreter;
  282. }
  283. break;
  284. /* Find definition of selected text */
  285. case ID_FIND: { String SelectedText;
  286. SelectedText = GetSelectedText(hWndText);
  287. AbortInterpreter;
  288. SetInterpreterCommand(":f %s\n",(LPSTR)SelectedText);
  289. GotoInterpreter;
  290. }
  291. break;
  292. /* Show type of selected text */
  293. case ID_TYPE: { String SelectedText;
  294. SelectedText = GetSelectedText(hWndText);
  295. AbortInterpreter;
  296. SetInterpreterCommand(":t %s\n",(LPSTR)SelectedText);
  297. GotoInterpreter;
  298. }
  299. break;
  300. /* Show info on selected text */
  301. case ID_INFO: { String SelectedText;
  302. SelectedText = GetSelectedText(hWndText);
  303. AbortInterpreter;
  304. SetInterpreterCommand(":i %s\n",(LPSTR)SelectedText);
  305. GotoInterpreter;
  306. }
  307. break;
  308. /* Eval selected text */
  309. case ID_EVAL: { String SelectedText;
  310. SelectedText = GetSelectedText(hWndText);
  311. AbortInterpreter;
  312. SetInterpreterCommand("%s\n",(LPSTR)SelectedText);
  313. GotoInterpreter;
  314. }
  315. break;
  316. /* Stop program execution */
  317. case ID_STOP: MessageBeep(0xFFFFFFFF);
  318. raise(SIGINT);
  319. break;
  320. /* Evaluate main expression */
  321. case ID_RUN: AbortInterpreter;
  322. SetInterpreterCommand("main\n");
  323. GotoInterpreter;
  324. break;
  325. /* Set interpreter options using dialog box */
  326. case ID_SETOPTIONS: DoOptions (hWnd, msg, wParam, lParam);
  327. break;
  328. /* Reload script files */
  329. case ID_COMPILE:
  330. case ID_MAKE: AbortInterpreter;
  331. SetInterpreterCommand(":r\n");
  332. GotoInterpreter;
  333. break;
  334. /* Clear all files loaded but Prelude */
  335. case ID_CLEARALL: AbortInterpreter;
  336. SetInterpreterCommand(":l\n");
  337. GotoInterpreter;
  338. break;
  339. /* Show classes hierarchy */
  340. case ID_BROWSEHIERARCHY: DrawClassesHierarchy();
  341. break;
  342. /* Browse classes defined */
  343. case ID_BROWSECLASSES: DoBrowseClasses(hWnd, msg, wParam, lParam);
  344. break;
  345. /* Browse names defined */
  346. case ID_BROWSENAMES: DoBrowseNames(hWnd, msg, wParam, lParam);
  347. break;
  348. /* Browse type constructors defined */
  349. case ID_BROWSETYCONS: DoBrowseTycons(hWnd, msg, wParam, lParam);
  350. break;
  351. /* Display help about using windows help */
  352. case ID_HELPUSE: WinHelp(hWnd, "Winhelp.Hlp", HELP_CONTENTS, 0L);
  353. break;
  354. /* Display help about Hugs */
  355. case ID_HELPINDEX: { char DocFullPath[_MAX_PATH];
  356. char *HelpFullPath = NULL;
  357. if ( GetFromRegistryDocPath(DocFullPath, _MAX_PATH) ) {
  358. HelpFullPath = alloca(strlen(DocFullPath) + strlen(HUGS_HELP_FILE) + 5);
  359. if (HelpFullPath) {
  360. wsprintf(HelpFullPath, "%s\\%s", DocFullPath, HUGS_HELP_FILE);
  361. WinHelp(hWnd, HelpFullPath, HELP_CONTENTS, 0L);
  362. }
  363. }
  364. }
  365. break;
  366. /* Display the Haskell report */
  367. case ID_HELPREPORT: OpenHtmlFromDocs(HASKELL_REPORT);
  368. break;
  369. /* Display the Haskell lib report */
  370. case ID_HELPLIBS: OpenHtmlFromDocs(HASKELL_LIBS);
  371. break;
  372. /* Display the Gentle intro */
  373. case ID_HELPGENTLE: OpenHtmlFromDocs(HASKELL_GENTLE);
  374. break;
  375. /* Go to haskell home */
  376. case ID_HELPHASKELLORG: OpenHtml(HASKELL_ORG);
  377. break;
  378. /* Display the hugs and ghc exts */
  379. case ID_HELPEXTS: OpenHtmlFromDocs(HUGS_EXTS);
  380. break;
  381. /* Display the hugs doc */
  382. case ID_HELPDOCS: OpenHtmlFromDocs(HUGS_DOCS);
  383. break;
  384. /* Show hugs commands */
  385. case ID_HELPCOMMANDS: AbortInterpreter;
  386. SetInterpreterCommand(":?\n");
  387. GotoInterpreter;
  388. break;
  389. /* Show Hugs copyright */
  390. case ID_ABOUT: DoAbout (hWnd, msg, wParam, lParam);
  391. break;
  392. }
  393. }
  394. /* Response to Windows WM_CREATE message */
  395. static INT local DoCreate(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  396. {
  397. INT DialogFontSize;
  398. CHAR DialogFontName[256];
  399. GetFromRegistryDialogFont(DialogFontName, 256, &DialogFontSize);
  400. hDialogFont = CreateFont(DialogFontSize*15/9,0,0,0,
  401. FW_NORMAL,
  402. FALSE,
  403. FALSE,
  404. FALSE,
  405. ANSI_CHARSET,
  406. OUT_TT_PRECIS,
  407. CLIP_TT_ALWAYS,
  408. DEFAULT_QUALITY,
  409. FIXED_PITCH | FF_MODERN,
  410. DialogFontName);
  411. if (!hDialogFont){
  412. MessageBox(GetFocus(), "Out of memory creating font", appName,
  413. MB_ICONHAND | MB_SYSTEMMODAL | MB_OK);
  414. DoDestroy(hWnd, msg, wParam, lParam);
  415. return -1;
  416. }
  417. /* Load Garbage Collection cursor */
  418. GarbageCursor = LoadCursor(hThisInstance, "GARBAGECURSOR");
  419. if (!GarbageCursor){
  420. MessageBox(GetFocus(), "Out of memory loading cursors", appName,
  421. MB_ICONHAND | MB_SYSTEMMODAL | MB_OK);
  422. DoDestroy(hWnd, msg, wParam, lParam);
  423. return -1;
  424. }
  425. InitMenus(); /* initialize menus */
  426. SetMenuBitmaps(hWnd);
  427. return 0;
  428. }
  429. /* Response to Windows WM_DESTROY message */
  430. static VOID local DoDestroy(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  431. {
  432. /* Close Help Windows, if opened */
  433. WinHelp(hWnd, "WINHELP.HLP", HELP_QUIT, 0L);
  434. WinHelp(hWnd, "Hugs.HLP", HELP_QUIT, 0L);
  435. /* Free space used by Fonts and cursors */
  436. if (GarbageCursor) DestroyCursor(GarbageCursor);
  437. if (hDialogFont) DeleteObject(hDialogFont);
  438. }
  439. /* Response to Windows WM_DROPFILES message */
  440. static VOID local DoDropFiles(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  441. {
  442. UINT cFiles, a;
  443. CHAR lpszFile[_MAX_PATH];
  444. forgetScriptsFrom(1);
  445. cFiles = DragQueryFile((HANDLE) wParam, (UINT) 0xFFFFFFFF, (LPSTR) NULL, 0);
  446. for(a = 0; a < cFiles; a++) {
  447. DragQueryFile((HANDLE) wParam, a, (LPSTR)lpszFile, (UINT)sizeof(lpszFile));
  448. /* Add file to scripts list */
  449. addScriptName(lpszFile, TRUE);
  450. SetWorkingDir(lpszFile);
  451. }
  452. DragFinish((HANDLE) wParam);
  453. /* set focus to frame window */
  454. SetForegroundWindow(hWnd);
  455. /* reload scripts */
  456. AbortInterpreter;
  457. readScripts(1);
  458. GotoInterpreter;
  459. }
  460. #if 0
  461. /* Response to Windows WM_GETMINMAXINFO message */
  462. static VOID local DoGetMinMaxInfo(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  463. {
  464. MINMAXINFO FAR* lpmmi;
  465. RECT rWind;
  466. GetWindowRect(hWnd, &rWind);
  467. lpmmi = (MINMAXINFO FAR*) lParam;
  468. lpmmi->ptMaxPosition.x = rWind.left;
  469. lpmmi->ptMaxPosition.y = rWind.top;
  470. lpmmi->ptMaxTrackSize.x = FrameWinWidth;
  471. lpmmi->ptMaxTrackSize.y = FrameWinHeight;
  472. lpmmi->ptMaxSize.x = FrameWinWidth;
  473. lpmmi->ptMaxSize.y = FrameWinHeight;
  474. }
  475. #else
  476. /*
  477. A very minor quibble though is that it wasn't possible to
  478. resize the main window (maybe that's really intentional..)
  479. In any case, I've changed the handler for WM_MINMAXINFO to
  480. let me do this - code appended.
  481. --sigbjorn
  482. */
  483. /* Response to Windows WM_GETMINMAXINFO message */
  484. static VOID local DoGetMinMaxInfo(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
  485. lParam)
  486. {
  487. MINMAXINFO FAR* lpmmi;
  488. RECT rWind;
  489. RECT rDeskTop;
  490. GetWindowRect(GetDesktopWindow(), &rDeskTop);
  491. GetWindowRect(hWnd, &rWind);
  492. lpmmi = (MINMAXINFO FAR*) lParam;
  493. lpmmi->ptMaxPosition.x = 0;
  494. lpmmi->ptMaxPosition.y = 0;
  495. lpmmi->ptMinTrackSize.x = 10; // a random small non-neg number, really.
  496. lpmmi->ptMinTrackSize.y = 10;
  497. lpmmi->ptMaxTrackSize.x = rDeskTop.right - rDeskTop.left;
  498. lpmmi->ptMaxTrackSize.y = rDeskTop.bottom - rDeskTop.top;
  499. lpmmi->ptMaxSize.x = lpmmi->ptMaxTrackSize.x;
  500. lpmmi->ptMaxSize.y = lpmmi->ptMaxTrackSize.y;
  501. }
  502. #endif
  503. static VOID local DoMove(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  504. {
  505. if (!IsIconic(hWnd)) {
  506. /* We must substract as it gets client position */
  507. FrameWinX = (INT) LOWORD(lParam) - GetSystemMetrics(SM_CXFRAME);
  508. FrameWinY = (INT) HIWORD(lParam) - GetSystemMetrics(SM_CYCAPTION)
  509. - GetSystemMetrics(SM_CYFRAME)
  510. - GetSystemMetrics(SM_CYMENU);
  511. }
  512. }
  513. /* Load and execute Options dialog box */
  514. static VOID local DoOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  515. {
  516. ExecDialog (hThisInstance, OPTIONSDLGBOX, OptionsDlgProc);
  517. AbortInterpreter;
  518. SetInterpreterCommand(":s\n");
  519. GotoInterpreter;
  520. }
  521. static VOID local DoScriptMan(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  522. {
  523. ExecDialog(hThisInstance, SCRIPTMANDLGBOX, ScriptManDlgProc);
  524. }
  525. /* Executed before a menu is opened */
  526. static VOID local DoInitMenu (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  527. {
  528. BOOL CanCopy, CanPaste, CanClear, CanCut;
  529. CanCopy = (BOOL) SendMessage (hWndText, WM_CANCOPY, 0, 0L);
  530. CanCut = (BOOL) SendMessage (hWndText, WM_CANCUT, 0, 0L);
  531. CanPaste = (BOOL) SendMessage (hWndText, WM_CANPASTE, 0, 0L);
  532. CanClear = (BOOL) SendMessage (hWndText, WM_CANCLEAR, 0, 0L);
  533. EnableMenuItem((HMENU)wParam, ID_COPY, (CanCopy ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  534. EnableMenuItem((HMENU)wParam, ID_PASTE, (CanPaste ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  535. EnableMenuItem((HMENU)wParam, ID_CUT, (CanCut ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  536. EnableMenuItem((HMENU)wParam, ID_CLEAR, (CanClear ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  537. EnableMenuItem((HMENU)wParam, ID_EVAL, (CanCopy ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  538. EnableMenuItem((HMENU)wParam, ID_TYPE, (CanCopy ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  539. EnableMenuItem((HMENU)wParam, ID_INFO, (CanCopy ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  540. EnableMenuItem((HMENU)wParam, ID_FIND, (CanCopy ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  541. EnableMenuItem((HMENU)wParam, ID_OPENSELECTED, (CanCopy ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  542. EnableMenuItem((HMENU)wParam, ID_EDITSELECTED, (CanCopy ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  543. EnableMenuItem((HMENU)wParam, ID_MAKE, MF_ENABLED|MF_BYCOMMAND);
  544. EnableMenuItem((HMENU)wParam, ID_CLEARALL, ((getScriptHwMark() > 1)
  545. ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  546. EnableMenuItem((HMENU)wParam, ID_COMPILE, ((getScriptHwMark() > 1)
  547. ? MF_ENABLED : MF_GRAYED)|MF_BYCOMMAND);
  548. }
  549. /* --------------------------------------------------------------------------
  550. * Other functions for Windows GUI:
  551. * ------------------------------------------------------------------------*/
  552. static
  553. UINT FAR APIENTRY
  554. FileOpenHookProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
  555. {
  556. switch (msg) {
  557. case WM_INITDIALOG: {
  558. HWND hWnd;
  559. hWnd = GetParent(hdlg);
  560. CenterDialogInParent(hWnd);
  561. SetDialogFont(hWnd, hDialogFont);
  562. return TRUE;
  563. }
  564. }
  565. return FALSE;
  566. }
  567. /* Used to get a file name using a common dialog box. Returns a pointer to */
  568. /* a static string where the file name is, or NULL if cancel button is pushed */
  569. /* Mask is the identificator of a string defined in Hugs.Rc where the type */
  570. /* of files and their masks are */
  571. static CHAR* local GetaFileName(HWND hWnd, UINT Mask)
  572. {
  573. #define MAXEXTENSIONS 15
  574. static CHAR Extensions[MAXEXTENSIONS][_MAX_EXT+1];
  575. static OPENFILENAME ofn;
  576. static CHAR szFileName[_MAX_PATH];
  577. CHAR szFile[_MAX_PATH], szFileTitle[_MAX_PATH];
  578. UINT i, j, cbString, n;
  579. CHAR chReplace; /* Separator between different filters in szFilter */
  580. CHAR szFilter[300];
  581. char currentDir[_MAX_PATH];
  582. szFile[0] = '\0';
  583. if ((cbString = LoadString(hThisInstance, Mask,
  584. szFilter, sizeof(szFilter))) == 0) {
  585. /* Error */
  586. return NULL;
  587. }
  588. chReplace = szFilter[cbString - 1]; /* Get separator */
  589. /* Get valid extensions for files */
  590. for (n=0, i=0;szFilter[i];) {
  591. while (szFilter[i] != chReplace) i++;
  592. i++;
  593. do {
  594. while (szFilter[i] != '.') i++;
  595. i++;
  596. j=0;
  597. while ((szFilter[i] != ';')&&(szFilter[i] != chReplace)){
  598. Extensions[n][j++] = szFilter[i++];
  599. }
  600. Extensions[n++][j] = (CHAR) 0;
  601. } while (szFilter[i] == ';');
  602. i++;
  603. }
  604. for (;n<MAXEXTENSIONS;n++)
  605. Extensions[n][0] = (CHAR)0;
  606. /* Replace separator with NULL */
  607. for (i = 0; szFilter[i] != '\0'; i++) {
  608. if (szFilter[i] == chReplace)
  609. szFilter[i] = '\0';
  610. }
  611. memset(&ofn, 0, sizeof(OPENFILENAME));
  612. ofn.lStructSize = sizeof(OPENFILENAME);
  613. ofn.hInstance = hThisInstance;
  614. ofn.hwndOwner = hWnd;
  615. ofn.lpstrFilter = szFilter;
  616. ofn.nFilterIndex = 1;
  617. ofn.lpstrFile= szFile;
  618. ofn.nMaxFile = sizeof(szFile);
  619. ofn.lpstrFileTitle = szFileTitle;
  620. ofn.nMaxFileTitle = sizeof(szFileTitle);
  621. ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLEHOOK | OFN_EXPLORER;;
  622. ofn.lpfnHook = FileOpenHookProc;
  623. GetCurrentDirectory(_MAX_PATH,currentDir);
  624. ofn.lpstrInitialDir = currentDir;
  625. if (GetOpenFileName(&ofn)) {
  626. strcpy(szFileName, ofn.lpstrFile);
  627. return szFileName;
  628. }
  629. else {
  630. return NULL;
  631. }
  632. }
  633. /* Construct hugs_argc and hugs_argv from lpszCmdLine */
  634. static Void local copyArgs(LPSTR lpszCmdLine) {
  635. INT i, currentArg, beginOfArg;
  636. CHAR svChar;
  637. /* First, get number of args */
  638. /* Rules: */
  639. /* 1) arguments are separates by spaces */
  640. /* 2) A single argument may contain spaces if surrounded by quotes */
  641. /* */
  642. /* For example, a valid command line with two args is */
  643. /* c:> winhugs -98 "c:\program files\test.hs" */
  644. hugs_argc = 0;
  645. for(i=0;lpszCmdLine[i];) {
  646. if(lpszCmdLine[i]=='"') { /* a "... " argument */
  647. i++;
  648. hugs_argc++;
  649. while (lpszCmdLine[i] && lpszCmdLine[i] != '"') i++;
  650. if (lpszCmdLine[i] != '"') {
  651. MessageBox(GetFocus(), "Invalid command line", appName, MB_OK);
  652. hugs_argc = 0;
  653. }
  654. }
  655. else if(lpszCmdLine[i]!=' ') {
  656. i++;
  657. hugs_argc++;
  658. while (lpszCmdLine[i] && lpszCmdLine[i] != ' ') i++;
  659. }
  660. if(lpszCmdLine[i]) i++;
  661. }
  662. hugs_argc++; /* One more for program name */
  663. /* Allocate arguments */
  664. hugs_argv = malloc(hugs_argc*sizeof(CHAR *));
  665. if (!hugs_argv) {
  666. ERRMSG(0) "String storage space exhausted"
  667. EEND;
  668. }
  669. /* First argument must be program name */
  670. hugs_argv[0] = strCopy("winhugs.exe");
  671. #define copyCurrentArg { \
  672. svChar = lpszCmdLine[i]; \
  673. lpszCmdLine[i] = '\0'; \
  674. hugs_argv[currentArg++] = strCopy(&lpszCmdLine[beginOfArg]);\
  675. lpszCmdLine[i] = svChar; \
  676. }
  677. if (hugs_argc > 1) {
  678. currentArg = 1;
  679. for(i=0;lpszCmdLine[i];) {
  680. if(lpszCmdLine[i]=='"') { /* a "... " argument */
  681. beginOfArg = ++i;
  682. while (lpszCmdLine[i] != '"') i++;
  683. copyCurrentArg;
  684. }
  685. else if(lpszCmdLine[i]!=' ') {
  686. beginOfArg = i;
  687. while (lpszCmdLine[i] && lpszCmdLine[i] != ' ') i++;
  688. copyCurrentArg;
  689. }
  690. if(lpszCmdLine[i]) i++;
  691. }
  692. }
  693. #undef copyCurrentArg
  694. }
  695. /* Program entry point */
  696. INT APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, INT nCmdShow)
  697. {
  698. INT i;
  699. /* Save application instance */
  700. hThisInstance = hInstance;
  701. if (!hPrevInstance) {
  702. if (!InitApplication()) {
  703. MessageBeep(0);
  704. { DWORD Error;
  705. CHAR Buffer[256];
  706. Error = GetLastError();
  707. sprintf(Buffer, "Error number %u",Error);
  708. MessageBox(NULL, Buffer, "Error", MB_OK);
  709. }
  710. return FALSE;
  711. }
  712. }
  713. if (!InitInstance(lpszCmdLine, nCmdShow))
  714. return FALSE;
  715. /* Call hugs main function */
  716. copyArgs(lpszCmdLine);
  717. main(hugs_argc, hugs_argv);
  718. /* Leaving hugs ... */
  719. /* hWndMain is already destroyed */
  720. /* Free allocated memory for command line */
  721. for (i=0; i<hugs_argc; i++)
  722. if (hugs_argv[i])
  723. free(hugs_argv[i]);
  724. free(hugs_argv);
  725. return 0;
  726. }
  727. /* Init application */
  728. static BOOL local InitApplication(VOID)
  729. {
  730. WNDCLASS wc;
  731. /* register frame window class */
  732. if (!FRAMERegisterClass(hThisInstance))
  733. return FALSE;
  734. /* superclass the frame class */
  735. if (!FRAMESuperclass (hThisInstance,
  736. "HugsFrameWindow",
  737. "HugsMenu",
  738. "Hugs"))
  739. return FALSE;
  740. /* register classes hierarchy window */
  741. wc.style = CS_VREDRAW | CS_HREDRAW;
  742. wc.lpfnWndProc = ClassesWndProc;
  743. wc.cbClsExtra = 0;
  744. wc.cbWndExtra = 0;
  745. wc.hInstance = hThisInstance;
  746. wc.hIcon = NULL;
  747. wc.hCursor = NULL;
  748. wc.hbrBackground = GetStockObject(LTGRAY_BRUSH);
  749. wc.lpszMenuName = NULL;
  750. wc.lpszClassName = "HugsClassesWindow";
  751. if (!RegisterClass(&wc))
  752. return FALSE;
  753. /* register text class */
  754. if (!RegisterTextClass(hThisInstance))
  755. return FALSE;
  756. return TRUE;
  757. }
  758. /* Init one instance of the application */
  759. static BOOL local InitInstance(LPSTR lpCmdLine, INT nCmdShow)
  760. {
  761. RECT rText, rTB, rSTLN;
  762. HWND hWndTB, hWndSTLN;
  763. INT FontSize, FontWeight;
  764. CHAR FontName[256];
  765. /* Create frame window */
  766. hWndMain = FRAMECreateWindow (hThisInstance,
  767. appName,
  768. MainGUIWndProc,
  769. &PrevWndProc,
  770. NULL,
  771. "HugsFrameWindow",
  772. "RESIZECORNER",
  773. "BUTTON", "PUSHEDBUTTON");
  774. if (!hWndMain)
  775. return FALSE;
  776. /* Configure tools bar */
  777. hWndTB = FRAMEGetTB (hWndMain);
  778. GetClientRect(hWndTB, &rTB);
  779. TBAppendButton(hWndTB, ID_OPEN, "OPENFILEBUTTON", ID_OPEN, TRUE);
  780. TBAppendButton(hWndTB, ID_SCRIPTMAN, "SCRIPTMANBUTTON", ID_SCRIPTMAN, TRUE);
  781. TBAppendButton(hWndTB, MF_SEPARATOR, NULL, 0, 0);
  782. TBAppendButton(hWndTB, ID_CUT, "CUTBUTTON", ID_CUT, TRUE);
  783. TBAppendButton(hWndTB, ID_COPY, "COPYBUTTON", ID_COPY, TRUE);
  784. TBAppendButton(hWndTB, ID_PASTE, "PASTEBUTTON", ID_PASTE, TRUE);
  785. TBAppendButton(hWndTB, ID_CLEAR, "DELETEBUTTON", ID_CLEAR, TRUE);
  786. TBAppendButton(hWndTB, ID_GOEDIT, "EDITBUTTON", ID_GOEDIT, TRUE);
  787. TBAppendButton(hWndTB, MF_SEPARATOR, NULL, 0, 0);
  788. TBAppendButton(hWndTB, ID_RUN, "RUNBUTTON", ID_RUN, TRUE);
  789. TBAppendButton(hWndTB, ID_STOP, "STOPBUTTON", ID_STOP, TRUE);
  790. TBAppendButton(hWndTB, ID_MAKE, "MAKEBUTTON", ID_MAKE, TRUE);
  791. TBAppendButton(hWndTB, ID_SETOPTIONS, "OPTIONSBUTTON", ID_SETOPTIONS,TRUE);
  792. TBAppendButton(hWndTB, MF_SEPARATOR, NULL, 0, 0);
  793. TBAppendButton(hWndTB, ID_BROWSEHIERARCHY, "HIERARCHYBUTTON", ID_BROWSEHIERARCHY, TRUE);
  794. TBAppendButton(hWndTB, MF_SEPARATOR, NULL, 0, 0);
  795. TBAppendButton(hWndTB, ID_HELPINDEX, "HELPBUTTON", ID_HELPINDEX, TRUE);
  796. TBAppendButton(hWndTB, MF_SEPARATOR, NULL, 0, 0);
  797. TBAppendButton(hWndTB, ID_EXIT, "EXITBUTTON", ID_EXIT, TRUE);
  798. /* get status line */
  799. hWndSTLN = FRAMEGetSTLN(hWndMain);
  800. GetClientRect(hWndSTLN, &rSTLN);
  801. /* Load accelerators */
  802. hAccelTable = LoadAccelerators(hThisInstance, (LPSTR) "HugsAccelerators");
  803. /* create text window */
  804. GetFromRegistryFont(FontName, 256, &FontSize, &FontWeight);
  805. GetFromRegistryScreenSize(&ScreenRows, &ScreenCols);
  806. hWndText = CreateTextWindow(hThisInstance,
  807. hWndMain,
  808. rTB.right+2,
  809. 0 /*V_INDENT*/,
  810. ScreenCols, ScreenRows,
  811. FontName, FontSize, FontWeight,
  812. hAccelTable);
  813. if (!hWndText)
  814. return FALSE;
  815. GetWindowRect (hWndText, &rText);
  816. /* Atach text window to frame */
  817. FRAMESetChild(hWndMain, hWndText);
  818. /* Set main window size */
  819. FrameWinWidth = (rText.right-rText.left)+
  820. GetSystemMetrics(SM_CXFRAME)*2+
  821. GetSystemMetrics(SM_CXVSCROLL)+
  822. rTB.right+FRAMEGetRightBorderSize(hWndMain);
  823. FrameWinHeight = (rText.bottom-rText.top+1)+
  824. GetSystemMetrics(SM_CYFRAME)*2+
  825. GetSystemMetrics(SM_CYCAPTION)+
  826. GetSystemMetrics(SM_CYMENU)+
  827. rSTLN.bottom;
  828. GetFromRegistryScreenPosition(&FrameWinX, &FrameWinY);
  829. MoveWindow(hWndMain, FrameWinX, FrameWinY, FrameWinWidth, FrameWinHeight, FALSE);
  830. /* Show the Window */
  831. ShowWindow(hWndMain, nCmdShow);
  832. UpdateWindow(hWndMain);
  833. return TRUE;
  834. }
  835. /* --------------------------------------------------------------------------
  836. * Main Window WinProc:
  837. * ------------------------------------------------------------------------*/
  838. #define CALLPARENTCLASS ((LRESULT)CallWindowProc(PrevWndProc, hWnd, msg, wParam, lParam))
  839. LRESULT CALLBACK MainGUIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  840. {
  841. /* Check rest of messages */
  842. switch (msg) {
  843. case WM_CLOSE: DoClose(hWnd, msg, wParam, lParam);
  844. break;
  845. case WM_COMMAND: DoCommand(hWnd, msg, wParam, lParam);
  846. break;
  847. case WM_CREATE: return ((LRESULT) DoCreate(hWnd, msg, wParam, lParam));
  848. case WM_DESTROY: DoDestroy(hWnd, msg, wParam, lParam);
  849. break;
  850. case WM_DROPFILES: DoDropFiles(hWnd, msg, wParam, lParam);
  851. break;
  852. case WM_GETMINMAXINFO: DoGetMinMaxInfo(hWnd, msg, wParam, lParam);
  853. break;
  854. case WM_INITMENU: DoInitMenu(hWnd, msg, wParam, lParam);
  855. break;
  856. case WM_MOVE: DoMove(hWnd, msg, wParam, lParam);
  857. break;
  858. default: return CALLPARENTCLASS;
  859. }
  860. return CALLPARENTCLASS;
  861. }
  862. #undef CALLPARENTCLASS
  863. /* --------------------------------------------------------------------------
  864. * Dialogs procedures:
  865. * ------------------------------------------------------------------------*/
  866. LRESULT CALLBACK AboutDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  867. {
  868. HBITMAP hBitmap;
  869. switch (msg) {
  870. case WM_INITDIALOG: {
  871. CHAR Buffer[256];
  872. CenterDialogInParent(hDlg);
  873. SetDialogFont (hDlg, hDialogFont);
  874. {
  875. MEMORYSTATUS ms;
  876. ms.dwLength = sizeof(MEMORYSTATUS);
  877. GlobalMemoryStatus (&ms);
  878. wsprintf (Buffer, "Unkown");
  879. SetDlgItemText(hDlg, ID_FREERESOURCES, (LPCSTR)Buffer);
  880. wsprintf (Buffer, "%u KB",((UINT)ms.dwTotalPhys)/1024U);
  881. SetDlgItemText(hDlg, ID_TOTALMEMORY, (LPCSTR)Buffer);
  882. }
  883. }
  884. return TRUE;
  885. case WM_PAINT: {
  886. HDC hDC;
  887. PAINTSTRUCT Ps;
  888. BeginPaint(hDlg, &Ps);
  889. hDC = Ps.hdc;
  890. hBitmap = LoadMappedBitmap(hThisInstance, "LOGOBMP");
  891. DrawBitmap(hDC, hBitmap, 25, 40);
  892. DeleteObject(hBitmap);
  893. EndPaint(hDlg, &Ps);
  894. }
  895. break;
  896. case WM_COMMAND:
  897. switch (wParam) {
  898. case IDOK:
  899. EndDialog(hDlg, TRUE);
  900. return TRUE;
  901. default:
  902. return TRUE;
  903. }
  904. }
  905. return FALSE;
  906. }
  907. /* Handle options dialog box */
  908. LRESULT CALLBACK OptionsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  909. {
  910. INT i;
  911. switch (msg) {
  912. case WM_INITDIALOG: {
  913. CHAR Buffer[300];
  914. CenterDialogInParent(hDlg);
  915. SetDialogFont (hDlg, hDialogFont);
  916. SetDlgItemText(hDlg, ID_PROMPT, (LPCSTR) prompt);
  917. SetDlgItemText(hDlg, ID_LASTEXPR, (LPCSTR) repeatStr);
  918. SetDlgItemText(hDlg, ID_PATH, (LPCSTR) hugsPath);
  919. SetDlgItemText(hDlg, ID_EDITOR, (LPCSTR) hugsEdit);
  920. #if SUPPORT_PREPROCESSOR
  921. SetDlgItemText(hDlg, ID_PREPROCESSOR, (LPCSTR) preprocessor);
  922. #endif
  923. sprintf(Buffer, "%d", cutoff);
  924. SetDlgItemText(hDlg, ID_CUTOFF, (LPCSTR) Buffer);
  925. sprintf(Buffer, "%d", heapSize);
  926. SetDlgItemText(hDlg, ID_HEAPSIZE, (LPCSTR) Buffer);
  927. for(i=0; toggle[i].c; i++) {
  928. int j = 0;
  929. while (1) { /* look for DlgItem corresponding to flag */
  930. GetDlgItemText(hDlg, ID_OP+j, (LPSTR) Buffer, 1024);
  931. if (!(*Buffer))
  932. break;
  933. if (Buffer[1] == toggle[i].c) {
  934. if (!toggle[i].h98 && haskell98)
  935. EnableWindow(GetDlgItem(hDlg, ID_OP+j), FALSE);
  936. else
  937. CheckDlgButton(hDlg, ID_OP+j, *toggle[i].flag);
  938. break;
  939. }
  940. j++;
  941. }
  942. }
  943. /*
  944. for(i=0; toggle[i].c; i++)
  945. if (!toggle[i].h98 && haskell98)
  946. EnableWindow(GetDlgItem(hDlg, ID_OP+i), FALSE);
  947. else
  948. CheckDlgButton(hDlg, ID_OP+i, *toggle[i].flag);
  949. */
  950. return TRUE;
  951. }
  952. case WM_PAINT: {
  953. HDC hDC;
  954. PAINTSTRUCT Ps;
  955. HBITMAP hBitmap;
  956. RECT aRect, DlgRect;
  957. BeginPaint(hDlg, &Ps);
  958. hDC = Ps.hdc;
  959. /* Paint classes Bitmap */
  960. GetWindowRect(hDlg, &DlgRect);
  961. GetWindowRect(GetDlgItem(hDlg, ID_PLACEBITMAP), &aRect);
  962. hBitmap = LoadMappedBitmap(hThisInstance, "OPTIONSDLGBMP");
  963. DrawBitmap(hDC, hBitmap,
  964. aRect.left-DlgRect.left-GetSystemMetrics(SM_CXDLGFRAME),
  965. aRect.top-DlgRect.top-GetSystemMetrics(SM_CYDLGFRAME)-GetSystemMetrics(SM_CYCAPTION));
  966. DeleteObject(hBitmap);
  967. EndPaint(hDlg, &Ps);
  968. }
  969. break;
  970. case WM_COMMAND:
  971. switch (wParam) {
  972. case IDCANCEL:
  973. EndDialog(hDlg, TRUE);
  974. return FALSE;
  975. case IDOK: {
  976. CHAR Buffer[1024];
  977. GetDlgItemText(hDlg, ID_PROMPT, (LPSTR) Buffer, 1024);
  978. if (prompt) free(prompt);
  979. prompt = strCopy(Buffer);
  980. GetDlgItemText(hDlg, ID_LASTEXPR, (LPSTR) Buffer, 1024);
  981. if (repeatStr) free(repeatStr);
  982. repeatStr = strCopy(Buffer);
  983. GetDlgItemText(hDlg, ID_PATH, (LPSTR) Buffer, 1024);
  984. if (hugsPath) free(hugsPath);
  985. hugsPath = strCopy(Buffer);
  986. GetDlgItemText(hDlg, ID_EDITOR, (LPSTR) Buffer, 1024);
  987. if (hugsEdit) free(hugsEdit);
  988. hugsEdit = strCopy(Buffer);
  989. #if SUPPORT_PREPROCESSOR
  990. GetDlgItemText(hDlg, ID_PREPROCESSOR, (LPSTR) Buffer, 1024);
  991. if (preprocessor) free(preprocessor);
  992. preprocessor = strCopy(Buffer);
  993. #endif
  994. GetDlgItemText(hDlg, ID_CUTOFF, (LPSTR) Buffer, 1024);
  995. cutoff = argToInt(Buffer);
  996. GetDlgItemText(hDlg, ID_HEAPSIZE, (LPSTR) Buffer, 1024);
  997. setHeapSize(Buffer);
  998. for(i=0; toggle[i].c; i++) {
  999. int j = 0;
  1000. while (1) { /* look for DlgItem corresponding to flag */
  1001. GetDlgItemText(hDlg, ID_OP+j, (LPSTR) Buffer, 1024);
  1002. if (!(*Buffer))
  1003. break;
  1004. if ((Buffer[1] == toggle[i].c) && (toggle[i].h98 || !haskell98)) {
  1005. *toggle[i].flag = (Bool) IsDlgButtonChecked(hDlg, ID_OP+j);
  1006. break;
  1007. }
  1008. j++;
  1009. }
  1010. }
  1011. /*
  1012. for(i=0; toggle[i].c; i++)
  1013. if (toggle[i].h98 || !haskell98)
  1014. *toggle[i].flag = (Bool) IsDlgButtonChecked(hDlg, ID_OP+i);
  1015. */
  1016. writeRegString("Options", optionsToStr());
  1017. EndDialog(hDlg, TRUE);
  1018. return TRUE;
  1019. }
  1020. default:
  1021. return TRUE;
  1022. }
  1023. }
  1024. return FALSE;
  1025. }
  1026. /* --------------------------------------------------------------------------
  1027. * Script Manager:
  1028. * ------------------------------------------------------------------------*/
  1029. static INT smLoaded, smUpto;
  1030. static String smFile[NUM_SCRIPTS];
  1031. static INT selScr;
  1032. static Void local SmSelScr(HWND hDlg, Int i) {
  1033. selScr = i;
  1034. SendDlgItemMessage(hDlg, LB_SCRIPTS, LB_SETCURSEL, i, 0L);
  1035. }
  1036. static Void local SmAddScr(HWND hDlg, CHAR *s) {
  1037. smFile[smUpto] = strCopy(s);
  1038. fprintf(stdstr,"%s\n",smFile[smUpto]);
  1039. SendDlgItemMessage(hDlg, LB_SCRIPTS, LB_ADDSTRING, 0,
  1040. (LONG) (LPSTR) stdstrbuff);
  1041. SmSelScr(hDlg,smUpto);
  1042. smUpto++;
  1043. }
  1044. LRESULT CALLBACK ScriptManDlgProc(HWND hDlg, UINT msg,
  1045. WPARAM wParam, LPARAM lParam) {
  1046. switch (msg) {
  1047. case WM_INITDIALOG: {
  1048. Int i;
  1049. smLoaded = numLoadedScripts();
  1050. smUpto = 0;
  1051. CenterDialogInParent(hDlg);
  1052. SetDialogFont (hDlg, hDialogFont);
  1053. SendDlgItemMessage(hDlg, LB_SCRIPTS, LB_SETHORIZONTALEXTENT, (WPARAM)1000, 0L);
  1054. SendDlgItemMessage(hDlg, LB_SCRIPTS, WM_SETREDRAW,FALSE,0L);
  1055. for (i=0; i<getScriptHwMark(); i++)
  1056. SmAddScr(hDlg,getScriptRealName(i));
  1057. SmSelScr(hDlg,0);
  1058. SendDlgItemMessage(hDlg,LB_SCRIPTS,LB_SETCURSEL, 0, 0L);
  1059. SendDlgItemMessage(hDlg,LB_SCRIPTS,WM_SETREDRAW,TRUE,0L);
  1060. return TRUE;
  1061. }
  1062. case WM_PAINT: {
  1063. HDC hDC;
  1064. PAINTSTRUCT Ps;
  1065. HBITMAP hBitmap;
  1066. RECT aRect, DlgRect;
  1067. BeginPaint(hDlg, &Ps);
  1068. hDC = Ps.hdc;
  1069. /* Paint classes Bitmap */
  1070. GetWindowRect(hDlg, &DlgRect);
  1071. GetWindowRect(GetDlgItem(hDlg, ID_PLACEBITMAP), &aRect);
  1072. hBitmap = LoadMappedBitmap(hThisInstance, "SCRIPTMANDLGBMP");
  1073. DrawBitmap(hDC, hBitmap,
  1074. aRect.left-DlgRect.left-GetSystemMetrics(SM_CXDLGFRAME),
  1075. aRect.top-DlgRect.top-GetSystemMetrics(SM_CYDLGFRAME)-GetSystemMetrics(SM_CYCAPTION));
  1076. DeleteObject(hBitmap);
  1077. EndPaint(hDlg, &Ps);
  1078. }
  1079. break;
  1080. case WM_COMMAND:
  1081. switch (CMDitem(wParam,lParam)) {
  1082. case ID_ADDSCRIPT:
  1083. if (smUpto>=NUM_SCRIPTS)
  1084. MessageBox(hDlg,"Too many script files",
  1085. "Add script", MB_ICONEXCLAMATION|MB_OK);
  1086. else {
  1087. String s = GetaFileName(hDlg,IDS_FILTERFILE);
  1088. if (s)
  1089. SmAddScr(hDlg,s);
  1090. }
  1091. return TRUE;
  1092. case ID_DELSCRIPT:
  1093. if (selScr < 0)
  1094. MessageBox(hDlg,"No script file selected",
  1095. "Remove script", MB_ICONEXCLAMATION|MB_OK);
  1096. else if (selScr == 0)
  1097. MessageBox(hDlg,"Cannot remove prelude file",
  1098. "Remove script", MB_ICONEXCLAMATION|MB_OK);
  1099. else {
  1100. Int i;
  1101. SendDlgItemMessage(hDlg, LB_SCRIPTS, LB_DELETESTRING,
  1102. selScr, 0L);
  1103. if (selScr<smLoaded)
  1104. smLoaded = selScr;
  1105. if (smFile[selScr]) {
  1106. free(smFile[selScr]);
  1107. smFile[selScr] = 0;
  1108. }
  1109. for (i=selScr+1; i<smUpto; ++i)
  1110. smFile[i-1] = smFile[i];
  1111. smUpto--;
  1112. SmSelScr(hDlg,-1);
  1113. }
  1114. return TRUE;
  1115. case ID_EDITSCRIPT:
  1116. if (selScr >= 0)
  1117. DlgSendMessage(hDlg, WM_COMMAND, LB_SCRIPTS, MAKELONG(0, LBN_DBLCLK));
  1118. else
  1119. MessageBox(hDlg,"No file selected","Edit",
  1120. MB_ICONEXCLAMATION|MB_OK);
  1121. return TRUE;
  1122. case ID_CLEARSCRIPTS: {
  1123. Int i;
  1124. for (i=1; i<smUpto; ++i)
  1125. if (smFile[i])
  1126. free(smFile[i]);
  1127. smUpto = smLoaded = 1;
  1128. SendDlgItemMessage(hDlg,LB_SCRIPTS,LB_RESETCONTENT,0,0L);
  1129. fprintf(stdstr,"%s\n",smFile[0]);
  1130. SendDlgItemMessage(hDlg, LB_SCRIPTS, LB_ADDSTRING, 0,
  1131. (LONG) (LPSTR) stdstrbuff);
  1132. SmSelScr(hDlg,-1);
  1133. return TRUE;
  1134. }
  1135. case LB_SCRIPTS:
  1136. switch (CMDdata(wParam,lParam)) {
  1137. case LBN_SELCHANGE:
  1138. SmSelScr(hDlg,(Int)SendDlgItemMessage(hDlg,
  1139. LB_SCRIPTS,
  1140. LB_GETCURSEL,
  1141. 0, 0L));
  1142. return TRUE;
  1143. case LBN_DBLCLK: {
  1144. char buffer[_MAX_PATH];
  1145. SendDlgItemMessage(hDlg,
  1146. LB_SCRIPTS,
  1147. LB_GETTEXT,
  1148. selScr,
  1149. (LPARAM) (LPSTR) buffer);
  1150. setLastEdit((String)buffer,0);
  1151. runEditor();
  1152. return TRUE;
  1153. }
  1154. }
  1155. break;
  1156. case IDOK: {
  1157. Int i;
  1158. /* Sigh, script stack hackery. */
  1159. for (i=0; i<getScriptHwMark(); i++)
  1160. if (getScriptName(i)) {
  1161. free(getScriptName(i));
  1162. free(getScriptRealName(i));
  1163. }
  1164. for (i=0; i<smUpto; i++) {
  1165. setScriptName(i,smFile[i]);
  1166. setScriptRealName(i,strCopy(RealPath(smFile[i])));
  1167. smFile[i] = 0;
  1168. }
  1169. setScriptHwMark(smUpto);
  1170. setNumLoadedScripts(smLoaded);
  1171. dropScriptsFrom(smLoaded-1);
  1172. PostMessage(hWndMain,WM_COMMAND,ID_COMPILE,0L);
  1173. EndDialog(hDlg,TRUE);
  1174. return TRUE;
  1175. }
  1176. case IDCANCEL: {
  1177. Int i;
  1178. for (i=0; i<smUpto; i++)
  1179. if (smFile[i])
  1180. free(smFile[i]);
  1181. EndDialog(hDlg, TRUE);
  1182. return TRUE;
  1183. }
  1184. }
  1185. break;
  1186. }
  1187. return FALSE;
  1188. }
  1189. /* --------------------------------------------------------------------------
  1190. * Manages Adding file names to Menus:
  1191. * ------------------------------------------------------------------------*/
  1192. #define SUBMENU(x) ((x)-1)
  1193. static VOID local InitFileNamesMenu(WORD MenuId, WORD FirstMenuId, FILENAMESMENU* fnm)
  1194. {
  1195. UINT i;
  1196. fnm->MenuId = MenuId;
  1197. fnm->FirstMenuId = FirstMenuId;
  1198. for (i=0;i<FILES_TO_REMEMBER;i++) {
  1199. fnm->FileNames[i][0] = (CHAR) 0;
  1200. }
  1201. fnm->Length = 0;
  1202. }
  1203. static CHAR local *GetFileNameFromFileNamesMenu (FILENAMESMENU* fnm, UINT i)
  1204. {
  1205. if (i<fnm->Length) {
  1206. return fnm->FileNames[i];
  1207. }
  1208. else {
  1209. return NULL;
  1210. }
  1211. }
  1212. VOID AddFileToFileNamesMenu(FILENAMESMENU* fnm, LPSTR NewFileName)
  1213. {
  1214. HMENU hMainMenu, hFilesSubMenu;
  1215. CHAR shortFName[_MAX_PATH], MenuContents[_MAX_PATH];
  1216. UINT i, Up;
  1217. hMainMenu = GetMenu(hWndMain);
  1218. hFilesSubMenu = GetSubMenu(hMainMenu, SUBMENU(fnm->MenuId));
  1219. Up = fnm->Length-1;
  1220. /* Check if the file is already added */
  1221. for (i=0; i<fnm->Length; i++) {
  1222. if (!stricmp(NewFileName, fnm->FileNames[i])) {
  1223. /* move it to the first position */
  1224. Up = i;
  1225. goto shift;
  1226. }
  1227. }
  1228. /* If there are less of FILES_TO_REMEMBER menu items, add one at first position */
  1229. if (fnm->Length < FILES_TO_REMEMBER) {
  1230. fnm->Length++;
  1231. Up++;
  1232. AppendMenu(hFilesSubMenu, MF_ENABLED, fnm->FirstMenuId+fnm->Length, "");
  1233. }
  1234. shift:
  1235. /* Shift file names down */
  1236. for (i=Up; i>0; i--) {
  1237. strcpy(fnm->FileNames[i], fnm->FileNames[i-1]);
  1238. ShortFileName(fnm->FileNames[i],shortFName);
  1239. wsprintf (MenuContents, "&%d %s", i, shortFName);
  1240. ModifyMenu(hFilesSubMenu, fnm->FirstMenuId+i+1, MF_BYCOMMAND, fnm->FirstMenuId+i+1, (LPCSTR)MenuContents);
  1241. }
  1242. /* Add new file */
  1243. ShortFileName(NewFileName,shortFName);
  1244. wsprintf (MenuContents, "&%d %s", 0, shortFName);
  1245. ModifyMenu(hFilesSubMenu, fnm->FirstMenuId+1, MF_BYCOMMAND, fnm->FirstMenuId+1, (LPCSTR)MenuContents);
  1246. strcpy(fnm->FileNames[0], NewFileName);
  1247. }
  1248. static VOID local SaveToRegistryFileNamesMenu (FILENAMESMENU* fnm, LPSTR Section)
  1249. {
  1250. HMENU hMainMenu, hFilesSubMenu;
  1251. CHAR Buffer[_MAX_PATH], Entry[256];
  1252. UINT i, Total;
  1253. hMainMenu = GetMenu(hWndMain);
  1254. hFilesSubMenu = GetSubMenu(hMainMenu, SUBMENU(fnm->MenuId));
  1255. for (i=0; i<fnm->Length; i++) {
  1256. wsprintf(Entry, "%s File%d", Section, fnm->Length-i-1);
  1257. writeRegString(Entry, fnm->FileNames[i]);
  1258. }
  1259. }
  1260. /* loads files added to a menu from the registry */
  1261. static VOID local GetFromRegistryFileNamesMenu (FILENAMESMENU* fnm, LPSTR Section)
  1262. {
  1263. HMENU hMainMenu, hFilesSubMenu;
  1264. CHAR Entry[256];
  1265. String Buffer;
  1266. UINT i, Total;
  1267. hMainMenu = GetMenu(hWndMain);
  1268. hFilesSubMenu = GetSubMenu(hMainMenu, SUBMENU(fnm->MenuId));
  1269. /* Delete current entries, if any */
  1270. for (i=0; i<fnm->Length; i++) {
  1271. DeleteMenu(hFilesSubMenu, fnm->FirstMenuId+i+1, MF_BYCOMMAND);
  1272. }
  1273. for (i=0;;i++) {
  1274. wsprintf(Entry, "%s File%d", Section, i);
  1275. Buffer=readRegString(HKEY_CURRENT_USER,hugsRegRoot,Entry, "");
  1276. if ( Buffer[0] ) {
  1277. AddFileToFileNamesMenu(fnm, Buffer);
  1278. free(Buffer);
  1279. } else {
  1280. free(Buffer);
  1281. break;
  1282. }
  1283. }
  1284. }
  1285. FILENAMESMENU FilesMenu, EditMenu;
  1286. static VOID local InitMenus(VOID) {
  1287. InitFileNamesMenu(ID_FILESMENU, ID_EXIT, &FilesMenu);
  1288. InitFileNamesMenu(ID_EDITMENU, ID_EDITSELECTED, &EditMenu);
  1289. }
  1290. /* --------------------------------------------------------------------------
  1291. * Loading and saving options to registry:
  1292. * ------------------------------------------------------------------------*/
  1293. #define RKEY_DOCPATH "Doc Path"
  1294. #define RKEY_SCREENROWS "Screen Rows"
  1295. #define RKEY_SCREENCOLS "Screen Cols"
  1296. #define RKEY_SCREENFONTNAME "Screen Font Name"
  1297. #define RKEY_SCREENFONTSIZE "Screen Font Size"
  1298. #define RKEY_SCREENFONTWEIGHT "Screen Font Weight"
  1299. #define RKEY_DIALOGSFONTNAME "Dialogs Font Name"
  1300. #define RKEY_DIALOGSFONTSIZE "Dialogs Font Size"
  1301. #define RKEY_LASTPATH "LastPath"
  1302. #define RKEY_POSX "Screen PosX"
  1303. #define RKEY_POSY "Screen PosY"
  1304. #define RKEY_FILESMENU "Files Menu"
  1305. #define RKEY_EDITSMENU "Edit Menu"
  1306. static int GetFromRegistryDocPath(char *realPath, int pathLen)
  1307. {
  1308. String hugsdir_ = hugsdir(); /* static, not freeable. */
  1309. String regPath = readRegString(HKEY_CURRENT_USER,hugsRegRoot,RKEY_DOCPATH, DEFAULT_DOC_DIR);
  1310. INT rlen,hlen;
  1311. INT flen = sizeof("{Hugs}") - 1;
  1312. if (!regPath) {
  1313. goto NoResult;
  1314. }
  1315. /* Expand "{Hugs}" but only at the beginning of the string, avoiding
  1316. * buffer overflows in the process.
  1317. */
  1318. rlen = strlen(regPath);
  1319. hlen = strlen(hugsdir_);
  1320. if ( (rlen > pathLen) ) {
  1321. /* {Hugs} or not, no way the result is going to fit. */
  1322. free(regPath);
  1323. goto NoResult;
  1324. }
  1325. if (strncmp ("{Hugs}", regPath, flen) == 0) {
  1326. if ( ((rlen + (hlen - flen)) > pathLen) ) {
  1327. free(regPath);
  1328. goto NoResult;
  1329. }
  1330. strcpy(realPath,hugsdir_);
  1331. strcat(realPath,regPath+flen);
  1332. } else {
  1333. strcpy(realPath,regPath);
  1334. }
  1335. free(regPath);
  1336. return 1;
  1337. NoResult:
  1338. *realPath = '\0';
  1339. return 0;
  1340. }
  1341. static VOID local GetFromRegistryFont(CHAR *FontName, INT FontNameLen, INT *FontSize, INT* FontWeight)
  1342. {
  1343. String opt = readRegString(HKEY_CURRENT_USER,hugsRegRoot,RKEY_SCREENFONTNAME, DEFAULT_FONT);
  1344. strncpy(FontName, opt, FontNameLen);
  1345. free(opt);
  1346. *FontSize = readRegInt(RKEY_SCREENFONTSIZE, DEFAULT_FONT_SIZE);
  1347. *FontWeight = readRegInt(RKEY_SCREENFONTWEIGHT, DEFAULT_FONT_WEIGHT);
  1348. }
  1349. static VOID local GetFromRegistryDialogFont(CHAR *FontName, INT FontNameLen, INT *FontSize)
  1350. {
  1351. String opt = readRegString(HKEY_CURRENT_USER,hugsRegRoot,RKEY_DIALOGSFONTNAME, DEFAULT_DIALOGFONT);
  1352. strncpy(FontName, opt, FontNameLen);
  1353. *FontSize = readRegInt(RKEY_DIALOGSFONTSIZE, DEFAULT_DIALOGFONT_SIZE);
  1354. free(opt);
  1355. }
  1356. static VOID local GetFromRegistryScreenSize(INT *Rows, INT *Cols)
  1357. {
  1358. *Rows = readRegInt(RKEY_SCREENROWS, DEFAULT_ROWS);
  1359. *Cols = readRegInt(RKEY_SCREENCOLS, DEFAULT_COLS);
  1360. }
  1361. static VOID local GetFromRegistryScreenPosition(INT *X, INT *Y)
  1362. {
  1363. *X = readRegInt(RKEY_POSX, 0);
  1364. *X = min(GetSystemMetrics(SM_CXFULLSCREEN)-40, *X);
  1365. *Y = readRegInt(RKEY_POSY, 0);
  1366. *Y = min(GetSystemMetrics(SM_CYFULLSCREEN)-40, *Y);
  1367. }
  1368. VOID ReadGUIOptions(VOID)
  1369. {
  1370. /* Get last working dir and set it */
  1371. String opt = readRegString(HKEY_CURRENT_USER,hugsRegRoot,RKEY_LASTPATH, ".\\");
  1372. SetWorkingDir(opt);
  1373. free(opt);
  1374. /* load menus */
  1375. GetFromRegistryFileNamesMenu(&FilesMenu, RKEY_FILESMENU);
  1376. GetFromRegistryFileNamesMenu(&EditMenu, RKEY_EDITSMENU);
  1377. }
  1378. VOID SaveGUIOptions(VOID)
  1379. {
  1380. String opt = readRegString(HKEY_CURRENT_USER,hugsRegRoot,RKEY_DOCPATH, DEFAULT_DOC_DIR);
  1381. writeRegString(RKEY_DOCPATH, opt);
  1382. free(opt);
  1383. writeRegString("Options", optionsToStr());
  1384. /* calculate rows and columns */
  1385. if (!IsIconic(hWndMain) && !IsZoomed(hWndMain)) {
  1386. RECT aRect;
  1387. TEXTMETRIC *tm = (TEXTMETRIC*) SendMessage (hWndText, WM_GETTEXTMETRIC, 0, 0L);
  1388. GetClientRect(hWndText, &aRect);
  1389. ScreenRows = (INT) (aRect.bottom-aRect.top) / (tm->tmHeight+tm->tmExternalLeading);
  1390. ScreenCols = (INT) (aRect.right-aRect.left) / (tm->tmAveCharWidth);
  1391. }
  1392. writeRegInt(RKEY_SCREENROWS, ScreenRows);
  1393. writeRegInt(RKEY_SCREENCOLS, ScreenCols);
  1394. { LOGFONT *LogFontPtr;
  1395. HDC hDC;
  1396. INT FontSize;
  1397. LogFontPtr = (LOGFONT*) SendMessage (hWndText, WM_GETLOGFONT, 0, 0L);
  1398. hDC = GetDC(hWndText);
  1399. FontSize = -MulDiv(LogFontPtr->lfHeight, 72, GetDeviceCaps(hDC, LOGPIXELSY));
  1400. ReleaseDC(hWndText, hDC);
  1401. writeRegInt(RKEY_SCREENFONTSIZE, FontSize);
  1402. writeRegInt(RKEY_SCREENFONTWEIGHT, LogFontPtr->lfWeight);
  1403. writeRegString(RKEY_SCREENFONTNAME, LogFontPtr->lfFaceName);
  1404. }
  1405. {
  1406. INT DialogFontSize;
  1407. CHAR DialogFontName[256];
  1408. GetFromRegistryDialogFont(DialogFontName, 256, &DialogFontSize);
  1409. writeRegInt(RKEY_DIALOGSFONTSIZE, DialogFontSize);
  1410. writeRegString(RKEY_DIALOGSFONTNAME, DialogFontName);
  1411. }
  1412. SaveToRegistryWinPos();
  1413. SaveToRegistryMenus();
  1414. SaveToRegistryWorkingDir();
  1415. }
  1416. /* save current working dir */
  1417. static VOID local SaveToRegistryWorkingDir(VOID)
  1418. {
  1419. CHAR Path[_MAX_PATH];
  1420. CHAR Buffer[_MAX_PATH];
  1421. _getcwd(Path, _MAX_PATH);
  1422. wsprintf(Buffer, "%s\\", Path);
  1423. writeRegString(RKEY_LASTPATH, Buffer);
  1424. }
  1425. /* Save Windows current position to registry */
  1426. static VOID local SaveToRegistryWinPos(VOID)
  1427. {
  1428. writeRegInt(RKEY_POSX, FrameWinX);
  1429. writeRegInt(RKEY_POSY, FrameWinY);
  1430. }
  1431. /* save file names in menus */
  1432. static VOID local SaveToRegistryMenus()
  1433. {
  1434. SaveToRegistryFileNamesMenu(&FilesMenu, RKEY_FILESMENU);
  1435. SaveToRegistryFileNamesMenu(&EditMenu, RKEY_EDITSMENU);
  1436. }
  1437. /* --------------------------------------------------------------------------
  1438. * Evaluator code
  1439. * ------------------------------------------------------------------------*/
  1440. Bool InAutoReloadFiles = FALSE; /* TRUE =>loading files before eval*/
  1441. Bool autoLoadFiles = FALSE; /* TRUE => automatical…

Large files files are truncated, but you can click here to view the full file