fp.pas 9.8 KB

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