fp.pas 15 KB

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