fp.pas 12 KB

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