fp.pas 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. uses
  15. {$ifdef IDEHeapTrc}
  16. HeapTrc,
  17. {$endif IDEHeapTrc}
  18. Dos,Objects,
  19. BrowCol,
  20. Views,App,Dialogs,ColorSel,Menus,StdDlg,Validate,
  21. {$ifdef EDITORS}Editors{$else}WEditor{$endif},
  22. ASCIITab,Calc,
  23. WViews,
  24. FPIDE,FPCalc,FPCompile,
  25. FPIni,FPViews,FPConst,FPVars,FPUtils,FPHelp,FPSwitch,FPUsrScr,
  26. FPTools,{$ifndef NODEBUG}FPDebug,{$endif}FPTemplt,FPCatch,FPRedir,FPDesk
  27. {$ifdef FPC}
  28. ,dpmiexcp
  29. {$endif FPC}
  30. ;
  31. procedure ProcessParams(BeforeINI: boolean);
  32. function IsSwitch(const Param: string): boolean;
  33. begin
  34. IsSwitch:=(Param<>'') and (Param[1]<>DirSep) { <- allow UNIX root-relative paths }
  35. and (Param[1] in ['-','/']); { <- but still accept dos switch char, eg. '/' }
  36. end;
  37. var I: Sw_integer;
  38. Param: string;
  39. begin
  40. for I:=1 to ParamCount do
  41. begin
  42. Param:=ParamStr(I);
  43. if IsSwitch(Param) then
  44. begin
  45. Param:=copy(Param,2,255);
  46. if Param<>'' then
  47. case Upcase(Param[1]) of
  48. 'C' : { custom config file (BP compatiblity) }
  49. if BeforeINI then
  50. INIPath:=copy(Param,2,255);
  51. 'R' : { enter the directory last exited from (BP comp.) }
  52. begin
  53. Param:=copy(Param,2,255);
  54. if (Param='') or (Param='+') then
  55. StartupOptions:=StartupOptions or soReturnToLastDir
  56. else
  57. if (Param='-') then
  58. StartupOptions:=StartupOptions and (not soReturnToLastDir);
  59. end;
  60. end;
  61. end
  62. else
  63. if not BeforeINI then
  64. TryToOpenFile(nil,Param,0,0,false);
  65. end;
  66. end;
  67. Procedure MyStreamError(Var S: TStream); {$ifndef FPC}far;{$endif}
  68. var ErrS: string;
  69. begin
  70. {$ifdef GABOR}{$ifdef TP}asm int 3;end;{$endif}{$endif}
  71. case S.Status of
  72. stGetError : ErrS:='Get of unregistered object type';
  73. stPutError : ErrS:='Put of unregistered object type';
  74. else ErrS:='';
  75. end;
  76. if Assigned(Application) then
  77. ErrorBox('Stream error: '+#13+ErrS,nil)
  78. else
  79. writeln('Error: ',ErrS);
  80. end;
  81. procedure RegisterIDEObjects;
  82. begin
  83. RegisterApp;
  84. RegisterAsciiTab;
  85. RegisterCalc;
  86. RegisterColorSel;
  87. RegisterDialogs;
  88. {$ifdef EDITORS}
  89. RegisterEditors;
  90. {$else}
  91. RegisterCodeEditors;
  92. {$endif}
  93. RegisterFPCalc;
  94. RegisterFPCompile;
  95. RegisterFPTools;
  96. RegisterFPViews;
  97. RegisterMenus;
  98. RegisterStdDlg;
  99. RegisterObjects;
  100. RegisterValidate;
  101. RegisterViews;
  102. end;
  103. var CanExit : boolean;
  104. BEGIN
  105. {$ifdef DEV}HeapLimit:=4096;{$endif}
  106. writeln('þ Free Pascal IDE Version '+VersionStr);
  107. StartupDir:=CompleteDir(FExpand('.'));
  108. IDEDir:=CompleteDir(DirOf(Paramstr(0)));
  109. RegisterIDEObjects;
  110. StreamError:=@MyStreamError;
  111. ProcessParams(true);
  112. {$ifdef VESA}
  113. InitVESAScreenModes;
  114. {$endif}
  115. InitRedir;
  116. {$ifndef NODEBUG}
  117. InitBreakpoints;
  118. {$endif}
  119. InitReservedWords;
  120. InitHelpFiles;
  121. InitSwitches;
  122. InitINIFile;
  123. InitUserScreen;
  124. InitTools;
  125. InitTemplates;
  126. ReadSwitches(SwitchesPath);
  127. MyApp.Init;
  128. { load all options after init because of open files }
  129. ReadINIFile;
  130. InitDesktopFile;
  131. LoadDesktop;
  132. { Update IDE }
  133. MyApp.Update;
  134. ProcessParams(false);
  135. repeat
  136. MyApp.Run;
  137. if (AutoSaveOptions and asEditorFiles)=0 then CanExit:=true else
  138. CanExit:=MyApp.SaveAll;
  139. until CanExit;
  140. { must be written before done for open files }
  141. if (AutoSaveOptions and asEnvironment)<>0 then
  142. if WriteINIFile=false then
  143. ErrorBox('Error saving configuration.',nil);
  144. if (AutoSaveOptions and asDesktop)<>0 then
  145. if SaveDesktop=false then
  146. ErrorBox('Error saving desktop.',nil);
  147. DoneDesktopFile;
  148. MyApp.Done;
  149. WriteSwitches(SwitchesPath);
  150. DoneTemplates;
  151. DoneTools;
  152. DoneUserScreen;
  153. DoneSwitches;
  154. DoneHelpFiles;
  155. DoneReservedWords;
  156. DoneBrowserCol;
  157. {$ifndef NODEBUG}
  158. DoneDebugger;
  159. DoneBreakpoints;
  160. {$endif}
  161. StreamError:=nil;
  162. END.
  163. {
  164. $Log$
  165. Revision 1.22 1999-05-22 13:44:28 peter
  166. * fixed couple of bugs
  167. Revision 1.21 1999/04/07 21:55:40 peter
  168. + object support for browser
  169. * html help fixes
  170. * more desktop saving things
  171. * NODEBUG directive to exclude debugger
  172. Revision 1.20 1999/03/23 16:16:36 peter
  173. * linux fixes
  174. Revision 1.19 1999/03/23 15:11:26 peter
  175. * desktop saving things
  176. * vesa mode
  177. * preferences dialog
  178. Revision 1.18 1999/03/21 22:51:35 florian
  179. + functional screen mode switching added
  180. Revision 1.17 1999/03/16 12:38:06 peter
  181. * tools macro fixes
  182. + tph writer
  183. + first things for resource files
  184. Revision 1.16 1999/03/12 01:13:01 peter
  185. * use TryToOpen() with parameter files to overcome double opened files
  186. at startup
  187. Revision 1.15 1999/03/08 14:58:08 peter
  188. + prompt with dialogs for tools
  189. Revision 1.14 1999/03/05 17:53:00 pierre
  190. + saving and opening of open files on exit
  191. Revision 1.13 1999/03/01 15:41:48 peter
  192. + Added dummy entries for functions not yet implemented
  193. * MenuBar didn't update itself automatically on command-set changes
  194. * Fixed Debugging/Profiling options dialog
  195. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  196. set
  197. * efBackSpaceUnindents works correctly
  198. + 'Messages' window implemented
  199. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  200. + Added TP message-filter support (for ex. you can call GREP thru
  201. GREP2MSG and view the result in the messages window - just like in TP)
  202. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  203. so topic search didn't work...
  204. * In FPHELP.PAS there were still context-variables defined as word instead
  205. of THelpCtx
  206. * StdStatusKeys() was missing from the statusdef for help windows
  207. + Topic-title for index-table can be specified when adding a HTML-files
  208. Revision 1.12 1999/02/20 15:18:25 peter
  209. + ctrl-c capture with confirm dialog
  210. + ascii table in the tools menu
  211. + heapviewer
  212. * empty file fixed
  213. * fixed callback routines in fpdebug to have far for tp7
  214. Revision 1.11 1999/02/18 13:44:30 peter
  215. * search fixed
  216. + backward search
  217. * help fixes
  218. * browser updates
  219. Revision 1.10 1999/02/15 09:07:10 pierre
  220. * HEAPTRC conditionnal renamed IDEHEAPTRC
  221. Revision 1.9 1999/02/10 09:55:43 pierre
  222. + Memory tracing if compiled with -dHEAPTRC
  223. * Many memory leaks removed
  224. Revision 1.8 1999/02/08 09:30:59 florian
  225. + some split heap stuff, in $ifdef TEMPHEAP
  226. Revision 1.7 1999/02/05 13:51:38 peter
  227. * unit name of FPSwitches -> FPSwitch which is easier to use
  228. * some fixes for tp7 compiling
  229. Revision 1.6 1999/01/21 11:54:10 peter
  230. + tools menu
  231. + speedsearch in symbolbrowser
  232. * working run command
  233. Revision 1.5 1999/01/12 14:29:31 peter
  234. + Implemented still missing 'switch' entries in Options menu
  235. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  236. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  237. ASCII chars and inserted directly in the text.
  238. + Added symbol browser
  239. * splitted fp.pas to fpide.pas
  240. }