fp.pas 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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 TEMPHEAP}
  28. ,dpmiexcp
  29. {$endif TEMPHEAP}
  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.21 1999-04-07 21:55:40 peter
  166. + object support for browser
  167. * html help fixes
  168. * more desktop saving things
  169. * NODEBUG directive to exclude debugger
  170. Revision 1.20 1999/03/23 16:16:36 peter
  171. * linux fixes
  172. Revision 1.19 1999/03/23 15:11:26 peter
  173. * desktop saving things
  174. * vesa mode
  175. * preferences dialog
  176. Revision 1.18 1999/03/21 22:51:35 florian
  177. + functional screen mode switching added
  178. Revision 1.17 1999/03/16 12:38:06 peter
  179. * tools macro fixes
  180. + tph writer
  181. + first things for resource files
  182. Revision 1.16 1999/03/12 01:13:01 peter
  183. * use TryToOpen() with parameter files to overcome double opened files
  184. at startup
  185. Revision 1.15 1999/03/08 14:58:08 peter
  186. + prompt with dialogs for tools
  187. Revision 1.14 1999/03/05 17:53:00 pierre
  188. + saving and opening of open files on exit
  189. Revision 1.13 1999/03/01 15:41:48 peter
  190. + Added dummy entries for functions not yet implemented
  191. * MenuBar didn't update itself automatically on command-set changes
  192. * Fixed Debugging/Profiling options dialog
  193. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  194. set
  195. * efBackSpaceUnindents works correctly
  196. + 'Messages' window implemented
  197. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  198. + Added TP message-filter support (for ex. you can call GREP thru
  199. GREP2MSG and view the result in the messages window - just like in TP)
  200. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  201. so topic search didn't work...
  202. * In FPHELP.PAS there were still context-variables defined as word instead
  203. of THelpCtx
  204. * StdStatusKeys() was missing from the statusdef for help windows
  205. + Topic-title for index-table can be specified when adding a HTML-files
  206. Revision 1.12 1999/02/20 15:18:25 peter
  207. + ctrl-c capture with confirm dialog
  208. + ascii table in the tools menu
  209. + heapviewer
  210. * empty file fixed
  211. * fixed callback routines in fpdebug to have far for tp7
  212. Revision 1.11 1999/02/18 13:44:30 peter
  213. * search fixed
  214. + backward search
  215. * help fixes
  216. * browser updates
  217. Revision 1.10 1999/02/15 09:07:10 pierre
  218. * HEAPTRC conditionnal renamed IDEHEAPTRC
  219. Revision 1.9 1999/02/10 09:55:43 pierre
  220. + Memory tracing if compiled with -dHEAPTRC
  221. * Many memory leaks removed
  222. Revision 1.8 1999/02/08 09:30:59 florian
  223. + some split heap stuff, in $ifdef TEMPHEAP
  224. Revision 1.7 1999/02/05 13:51:38 peter
  225. * unit name of FPSwitches -> FPSwitch which is easier to use
  226. * some fixes for tp7 compiling
  227. Revision 1.6 1999/01/21 11:54:10 peter
  228. + tools menu
  229. + speedsearch in symbolbrowser
  230. * working run command
  231. Revision 1.5 1999/01/12 14:29:31 peter
  232. + Implemented still missing 'switch' entries in Options menu
  233. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  234. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  235. ASCII chars and inserted directly in the text.
  236. + Added symbol browser
  237. * splitted fp.pas to fpide.pas
  238. }