fp.pas 11 KB

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