fp.pas 11 KB

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