fp.pas 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998-2000 by Berczi Gabor
  5. Main program of the IDE
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. program FP;
  13. {$I globdir.inc}
  14. (**********************************************************************)
  15. (* CONDITIONAL DEFINES *)
  16. (* - NODEBUG No Debugging support *)
  17. (* - TP Turbo Pascal mode *)
  18. (* - i386 Target is an i386 IDE *)
  19. (**********************************************************************)
  20. uses
  21. {$ifdef IDEHeapTrc}
  22. HeapTrc,
  23. {$endif IDEHeapTrc}
  24. {$ifdef go32v2}
  25. dpmiexcp,
  26. {$endif go32v2}
  27. Dos,Objects,
  28. BrowCol,
  29. Drivers,Views,App,Dialogs,ColorSel,Menus,StdDlg,Validate,
  30. {$ifdef EDITORS}Editors{$else}WEditor,WCEdit{$endif},
  31. ASCIITab,Calc,
  32. WUtils,WViews,WHTMLScn,
  33. FPIDE,FPCalc,FPCompil,
  34. FPIni,FPViews,FPConst,FPVars,FPUtils,FPHelp,FPSwitch,FPUsrScr,
  35. FPTools,{$ifndef NODEBUG}FPDebug,{$endif}FPTemplt,FPCatch,FPRedir,FPDesk,
  36. FPCodTmp,FPCodCmp;
  37. procedure ProcessParams(BeforeINI: boolean);
  38. function IsSwitch(const Param: string): boolean;
  39. begin
  40. IsSwitch:=(Param<>'') and (Param[1]<>DirSep) { <- allow UNIX root-relative paths }
  41. and (Param[1] in ['-','/']); { <- but still accept dos switch char, eg. '/' }
  42. end;
  43. var I: Sw_integer;
  44. Param: string;
  45. begin
  46. for I:=1 to ParamCount do
  47. begin
  48. Param:=System.ParamStr(I);
  49. if IsSwitch(Param) then
  50. begin
  51. Param:=copy(Param,2,255);
  52. if Param<>'' then
  53. if UpcaseStr(copy(Param,1,2))='HM' then
  54. { HeapMonitor }
  55. begin
  56. if (copy(Param,3,1)='+') or (copy(Param,3,1)='') then
  57. StartupOptions:=StartupOptions or soHeapMonitor
  58. else
  59. if (copy(Param,3,1)='-') then
  60. StartupOptions:=StartupOptions and not soHeapMonitor;
  61. end else
  62. {$ifdef go32v2}
  63. if UpcaseStr(Param)='NOLFN' then
  64. begin
  65. LFNSupport:=false;
  66. end else
  67. {$endif go32v2}
  68. if UpcaseStr(Param)='README' then
  69. begin
  70. ShowReadme:=true;
  71. end else
  72. case Upcase(Param[1]) of
  73. 'C' : { custom config file (BP compatiblity) }
  74. if BeforeINI then
  75. begin
  76. if (length(Param)>=1) and (Param[1] in['=',':']) then
  77. Delete(Param,1,1); { eat separator }
  78. IniFileName:=Param;
  79. end;
  80. 'R' : { enter the directory last exited from (BP comp.) }
  81. begin
  82. Param:=copy(Param,2,255);
  83. if (Param='') or (Param='+') then
  84. StartupOptions:=StartupOptions or soReturnToLastDir
  85. else
  86. if (Param='-') then
  87. StartupOptions:=StartupOptions and (not soReturnToLastDir);
  88. end;
  89. 'S' :
  90. if Length(Param)=1 then
  91. begin
  92. UseMouse:=false;
  93. ButtonCount:=0;
  94. end;
  95. end;
  96. end
  97. else
  98. if not BeforeINI then
  99. TryToOpenFile(nil,Param,0,0,{false}true);
  100. end;
  101. end;
  102. Procedure MyStreamError(Var S: TStream); {$ifndef FPC}far;{$endif}
  103. var ErrS: string;
  104. begin
  105. case S.Status of
  106. stGetError : ErrS:='Get of unregistered object type';
  107. stPutError : ErrS:='Put of unregistered object type';
  108. else ErrS:='';
  109. end;
  110. if ErrS<>'' then
  111. begin
  112. {$ifdef GABOR}{$ifdef TP}asm int 3;end;{$endif}{$endif}
  113. if Assigned(Application) then
  114. ErrorBox('Stream error: '+#13+ErrS,nil)
  115. else
  116. writeln('Error: ',ErrS);
  117. end;
  118. end;
  119. procedure DelTempFiles;
  120. begin
  121. DeleteFile(FPOutFileName);
  122. DeleteFile(FPErrFileName);
  123. DeleteFile(GDBOutFileName);
  124. DeleteFile(GDBOutPutFileName);
  125. DeleteFile(GREPOutName);
  126. DeleteFile(GREPErrName);
  127. end;
  128. procedure RegisterIDEObjects;
  129. begin
  130. RegisterApp;
  131. RegisterAsciiTab;
  132. RegisterCalc;
  133. RegisterCodeComplete;
  134. RegisterCodeTemplates;
  135. RegisterColorSel;
  136. RegisterDialogs;
  137. {$ifdef EDITORS}
  138. RegisterEditors;
  139. {$else}
  140. RegisterWEditor;
  141. RegisterWCEdit;
  142. {$endif}
  143. RegisterFPCalc;
  144. RegisterFPCompile;
  145. RegisterFPTools;
  146. RegisterFPViews;
  147. {$ifndef NODEBUG}
  148. RegisterFPDebugViews;
  149. {$endif}
  150. RegisterMenus;
  151. RegisterStdDlg;
  152. RegisterSymbols;
  153. RegisterObjects;
  154. RegisterValidate;
  155. RegisterViews;
  156. RegisterWHTMLScan;
  157. RegisterWUtils;
  158. RegisterWViews;
  159. end;
  160. var CanExit : boolean;
  161. BEGIN
  162. {$ifdef DEV}HeapLimit:=4096;{$endif}
  163. writeln('þ Free Pascal IDE Version '+VersionStr);
  164. ProcessParams(true);
  165. StartupDir:=CompleteDir(FExpand('.'));
  166. IDEDir:=CompleteDir(DirOf(system.Paramstr(0)));
  167. RegisterIDEObjects;
  168. StreamError:=@MyStreamError;
  169. ShowReadme:=ShowReadme or (LocateFile(INIFileName)='');
  170. {$ifdef win32}
  171. DosExecute(GetEnv('COMSPEC'),'/C echo This dummy call gets the mouse to become visible');
  172. {$endif win32}
  173. {$ifdef VESA}
  174. InitVESAScreenModes;
  175. {$endif}
  176. InitRedir;
  177. {$ifndef NODEBUG}
  178. InitBreakpoints;
  179. InitWatches;
  180. {$endif}
  181. InitReservedWords;
  182. InitHelpFiles;
  183. InitSwitches;
  184. InitINIFile;
  185. InitUserScreen;
  186. InitTools;
  187. InitTemplates;
  188. InitCodeTemplates;
  189. InitCodeComplete;
  190. IDEApp.Init;
  191. CheckINIFile;
  192. ReadSwitches(SwitchesPath);
  193. { load all options after init because of open files }
  194. ReadINIFile;
  195. InitDesktopFile;
  196. LoadDesktop;
  197. ParseUserScreen;
  198. { why are the screen contents parsed at startup? Gabor }
  199. { Update IDE }
  200. IDEApp.Update;
  201. IDEApp.UpdateMode;
  202. IDEApp.UpdateTarget;
  203. ProcessParams(false);
  204. if ShowReadme then
  205. begin
  206. PutCommand(Application,evCommand,cmShowReadme,nil);
  207. ShowReadme:=false; { do not show next time }
  208. end;
  209. repeat
  210. IDEApp.Run;
  211. if (AutoSaveOptions and asEditorFiles)=0 then
  212. CanExit:=IDEApp.AskSaveAll
  213. else
  214. CanExit:=IDEApp.SaveAll;
  215. until CanExit;
  216. IDEApp.AutoSave;
  217. DoneDesktopFile;
  218. DelTempFiles;
  219. IDEApp.Done;
  220. WriteSwitches(SwitchesPath);
  221. DoneCodeComplete;
  222. DoneCodeTemplates;
  223. DoneTemplates;
  224. DoneTools;
  225. DoneUserScreen;
  226. DoneSwitches;
  227. DoneHelpFiles;
  228. DoneReservedWords;
  229. ClearToolMessages;
  230. DoneBrowserCol;
  231. {$ifndef NODEBUG}
  232. DoneDebugger;
  233. DoneBreakpoints;
  234. DoneWatches;
  235. {$endif}
  236. StreamError:=nil;
  237. END.
  238. {
  239. $Log$
  240. Revision 1.3 2000-10-01 22:44:18 pierre
  241. * remove lineinfo in _USES
  242. Revision 1.2 2000/08/22 09:41:39 pierre
  243. * first big merge from fixes branch
  244. Revision 1.1.2.2 2000/08/16 18:46:14 peter
  245. [*] double clicking on a droplistbox caused GPF (due to invalid recurson)
  246. [*] Make, Build now possible even in Compiler Messages Window
  247. [+] when started in a new dir the IDE now ask whether to create a local
  248. config, or to use the one located in the IDE dir
  249. Revision 1.1.2.1 2000/07/18 05:50:22 michael
  250. + Merged Gabors fixes
  251. Revision 1.1 2000/07/13 09:48:34 michael
  252. + Initial import
  253. Revision 1.47 2000/06/16 08:50:40 pierre
  254. + new bunch of Gabor's changes
  255. Revision 1.46 2000/05/29 10:44:56 pierre
  256. + New bunch of Gabor's changes: see fixes.txt
  257. Revision 1.45 2000/05/02 08:42:26 pierre
  258. * new set of Gabor changes: see fixes.txt
  259. Revision 1.44 2000/04/25 08:42:32 pierre
  260. * New Gabor changes : see fixes.txt
  261. Revision 1.43 2000/04/18 11:42:36 pierre
  262. lot of Gabor changes : see fixes.txt
  263. Revision 1.42 2000/03/21 23:34:10 pierre
  264. adapted to wcedit addition by Gabor
  265. Revision 1.41 2000/03/13 20:41:34 pierre
  266. + option -S to disable the mouse
  267. * adapted to changes in fpusrscr for DOS
  268. Revision 1.40 2000/03/07 21:58:58 pierre
  269. + uses ParseUserScreen and UpdateMode
  270. Revision 1.39 2000/02/12 23:58:26 carl
  271. + Conditional define explanaations
  272. Revision 1.38 2000/02/07 11:54:17 pierre
  273. + RegisterWUtils by Gabor
  274. Revision 1.37 2000/01/25 00:26:35 pierre
  275. + Browser info saving
  276. Revision 1.36 2000/01/10 15:53:37 pierre
  277. * WViews objects were not registered
  278. Revision 1.35 2000/01/03 11:38:33 michael
  279. Changes from Gabor
  280. Revision 1.34 1999/12/20 14:23:16 pierre
  281. * MyApp renamed IDEApp
  282. * TDebugController.ResetDebuggerRows added to
  283. get resetting of debugger rows
  284. Revision 1.33 1999/12/20 09:36:49 pierre
  285. * get the mouse visible on win32 fp
  286. Revision 1.32 1999/12/10 13:02:05 pierre
  287. + VideoMode save/restore
  288. Revision 1.31 1999/09/13 11:43:59 peter
  289. * fixes from gabor, idle event, html fix
  290. Revision 1.30 1999/08/22 22:24:15 pierre
  291. * avoid objpas paramstr functions
  292. Revision 1.29 1999/08/03 20:22:25 peter
  293. + TTab acts now on Ctrl+Tab and Ctrl+Shift+Tab...
  294. + Desktop saving should work now
  295. - History saved
  296. - Clipboard content saved
  297. - Desktop saved
  298. - Symbol info saved
  299. * syntax-highlight bug fixed, which compared special keywords case sensitive
  300. (for ex. 'asm' caused asm-highlighting, while 'ASM' didn't)
  301. * with 'whole words only' set, the editor didn't found occourences of the
  302. searched text, if the text appeared previously in the same line, but didn't
  303. satisfied the 'whole-word' condition
  304. * ^QB jumped to (SelStart.X,SelEnd.X) instead of (SelStart.X,SelStart.Y)
  305. (ie. the beginning of the selection)
  306. * when started typing in a new line, but not at the start (X=0) of it,
  307. the editor inserted the text one character more to left as it should...
  308. * TCodeEditor.HideSelection (Ctrl-K+H) didn't update the screen
  309. * Shift shouldn't cause so much trouble in TCodeEditor now...
  310. * Syntax highlight had problems recognizing a special symbol if it was
  311. prefixed by another symbol character in the source text
  312. * Auto-save also occours at Dos shell, Tool execution, etc. now...
  313. Revision 1.28 1999/07/10 01:24:11 pierre
  314. + First implementation of watches window
  315. Revision 1.27 1999/06/29 22:43:12 peter
  316. * try to add extensions to params
  317. Revision 1.26 1999/06/28 23:31:14 pierre
  318. * typo inside go32v2 cond error removed
  319. Revision 1.25 1999/06/28 19:25:34 peter
  320. * fixes from gabor
  321. Revision 1.24 1999/06/28 12:40:56 pierre
  322. + clear tool messages at exit
  323. Revision 1.23 1999/06/25 00:48:05 pierre
  324. + adds current target in menu at startup
  325. Revision 1.22 1999/05/22 13:44:28 peter
  326. * fixed couple of bugs
  327. Revision 1.21 1999/04/07 21:55:40 peter
  328. + object support for browser
  329. * html help fixes
  330. * more desktop saving things
  331. * NODEBUG directive to exclude debugger
  332. Revision 1.20 1999/03/23 16:16:36 peter
  333. * linux fixes
  334. Revision 1.19 1999/03/23 15:11:26 peter
  335. * desktop saving things
  336. * vesa mode
  337. * preferences dialog
  338. Revision 1.18 1999/03/21 22:51:35 florian
  339. + functional screen mode switching added
  340. Revision 1.17 1999/03/16 12:38:06 peter
  341. * tools macro fixes
  342. + tph writer
  343. + first things for resource files
  344. Revision 1.16 1999/03/12 01:13:01 peter
  345. * use TryToOpen() with parameter files to overcome double opened files
  346. at startup
  347. Revision 1.15 1999/03/08 14:58:08 peter
  348. + prompt with dialogs for tools
  349. Revision 1.14 1999/03/05 17:53:00 pierre
  350. + saving and opening of open files on exit
  351. Revision 1.13 1999/03/01 15:41:48 peter
  352. + Added dummy entries for functions not yet implemented
  353. * MenuBar didn't update itself automatically on command-set changes
  354. * Fixed Debugging/Profiling options dialog
  355. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  356. set
  357. * efBackSpaceUnindents works correctly
  358. + 'Messages' window implemented
  359. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  360. + Added TP message-filter support (for ex. you can call GREP thru
  361. GREP2MSG and view the result in the messages window - just like in TP)
  362. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  363. so topic search didn't work...
  364. * In FPHELP.PAS there were still context-variables defined as word instead
  365. of THelpCtx
  366. * StdStatusKeys() was missing from the statusdef for help windows
  367. + Topic-title for index-table can be specified when adding a HTML-files
  368. Revision 1.12 1999/02/20 15:18:25 peter
  369. + ctrl-c capture with confirm dialog
  370. + ascii table in the tools menu
  371. + heapviewer
  372. * empty file fixed
  373. * fixed callback routines in fpdebug to have far for tp7
  374. Revision 1.11 1999/02/18 13:44:30 peter
  375. * search fixed
  376. + backward search
  377. * help fixes
  378. * browser updates
  379. Revision 1.10 1999/02/15 09:07:10 pierre
  380. * HEAPTRC conditionnal renamed IDEHEAPTRC
  381. Revision 1.9 1999/02/10 09:55:43 pierre
  382. + Memory tracing if compiled with -dHEAPTRC
  383. * Many memory leaks removed
  384. Revision 1.8 1999/02/08 09:30:59 florian
  385. + some split heap stuff, in $ifdef TEMPHEAP
  386. Revision 1.7 1999/02/05 13:51:38 peter
  387. * unit name of FPSwitches -> FPSwitch which is easier to use
  388. * some fixes for tp7 compiling
  389. Revision 1.6 1999/01/21 11:54:10 peter
  390. + tools menu
  391. + speedsearch in symbolbrowser
  392. * working run command
  393. Revision 1.5 1999/01/12 14:29:31 peter
  394. + Implemented still missing 'switch' entries in Options menu
  395. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  396. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  397. ASCII chars and inserted directly in the text.
  398. + Added symbol browser
  399. * splitted fp.pas to fpide.pas
  400. }