fp.pas 14 KB

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