fpide.pas 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Main IDEApp object
  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. unit fpide;
  13. interface
  14. {$i globdir.inc}
  15. uses
  16. Objects,Drivers,Views,App,Gadgets,MsgBox,
  17. {$ifdef EDITORS}Editors,{$else}WEditor,WCEdit,{$endif}
  18. Comphook,Browcol,
  19. WHTMLScn,
  20. FPViews,FPSymbol,fpstring;
  21. type
  22. TExecType = (exNormal,exNoSwap,exDosShell);
  23. TIDEApp = object(TApplication)
  24. constructor Init;
  25. procedure InitDesktop; virtual;
  26. procedure InitMenuBar; virtual;
  27. procedure InitStatusLine; virtual;
  28. procedure Open(FileName: string);
  29. function OpenSearch(FileName: string) : boolean;
  30. function AskSaveAll: boolean;
  31. function SaveAll: boolean;
  32. function AutoSave: boolean;
  33. procedure Idle; virtual;
  34. procedure Update;
  35. procedure UpdateMode;
  36. procedure UpdateTarget;
  37. procedure GetEvent(var Event: TEvent); virtual;
  38. procedure HandleEvent(var Event: TEvent); virtual;
  39. procedure GetTileRect(var R: TRect); virtual;
  40. function GetPalette: PPalette; virtual;
  41. procedure DosShell; {virtual;}
  42. procedure ShowReadme;
  43. destructor Done; virtual;
  44. procedure ShowUserScreen;
  45. procedure ShowIDEScreen;
  46. function IsClosing : boolean;
  47. private
  48. procedure NewEditor;
  49. procedure NewFromTemplate;
  50. procedure OpenRecentFile(RecentIndex: integer);
  51. procedure ChangeDir;
  52. procedure ShowClipboard;
  53. procedure FindProcedure;
  54. procedure Objects;
  55. procedure Modules;
  56. procedure Globals;
  57. procedure SearchSymbol;
  58. procedure Parameters;
  59. procedure DoStepOver;
  60. procedure DoTraceInto;
  61. procedure DoRun;
  62. procedure DoResetDebugger;
  63. procedure DoContToCursor;
  64. procedure DoContUntilReturn;
  65. procedure Target;
  66. procedure DoCompilerMessages;
  67. procedure DoPrimaryFile;
  68. procedure DoClearPrimary;
  69. procedure DoUserScreenWindow;
  70. procedure DoCloseUserScreenWindow;
  71. procedure DoUserScreen;
  72. procedure DoOpenGDBWindow;
  73. procedure DoToggleBreak;
  74. procedure DoShowCallStack;
  75. procedure DoShowBreakpointList;
  76. procedure DoShowWatches;
  77. procedure DoAddWatch;
  78. procedure DoShowRegisters;
  79. procedure DoInformation;
  80. procedure Messages;
  81. procedure Calculator;
  82. procedure DoAsciiTable;
  83. procedure ExecuteTool(Idx: integer);
  84. procedure SetSwitchesMode;
  85. procedure DoCompilerSwitch;
  86. procedure MemorySizes;
  87. procedure DoLinkerSwitch;
  88. procedure DoDebuggerSwitch;
  89. procedure Directories;
  90. procedure Tools;
  91. procedure DoGrep;
  92. procedure Preferences;
  93. procedure EditorOptions(Editor: PEditor);
  94. procedure CodeComplete;
  95. procedure CodeTemplates;
  96. procedure BrowserOptions(Browser: PBrowserWindow);
  97. procedure DesktopOptions;
  98. procedure Mouse;
  99. procedure StartUp;
  100. procedure Colors;
  101. procedure OpenINI;
  102. procedure SaveINI;
  103. procedure SaveAsINI;
  104. procedure CloseAll;
  105. procedure WindowList;
  106. procedure HelpContents;
  107. procedure HelpHelpIndex;
  108. procedure HelpTopicSearch;
  109. procedure HelpPrevTopic;
  110. procedure HelpUsingHelp;
  111. procedure HelpFiles;
  112. procedure About;
  113. private
  114. SaveCancelled: boolean;
  115. InsideDone : boolean;
  116. LastEvent: longint;
  117. function DoExecute(ProgramPath, Params, InFile, OutFile: string; ExecType: TExecType): boolean;
  118. procedure AddRecentFile(AFileName: string; CurX, CurY: integer);
  119. function SearchRecentFile(AFileName: string): integer;
  120. procedure RemoveRecentFile(Index: integer);
  121. procedure CurDirChanged;
  122. procedure UpdatePrimaryFile;
  123. procedure UpdateINIFile;
  124. procedure UpdateRecentFileList;
  125. procedure UpdateTools;
  126. end;
  127. procedure PutEvent(TargetView: PView; E: TEvent);
  128. procedure PutCommand(TargetView: PView; What, Command: Word; InfoPtr: Pointer);
  129. var
  130. IDEApp: TIDEApp;
  131. implementation
  132. uses
  133. {$ifdef linux}
  134. linux,
  135. {$endif}
  136. {$ifdef HasSignal}
  137. fpcatch,
  138. {$endif HasSignal}
  139. {$ifdef WinClipSupported}
  140. WinClip,
  141. {$endif WinClipSupported}
  142. Video,Mouse,Keyboard,
  143. Dos,Memory,Menus,Dialogs,StdDlg,ColorSel,Commands,HelpCtx,
  144. AsciiTab,
  145. Systems,
  146. WUtils,WHelp,WHlpView,WINI,WViews,
  147. FPConst,FPVars,FPUtils,FPSwitch,FPIni,FPIntf,FPCompile,FPHelp,
  148. FPTemplt,FPCalc,FPUsrScr,FPTools,{$ifndef NODEBUG}FPDebug,{$endif}FPRedir,
  149. FPDesk,FPCodCmp,FPCodTmp;
  150. type
  151. TTargetedEvent = record
  152. Target: PView;
  153. Event: TEvent;
  154. end;
  155. const
  156. TargetedEventHead : integer = 0;
  157. TargetedEventTail : integer = 0;
  158. var
  159. TargetedEvents : array[0..10] of TTargetedEvent;
  160. function IncTargetedEventPtr(I: integer): integer;
  161. begin
  162. Inc(I);
  163. if I>High(TargetedEvents) then I:=Low(TargetedEvents);
  164. IncTargetedEventPtr:=I;
  165. end;
  166. procedure PutEvent(TargetView: PView; E: TEvent);
  167. begin
  168. if IncTargetedEventPtr(TargetedEventHead)=TargetedEventTail then Exit;
  169. with TargetedEvents[TargetedEventHead] do
  170. begin
  171. Target:=TargetView;
  172. Event:=E;
  173. end;
  174. TargetedEventHead:=IncTargetedEventPtr(TargetedEventHead);
  175. end;
  176. procedure PutCommand(TargetView: PView; What, Command: Word; InfoPtr: Pointer);
  177. var E: TEvent;
  178. begin
  179. FillChar(E,Sizeof(E),0);
  180. E.What:=What;
  181. E.Command:=Command;
  182. E.InfoPtr:=InfoPtr;
  183. PutEvent(TargetView,E);
  184. end;
  185. function GetTargetedEvent(var P: PView; var E: TEvent): boolean;
  186. var OK: boolean;
  187. begin
  188. OK:=TargetedEventHead<>TargetedEventTail;
  189. if OK then
  190. begin
  191. with TargetedEvents[TargetedEventTail] do
  192. begin
  193. P:=Target;
  194. E:=Event;
  195. end;
  196. TargetedEventTail:=IncTargetedEventPtr(TargetedEventTail);
  197. end;
  198. GetTargetedEvent:=OK;
  199. end;
  200. function IDEUseSyntaxHighlight(Editor: PFileEditor): boolean; {$ifndef FPC}far;{$endif}
  201. begin
  202. IDEUseSyntaxHighlight:=(Editor^.FileName='') or MatchesFileList(NameAndExtOf(Editor^.FileName),HighlightExts);
  203. end;
  204. function IDEUseTabsPattern(Editor: PFileEditor): boolean; {$ifndef FPC}far;{$endif}
  205. begin
  206. { the commented code lead all new files
  207. to become with TAB use enabled which is wrong in my opinion PM }
  208. IDEUseTabsPattern:={(Editor^.FileName='') or }MatchesFileList(NameAndExtOf(Editor^.FileName),TabsPattern);
  209. end;
  210. constructor TIDEApp.Init;
  211. var R: TRect;
  212. begin
  213. {$ifndef EDITORS}
  214. {$ifdef TP}
  215. UseSyntaxHighlight:=IDEUseSyntaxHighlight;
  216. UseTabsPattern:=IDEUseTabsPattern;
  217. {$else TP}
  218. UseSyntaxHighlight:=@IDEUseSyntaxHighlight;
  219. UseTabsPattern:=@IDEUseTabsPattern;
  220. {$endif TP}
  221. {$endif}
  222. inherited Init;
  223. InsideDone:=false;
  224. MenuBar^.GetBounds(R); R.A.X:=R.B.X-8;
  225. New(ClockView, Init(R));
  226. ClockView^.GrowMode:=gfGrowLoX+gfGrowHiX;
  227. Application^.Insert(ClockView);
  228. New(ClipboardWindow, Init);
  229. Desktop^.Insert(ClipboardWindow);
  230. New(CalcWindow, Init); CalcWindow^.Hide;
  231. Desktop^.Insert(CalcWindow);
  232. {$ifndef OLDCOMP}
  233. New(CompilerMessageWindow, Init);
  234. CompilerMessageWindow^.Hide;
  235. Desktop^.Insert(CompilerMessageWindow);
  236. {$else}
  237. New(ProgramInfoWindow, Init);
  238. ProgramInfoWindow^.Hide;
  239. Desktop^.Insert(ProgramInfoWindow);
  240. {$endif}
  241. Message(@Self,evBroadcast,cmUpdate,nil);
  242. CurDirChanged;
  243. { heap viewer }
  244. GetExtent(R); Dec(R.B.X); R.A.X:=R.B.X-9; R.A.Y:=R.B.Y-1;
  245. New(HeapView, InitKb(R));
  246. if (StartupOptions and soHeapMonitor)=0 then HeapView^.Hide;
  247. Insert(HeapView);
  248. Drivers.ShowMouse;
  249. end;
  250. procedure TIDEApp.InitDesktop;
  251. var
  252. R: TRect;
  253. begin
  254. GetExtent(R);
  255. Inc(R.A.Y);
  256. Dec(R.B.Y);
  257. Desktop:=New(PFPDesktop, Init(R));
  258. end;
  259. procedure TIDEApp.InitMenuBar;
  260. var R: TRect;
  261. WinPMI : PMenuItem;
  262. begin
  263. GetExtent(R); R.B.Y:=R.A.Y+1;
  264. WinPMI:=nil;
  265. {$ifdef WinClipSupported}
  266. if WinClipboardSupported then
  267. WinPMI:=NewLine(
  268. NewItem(menu_edit_copywin,'', kbNoKey, cmCopyWin, hcCopyWin,
  269. NewItem(menu_edit_pastewin,'', kbNoKey, cmPasteWin, hcPasteWin,
  270. nil)));
  271. {$endif WinClipSupported}
  272. MenuBar:=New(PAdvancedMenuBar, Init(R, NewMenu(
  273. NewSubMenu(menu_file,hcFileMenu, NewMenu(
  274. NewItem(menu_file_new,'',kbNoKey,cmNew,hcNew,
  275. NewItem(menu_file_template,'',kbNoKey,cmNewFromTemplate,hcNewFromTemplate,
  276. NewItem(menu_file_open,menu_key_file_open,kbF3,cmOpen,hcOpen,
  277. NewItem(menu_file_save,menu_key_file_save,kbF2,cmSave,hcSave,
  278. NewItem(menu_file_saveas,'',kbNoKey,cmSaveAs,hcSaveAs,
  279. NewItem(menu_file_saveall,'',kbNoKey,cmSaveAll,hcSaveAll,
  280. NewLine(
  281. NewItem(menu_file_changedir,'',kbNoKey,cmChangeDir,hcChangeDir,
  282. NewItem(menu_file_dosshell,'',kbNoKey,cmDOSShell,hcDOSShell,
  283. NewItem(menu_file_exit,menu_key_file_exit,kbNoKey,cmQuit,hcQuit,
  284. nil))))))))))),
  285. NewSubMenu(menu_edit,hcEditMenu, NewMenu(
  286. NewItem(menu_edit_undo,menu_key_edit_undo, kbAltBack, cmUndo, hcUndo,
  287. NewItem(menu_edit_redo,'', kbNoKey, cmRedo, hcRedo,
  288. {$ifdef DebugUndo}
  289. NewItem('~D~ump Undo','', kbNoKey, cmDumpUndo, hcUndo,
  290. NewItem('U~n~do All','', kbNoKey, cmUndoAll, hcUndo,
  291. NewItem('R~e~do All','', kbNoKey, cmRedoAll, hcRedo,
  292. {$endif DebugUndo}
  293. NewLine(
  294. NewItem(menu_edit_cut,menu_key_edit_cut, kbShiftDel, cmCut, hcCut,
  295. NewItem(menu_edit_copy,menu_key_edit_copy, kbCtrlIns, cmCopy, hcCut,
  296. NewItem(menu_edit_paste,menu_key_edit_paste, kbShiftIns, cmPaste, hcPaste,
  297. NewItem(menu_edit_clear,menu_key_edit_clear, kbCtrlDel, cmClear, hcClear,
  298. NewLine(
  299. NewItem(menu_edit_showclipboard,'', kbNoKey, cmShowClipboard, hcShowClipboard,
  300. WinPMI))))))
  301. {$ifdef DebugUndo}))){$endif DebugUndo}
  302. )))),
  303. NewSubMenu(menu_search,hcSearchMenu, NewMenu(
  304. NewItem(menu_search_find,'', kbNoKey, cmFind, hcFind,
  305. NewItem(menu_search_replace,'', kbNoKey, cmReplace, hcReplace,
  306. NewItem(menu_search_searchagain,'', kbNoKey, cmSearchAgain, hcSearchAgain,
  307. NewLine(
  308. NewItem(menu_search_jumpline,'', kbNoKey, cmJumpLine, hcGotoLine,
  309. NewItem(menu_search_findproc,'', kbNoKey, cmFindProcedure, hcFindProcedure,
  310. NewLine(
  311. NewItem(menu_search_objects,'', kbNoKey, cmObjects, hcObjects,
  312. NewItem(menu_search_modules,'', kbNoKey, cmModules, hcModules,
  313. NewItem(menu_search_globals,'', kbNoKey, cmGlobals, hcGlobals,
  314. NewLine(
  315. NewItem(menu_search_symbol,'', kbNoKey, cmSymbol, hcSymbol,
  316. nil))))))))))))),
  317. NewSubMenu(menu_run,hcRunMenu, NewMenu(
  318. NewItem(menu_run_run,menu_key_run_run, kbCtrlF9, cmRun, hcRun,
  319. NewItem(menu_run_stepover,menu_key_run_stepover, kbF8, cmStepOver, hcRun,
  320. NewItem(menu_run_traceinto,menu_key_run_traceinto, kbF7, cmTraceInto, hcRun,
  321. NewItem(menu_run_conttocursor,menu_key_run_conttocursor, kbF4, cmContToCursor, hcContToCursor,
  322. NewItem(menu_run_untilreturn,'', kbNoKey,cmUntilReturn,hcUntilReturn,
  323. NewItem(menu_run_parameters,'', kbNoKey, cmParameters, hcParameters,
  324. NewItem(menu_run_resetdebugger,menu_key_run_resetdebugger, kbCtrlF2, cmResetDebugger, hcResetDebugger,
  325. nil)))))))),
  326. NewSubMenu(menu_compile,hcCompileMenu, NewMenu(
  327. NewItem(menu_compile_compile,menu_key_compile_compile, kbAltF9, cmCompile, hcCompile,
  328. NewItem(menu_compile_make,menu_key_compile_make, kbF9, cmMake, hcMake,
  329. NewItem(menu_compile_build,'', kbNoKey, cmBuild, hcBuild,
  330. NewLine(
  331. NewItem(menu_compile_target,'', kbNoKey, cmTarget, hcTarget,
  332. NewItem(menu_compile_primaryfile,'', kbNoKey, cmPrimaryFile, hcPrimaryFile,
  333. NewItem(menu_compile_clearprimaryfile,'', kbNoKey, cmClearPrimary, hcClearPrimary,
  334. NewLine(
  335. NewItem(menu_compile_information,'', kbNoKey, cmInformation, hcInformation,
  336. NewItem(menu_compile_compilermessages,menu_key_compile_compilermessages, kbF12, cmCompilerMessages, hcCompilerMessages,
  337. nil))))))))))),
  338. NewSubMenu(menu_debug, hcDebugMenu, NewMenu(
  339. NewItem(menu_debug_output,'', kbNoKey, cmUserScreenWindow, hcUserScreenWindow,
  340. NewItem(menu_debug_userscreen,menu_key_debug_userscreen, kbAltF5, cmUserScreen, hcUserScreen,
  341. NewItem(menu_debug_breakpoint,menu_key_debug_breakpoint, kbCtrlF8, cmToggleBreakpoint, hcToggleBreakpoint,
  342. NewItem(menu_debug_callstack,menu_key_debug_callstack, kbCtrlF3, cmStack, hcStack,
  343. NewItem(menu_debug_registers,'', kbNoKey, cmRegisters, hcRegisters,
  344. NewItem(menu_debug_addwatch,menu_key_debug_addwatch, kbCtrlF7, cmAddWatch, hcAddWatch,
  345. NewItem(menu_debug_watches,'', kbNoKey, cmWatches, hcWatches,
  346. NewItem(menu_debug_breakpointlist,'', kbNoKey, cmBreakpointList, hcBreakpointList,
  347. NewLine(
  348. NewItem(menu_debug_gdbwindow,'', kbNoKey, cmOpenGDBWindow, hcOpenGDBWindow,
  349. nil))))))))))),
  350. NewSubMenu(menu_tools, hcToolsMenu, NewMenu(
  351. NewItem(menu_tools_messages,menu_key_tools_messages, kbF11, cmToolsMessages, hcToolsMessages,
  352. NewItem(menu_tools_msgnext,menu_key_tools_msgnext, kbAltF8, cmToolsMsgNext, hcToolsMsgNext,
  353. NewItem(menu_tools_msgprev,menu_key_tools_msgprev, kbAltF7, cmToolsMsgPrev, hcToolsMsgPrev,
  354. NewLine(
  355. NewItem(menu_tools_grep,menu_key_tools_grep, kbShiftF2, cmGrep, hcGrep,
  356. NewItem(menu_tools_calculator, '', kbNoKey, cmCalculator, hcCalculator,
  357. NewItem(menu_tools_asciitable, '', kbNoKey, cmAsciiTable, hcAsciiTable,
  358. nil)))))))),
  359. NewSubMenu(menu_options, hcOptionsMenu, NewMenu(
  360. NewItem(menu_options_mode,'', kbNoKey, cmSwitchesMode, hcSwitchesMode,
  361. NewItem(menu_options_compiler,'', kbNoKey, cmCompiler, hcCompiler,
  362. NewItem(menu_options_memory,'', kbNoKey, cmMemorySizes, hcMemorySizes,
  363. NewItem(menu_options_linker,'', kbNoKey, cmLinker, hcLinker,
  364. NewItem(menu_options_debugger,'', kbNoKey, cmDebugger, hcDebugger,
  365. NewItem(menu_options_directories,'', kbNoKey, cmDirectories, hcDirectories,
  366. NewItem(menu_options_browser,'',kbNoKey, cmBrowser, hcBrowser,
  367. NewItem(menu_options_tools,'', kbNoKey, cmTools, hcTools,
  368. NewLine(
  369. NewSubMenu(menu_options_env, hcEnvironmentMenu, NewMenu(
  370. NewItem(menu_options_env_preferences,'', kbNoKey, cmPreferences, hcPreferences,
  371. NewItem(menu_options_env_editor,'', kbNoKey, cmEditor, hcEditor,
  372. NewItem(menu_options_env_codecomplete,'', kbNoKey, cmCodeCompleteOptions, hcCodeCompleteOptions,
  373. NewItem(menu_options_env_codetemplates,'', kbNoKey, cmCodeTemplateOptions, hcCodeTemplateOptions,
  374. NewItem(menu_options_env_desktop,'', kbNoKey, cmDesktopOptions, hcDesktopOptions,
  375. NewItem(menu_options_env_mouse,'', kbNoKey, cmMouse, hcMouse,
  376. NewItem(menu_options_env_startup,'', kbNoKey, cmStartup, hcStartup,
  377. NewItem(menu_options_env_colors,'', kbNoKey, cmColors, hcColors,
  378. nil))))))))),
  379. NewLine(
  380. NewItem(menu_options_open,'', kbNoKey, cmOpenINI, hcOpenINI,
  381. NewItem(menu_options_save,'', kbNoKey, cmSaveINI, hcSaveINI,
  382. NewItem(menu_options_saveas,'', kbNoKey, cmSaveAsINI, hcSaveAsINI,
  383. nil))))))))))))))),
  384. NewSubMenu(menu_window, hcWindowMenu, NewMenu(
  385. NewItem(menu_window_tile,'', kbNoKey, cmTile, hcTile,
  386. NewItem(menu_window_cascade,'', kbNoKey, cmCascade, hcCascade,
  387. NewItem(menu_window_closeall,'', kbNoKey, cmCloseAll, hcCloseAll,
  388. NewLine(
  389. NewItem(menu_window_resize,menu_key_window_resize, kbCtrlF5, cmResize, hcResize,
  390. NewItem(menu_window_zoom,menu_key_window_zoom, kbF5, cmZoom, hcZoom,
  391. NewItem(menu_window_next,menu_key_window_next, kbF6, cmNext, hcNext,
  392. NewItem(menu_window_previous,menu_key_window_previous, kbShiftF6, cmPrev, hcPrev,
  393. NewItem(menu_window_hide,menu_key_window_hide, kbCtrlF6, cmHide, hcHide,
  394. NewItem(menu_window_close,menu_key_window_close, kbAltF3, cmClose, hcClose,
  395. NewLine(
  396. NewItem(menu_window_list,menu_key_window_list, kbAlt0, cmWindowList, hcWindowList,
  397. NewItem(menu_window_update,'', kbNoKey, cmUpdate, hcUpdate,
  398. nil)))))))))))))),
  399. NewSubMenu(menu_help, hcHelpMenu, NewMenu(
  400. NewItem(menu_help_contents,'', kbNoKey, cmHelpContents, hcHelpContents,
  401. NewItem(menu_help_index,menu_key_help_helpindex, kbShiftF1, cmHelpIndex, hcHelpIndex,
  402. NewItem(menu_help_topicsearch,menu_key_help_topicsearch, kbCtrlF1, cmHelpTopicSearch, hcHelpTopicSearch,
  403. NewItem(menu_help_prevtopic,menu_key_help_prevtopic, kbAltF1, cmHelpPrevTopic, hcHelpPrevTopic,
  404. NewItem(menu_help_using,'',kbNoKey, cmHelpUsingHelp, hcHelpUsingHelp,
  405. NewItem(menu_help_files,'',kbNoKey, cmHelpFiles, hcHelpFiles,
  406. NewLine(
  407. NewItem(menu_help_about,'',kbNoKey, cmAbout, hcAbout,
  408. nil))))))))),
  409. nil)))))))))))));
  410. DisableCommands(EditorCmds+SourceCmds+CompileCmds);
  411. Update;
  412. end;
  413. procedure TIDEApp.InitStatusLine;
  414. var
  415. R: TRect;
  416. begin
  417. GetExtent(R);
  418. R.A.Y := R.B.Y - 1;
  419. StatusLine:=New(PIDEStatusLine, Init(R,
  420. NewStatusDef(hcDragging, hcDragging,
  421. NewStatusKey(status_help, kbF1, cmHelp,
  422. StdStatusKeys(
  423. NewStatusKey('~'#24#25#26#27+'~ Move', kbNoKey, 65535,
  424. NewStatusKey('~Shift+'#24#25#26#27+'~ Size', kbNoKey, 65535,
  425. NewStatusKey('~'#17+'ÄÙ~ Done', kbNoKey, 65535,
  426. NewStatusKey('~Esc~ Cancel', kbNoKey, 65535,
  427. nil)))))),
  428. NewStatusDef(hcFirstCommand, hcLastCommand,
  429. NewStatusKey(status_help, kbF1, cmHelp,
  430. StdStatusKeys(
  431. nil)),
  432. NewStatusDef(hcHelpWindow, hcHelpWindow,
  433. NewStatusKey(status_help_on_help, kbF1, cmHelpUsingHelp,
  434. NewStatusKey(status_help_previoustopic, kbAltF1, cmHelpPrevTopic,
  435. NewStatusKey(status_help_index, kbShiftF1, cmHelpIndex,
  436. NewStatusKey(status_help_close, kbEsc, cmClose,
  437. StdStatusKeys(
  438. nil))))),
  439. NewStatusDef(hcSourceWindow, hcSourceWindow,
  440. NewStatusKey(status_help, kbF1, cmHelp,
  441. NewStatusKey(status_save, kbF2, cmSave,
  442. NewStatusKey(status_open, kbF3, cmOpen,
  443. NewStatusKey(status_compile, kbAltF9, cmCompile,
  444. NewStatusKey(status_make, kbF9, cmMake,
  445. NewStatusKey(status_localmenu, kbAltF10, cmLocalMenu,
  446. StdStatusKeys(
  447. nil))))))),
  448. NewStatusDef(hcASCIITableWindow, hcASCIITableWindow,
  449. NewStatusKey(status_help, kbF1, cmHelp,
  450. NewStatusKey(status_transferchar, kbCtrlEnter, cmTransfer,
  451. StdStatusKeys(
  452. nil))),
  453. NewStatusDef(hcMessagesWindow, hcMessagesWindow,
  454. NewStatusKey(status_help, kbF1, cmHelp,
  455. NewStatusKey(status_msggotosource, kbEnter, cmMsgGotoSource,
  456. NewStatusKey(status_msgtracksource, kbNoKey, cmMsgTrackSource,
  457. NewStatusKey(status_localmenu, kbAltF10, cmLocalMenu,
  458. NewStatusKey('', kbEsc, cmClose,
  459. StdStatusKeys(
  460. nil)))))),
  461. NewStatusDef(hcCalcWindow, hcCalcWindow,
  462. NewStatusKey(status_help, kbF1, cmHelp,
  463. NewStatusKey(status_close, kbEsc, cmClose,
  464. NewStatusKey(status_calculatorpaste, kbCtrlEnter, cmCalculatorPaste,
  465. StdStatusKeys(
  466. nil)))),
  467. NewStatusDef(0, $FFFF,
  468. NewStatusKey(status_help, kbF1, cmHelp,
  469. NewStatusKey(status_open, kbF3, cmOpen,
  470. NewStatusKey(status_compile, kbAltF9, cmCompile,
  471. NewStatusKey(status_make, kbF9, cmMake,
  472. NewStatusKey(status_localmenu, kbAltF10, cmLocalMenu,
  473. StdStatusKeys(
  474. nil)))))),
  475. nil))))))))));
  476. end;
  477. procedure TIDEApp.Idle;
  478. begin
  479. inherited Idle;
  480. Message(Application,evIdle,0,nil);
  481. GiveUpTimeSlice;
  482. end;
  483. procedure TIDEApp.GetEvent(var Event: TEvent);
  484. var P: PView;
  485. begin
  486. { first of all dispatch queued targeted events }
  487. while GetTargetedEvent(P,Event) do
  488. P^.HandleEvent(Event);
  489. inherited GetEvent(Event);
  490. if Event.What<>evNothing then
  491. LastEvent:=GetDosTicks
  492. else
  493. begin
  494. if abs(GetDosTicks-LastEvent)>SleepTimeOut then
  495. GiveUpTimeSlice;
  496. end;
  497. end;
  498. procedure TIDEApp.HandleEvent(var Event: TEvent);
  499. var DontClear: boolean;
  500. TempS: string;
  501. ForceDlg: boolean;
  502. {$ifdef HasSignal}
  503. CtrlCCatched : boolean;
  504. {$endif HasSignal}
  505. begin
  506. {$ifdef HasSignal}
  507. if (Event.What=evKeyDown) and (Event.keyCode=kbCtrlC) and
  508. (CtrlCPressed) then
  509. begin
  510. CtrlCCatched:=true;
  511. {$ifdef DEBUG}
  512. Writeln(stderr,'One CtrlC caught');
  513. {$endif DEBUG}
  514. end
  515. else
  516. CtrlCCatched:=false;
  517. {$endif HasSignal}
  518. case Event.What of
  519. evKeyDown :
  520. begin
  521. DontClear:=true;
  522. { just for debugging purposes }
  523. end;
  524. evCommand :
  525. begin
  526. DontClear:=false;
  527. case Event.Command of
  528. cmUpdate : Message(Application,evBroadcast,cmUpdate,nil);
  529. { -- File menu -- }
  530. cmNew : NewEditor;
  531. cmNewFromTemplate: NewFromTemplate;
  532. cmOpen : begin
  533. ForceDlg:=false;
  534. if (OpenFileName<>'') and
  535. ((DirOf(OpenFileName)='') or (Pos(ListSeparator,OpenFileName)<>0)) then
  536. begin
  537. TempS:=LocateFile(OpenFileName);
  538. if TempS='' then
  539. ForceDlg:=true
  540. else
  541. OpenFileName:=TempS;
  542. end;
  543. if ForceDlg then
  544. OpenSearch(OpenFileName)
  545. else
  546. Open(OpenFileName);
  547. OpenFileName:='';
  548. end;
  549. cmSaveAll : SaveAll;
  550. cmChangeDir : ChangeDir;
  551. cmDOSShell : DOSShell;
  552. cmRecentFileBase..
  553. cmRecentFileBase+10
  554. : OpenRecentFile(Event.Command-cmRecentFileBase);
  555. { -- Edit menu -- }
  556. cmShowClipboard : ShowClipboard;
  557. { -- Search menu -- }
  558. cmFindProcedure : FindProcedure;
  559. cmObjects : Objects;
  560. cmModules : Modules;
  561. cmGlobals : Globals;
  562. cmSymbol : SearchSymbol;
  563. { -- Run menu -- }
  564. cmParameters : Parameters;
  565. cmStepOver : DoStepOver;
  566. cmTraceInto : DoTraceInto;
  567. cmRun : DoRun;
  568. cmResetDebugger : DoResetDebugger;
  569. cmContToCursor : DoContToCursor;
  570. cmUntilReturn : DoContUntilReturn;
  571. { -- Compile menu -- }
  572. cmCompile : DoCompile(cCompile);
  573. cmBuild : DoCompile(cBuild);
  574. cmMake : DoCompile(cMake);
  575. cmTarget : Target;
  576. cmPrimaryFile : DoPrimaryFile;
  577. cmClearPrimary : DoClearPrimary;
  578. cmInformation : DoInformation;
  579. cmCompilerMessages : DoCompilerMessages;
  580. { -- Debug menu -- }
  581. cmUserScreen : DoUserScreen;
  582. cmToggleBreakpoint : DoToggleBreak;
  583. cmStack : DoShowCallStack;
  584. cmBreakpointList : DoShowBreakpointList;
  585. cmWatches : DoShowWatches;
  586. cmAddWatch : DoAddWatch;
  587. cmOpenGDBWindow : DoOpenGDBWindow;
  588. cmRegisters : DoShowRegisters;
  589. { -- Options menu -- }
  590. cmSwitchesMode : SetSwitchesMode;
  591. cmCompiler : DoCompilerSwitch;
  592. cmMemorySizes : MemorySizes;
  593. cmLinker : DoLinkerSwitch;
  594. cmDebugger : DoDebuggerSwitch;
  595. cmDirectories : Directories;
  596. cmTools : Tools;
  597. cmPreferences : Preferences;
  598. cmEditor : EditorOptions(nil);
  599. cmEditorOptions : EditorOptions(Event.InfoPtr);
  600. cmCodeTemplateOptions: CodeTemplates;
  601. cmCodeCompleteOptions: CodeComplete;
  602. cmBrowser : BrowserOptions(nil);
  603. cmBrowserOptions : BrowserOptions(Event.InfoPtr);
  604. cmMouse : Mouse;
  605. cmStartup : StartUp;
  606. cmDesktopOptions: DesktopOptions;
  607. cmColors : Colors;
  608. cmOpenINI : OpenINI;
  609. cmSaveINI : SaveINI;
  610. cmSaveAsINI : SaveAsINI;
  611. { -- Tools menu -- }
  612. cmToolsMessages : Messages;
  613. cmCalculator : Calculator;
  614. cmAsciiTable : DoAsciiTable;
  615. cmGrep : DoGrep;
  616. cmToolsBase+1..
  617. cmToolsBase+MaxToolCount
  618. : ExecuteTool(Event.Command-cmToolsBase);
  619. { -- Window menu -- }
  620. cmCloseAll : CloseAll;
  621. cmWindowList : WindowList;
  622. cmUserScreenWindow: DoUserScreenWindow;
  623. { -- Help menu -- }
  624. cmHelpContents : HelpContents;
  625. cmHelpIndex : HelpHelpIndex;
  626. { cmHelpTopicSearch: HelpTopicSearch;}
  627. cmHelpPrevTopic : HelpPrevTopic;
  628. cmHelpUsingHelp : HelpUsingHelp;
  629. cmHelpFiles : HelpFiles;
  630. cmAbout : About;
  631. cmShowReadme : ShowReadme;
  632. else DontClear:=true;
  633. end;
  634. if DontClear=false then ClearEvent(Event);
  635. end;
  636. evBroadcast :
  637. case Event.Command of
  638. cmSaveCancelled :
  639. SaveCancelled:=true;
  640. cmUpdateTools :
  641. UpdateTools;
  642. cmCommandSetChanged :
  643. UpdateMenu(MenuBar^.Menu);
  644. cmUpdate :
  645. Update;
  646. cmSourceWndClosing :
  647. begin
  648. with PSourceWindow(Event.InfoPtr)^ do
  649. if Editor^.FileName<>'' then
  650. AddRecentFile(Editor^.FileName,Editor^.CurPos.X,Editor^.CurPos.Y);
  651. {$ifndef NODEBUG}
  652. if assigned(Debugger) and (PView(Event.InfoPtr)=Debugger^.LastSource) then
  653. Debugger^.LastSource:=nil;
  654. {$endif}
  655. end;
  656. end;
  657. end;
  658. inherited HandleEvent(Event);
  659. {$ifdef HasSignal}
  660. { Reset flag if CrtlC was handled }
  661. if CtrlCCatched and (Event.What=evNothing) then
  662. begin
  663. CtrlCPressed:=false;
  664. {$ifdef DEBUG}
  665. Writeln(stderr,'One CtrlC handled');
  666. {$endif DEBUG}
  667. end;
  668. {$endif HasSignal}
  669. end;
  670. procedure TIDEApp.GetTileRect(var R: TRect);
  671. begin
  672. Desktop^.GetExtent(R);
  673. { Leave the compiler messages window in the bottom }
  674. if assigned(CompilerMessageWindow) and (CompilerMessageWindow^.GetState(sfVisible)) then
  675. R.B.Y:=Min(CompilerMessageWindow^.Origin.Y,R.B.Y);
  676. { Leave the messages window in the bottom }
  677. if assigned(MessagesWindow) and (MessagesWindow^.GetState(sfVisible)) then
  678. R.B.Y:=Min(MessagesWindow^.Origin.Y,R.B.Y);
  679. { Leave the watch window in the bottom }
  680. if assigned(WatchesWindow) and (WatchesWindow^.GetState(sfVisible)) then
  681. R.B.Y:=Min(WatchesWindow^.Origin.Y,R.B.Y);
  682. end;
  683. {****************************************************************************
  684. Switch Screens
  685. ****************************************************************************}
  686. procedure TIDEApp.ShowUserScreen;
  687. begin
  688. DoneSysError;
  689. DoneEvents;
  690. DoneKeyboard;
  691. If UseMouse then
  692. DoneMouse
  693. else
  694. ButtonCount:=0;
  695. {$ifndef go32v2}
  696. DoneScreen; { this is available in FV app.pas (PFV) }
  697. {$endif go32v2}
  698. DoneDosMem;
  699. if Assigned(UserScreen) then
  700. UserScreen^.SwitchTo;
  701. end;
  702. procedure TIDEApp.ShowIDEScreen;
  703. begin
  704. if Assigned(UserScreen) then
  705. UserScreen^.SwitchBack;
  706. InitDosMem;
  707. {$ifndef go32v2}
  708. InitScreen;
  709. {$endif go32v2}
  710. InitKeyboard;
  711. If UseMouse then
  712. InitMouse
  713. else
  714. ButtonCount:=0;
  715. InitEvents;
  716. InitSysError;
  717. CurDirChanged;
  718. Message(Application,evBroadcast,cmUpdate,nil);
  719. {$ifndef go32v2}
  720. UpdateScreen(true);
  721. {$endif go32v2}
  722. end;
  723. function TIDEApp.AutoSave: boolean;
  724. var IOK,SOK,DOK: boolean;
  725. begin
  726. IOK:=true; SOK:=true; DOK:=true;
  727. if (AutoSaveOptions and asEnvironment)<>0 then
  728. begin
  729. IOK:=WriteINIFile;
  730. if IOK=false then
  731. ErrorBox(error_saving_cfg_file,nil);
  732. end;
  733. if (AutoSaveOptions and asEditorFiles)=0 then
  734. SOK:=SaveAll;
  735. if (AutoSaveOptions and asDesktop)<>0 then
  736. begin
  737. { destory all help & browser windows - we don't want to store them }
  738. { UserScreenWindow is also not registered PM }
  739. DoCloseUserScreenWindow;
  740. CloseHelpWindows;
  741. CloseAllBrowsers;
  742. DOK:=SaveDesktop;
  743. if DOK=false then
  744. ErrorBox(error_saving_dsk_file,nil);
  745. end;
  746. AutoSave:=IOK and SOK and DOK;
  747. end;
  748. function TIDEApp.DoExecute(ProgramPath, Params, InFile,OutFile: string; ExecType: TExecType): boolean;
  749. var CanRun: boolean;
  750. posexe : longint;
  751. begin
  752. SaveCancelled:=false;
  753. CanRun:=AutoSave;
  754. if (CanRun=false) and (SaveCancelled=false) then
  755. CanRun:=true; { do not care about .DSK or .INI saving problems - just like TP }
  756. if CanRun then
  757. begin
  758. if UserScreen=nil then
  759. begin
  760. ErrorBox(error_user_screen_not_avail,nil);
  761. Exit;
  762. end;
  763. if ExecType<>exNoSwap then
  764. ShowUserScreen;
  765. if ExecType=exDosShell then
  766. WriteShellMsg;
  767. {$ifdef linux}
  768. Shell(ProgramPath+' '+Params);
  769. {$else}
  770. { DO NOT use COMSPEC for exe files as the
  771. ExitCode is lost in those cases PM }
  772. posexe:=Pos('.EXE',UpCaseStr(ProgramPath));
  773. { if programpath was three char long => bug }
  774. if (posexe>0) and (posexe=Length(ProgramPath)-3) then
  775. begin
  776. if (InFile='') and (OutFile='') then
  777. DosExecute(ProgramPath,Params)
  778. else
  779. ExecuteRedir(ProgramPath,Params,InFile,OutFile,'stderr');
  780. end
  781. else if (InFile='') and (OutFile='') then
  782. DosExecute(GetEnv('COMSPEC'),'/C '+ProgramPath+' '+Params)
  783. else
  784. ExecuteRedir(GetEnv('COMSPEC'),'/C '+ProgramPath+' '+Params,InFile,OutFile,'stderr');
  785. {$endif}
  786. if ExecType<>exNoSwap then
  787. ShowIDEScreen;
  788. end;
  789. DoExecute:=CanRun;
  790. end;
  791. procedure TIDEApp.Update;
  792. begin
  793. SetCmdState([cmSaveAll],IsThereAnyEditor);
  794. SetCmdState([cmCloseAll,cmWindowList],IsThereAnyWindow);
  795. SetCmdState([cmTile,cmCascade],IsThereAnyVisibleWindow);
  796. SetCmdState([cmFindProcedure,cmObjects,cmModules,cmGlobals,cmSymbol{,cmInformation}],IsSymbolInfoAvailable);
  797. {$ifndef NODEBUG}
  798. SetCmdState([cmResetDebugger,cmUntilReturn],assigned(debugger) and debugger^.debuggee_started);
  799. {$endif}
  800. SetCmdState([cmToolsMsgNext,cmToolsMsgPrev],MessagesWindow<>nil);
  801. UpdateTools;
  802. UpdateRecentFileList;
  803. UpdatePrimaryFile;
  804. UpdateINIFile;
  805. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  806. end;
  807. procedure TIDEApp.CurDirChanged;
  808. begin
  809. Message(Application,evBroadcast,cmUpdateTitle,nil);
  810. UpdatePrimaryFile;
  811. UpdateINIFile;
  812. UpdateMenu(MenuBar^.Menu);
  813. end;
  814. procedure TIDEApp.UpdatePrimaryFile;
  815. begin
  816. SetMenuItemParam(SearchMenuItem(MenuBar^.Menu,cmPrimaryFile),SmartPath(PrimaryFile));
  817. SetCmdState([cmClearPrimary],PrimaryFile<>'');
  818. if PrimaryFile<>'' then
  819. SetCmdState(CompileCmds,true);
  820. UpdateMenu(MenuBar^.Menu);
  821. Message(ProgramInfoWindow,evBroadcast,cmUpdate,nil);
  822. end;
  823. procedure TIDEApp.UpdateINIFile;
  824. begin
  825. SetMenuItemParam(SearchMenuItem(MenuBar^.Menu,cmSaveINI),SmartPath(IniFileName));
  826. end;
  827. procedure TIDEApp.UpdateRecentFileList;
  828. var P: PMenuItem;
  829. {ID,}I: word;
  830. FileMenu: PMenuItem;
  831. begin
  832. { ID:=cmRecentFileBase;}
  833. FileMenu:=SearchSubMenu(MenuBar^.Menu,menuFile);
  834. repeat
  835. { Inc(ID);
  836. P:=SearchMenuItem(FileMenu^.SubMenu,ID);
  837. if FileMenu^.SubMenu^.Default=P then
  838. FileMenu^.SubMenu^.Default:=FileMenu^.SubMenu^.Items;
  839. if P<>nil then RemoveMenuItem(FileMenu^.SubMenu,P);}
  840. P:=GetMenuItemBefore(FileMenu^.SubMenu,nil);
  841. if (P<>nil) then
  842. begin
  843. if (cmRecentFileBase<P^.Command) and (P^.Command<=cmRecentFileBase+MaxRecentFileCount) then
  844. begin
  845. RemoveMenuItem(FileMenu^.SubMenu,P);
  846. if FileMenu^.SubMenu^.Default=P then
  847. FileMenu^.SubMenu^.Default:=FileMenu^.SubMenu^.Items;
  848. end
  849. else
  850. P:=nil;
  851. end;
  852. until P=nil;
  853. P:=GetMenuItemBefore(FileMenu^.SubMenu,nil);
  854. if (P<>nil) and IsSeparator(P) then
  855. RemoveMenuItem(FileMenu^.SubMenu,P);
  856. if RecentFileCount>0 then
  857. AppendMenuItem(FileMenu^.SubMenu,NewLine(nil));
  858. for I:=1 to RecentFileCount do
  859. begin
  860. P:=NewItem('~'+IntToStr(I)+'~ '+ShrinkPath(SmartPath(RecentFiles[I].FileName),27),' ',
  861. kbNoKey,cmRecentFileBase+I,hcRecentFileBase+I,nil);
  862. AppendMenuItem(FileMenu^.SubMenu,P);
  863. end;
  864. end;
  865. procedure TIDEApp.UpdateTools;
  866. var P: PMenuItem;
  867. { ID,}I: word;
  868. ToolsMenu: PMenuItem;
  869. S1,S2,S3: string;
  870. W: word;
  871. begin
  872. { ID:=cmToolsBase;}
  873. ToolsMenu:=SearchSubMenu(MenuBar^.Menu,menuTools);
  874. repeat
  875. P:=GetMenuItemBefore(ToolsMenu^.SubMenu,nil);
  876. if (P<>nil) then
  877. begin
  878. if (cmToolsBase<P^.Command) and (P^.Command<=cmToolsBase+MaxToolCount) then
  879. begin
  880. RemoveMenuItem(ToolsMenu^.SubMenu,P);
  881. if ToolsMenu^.SubMenu^.Default=P then
  882. ToolsMenu^.SubMenu^.Default:=ToolsMenu^.SubMenu^.Items;
  883. end
  884. else
  885. P:=nil;
  886. end;
  887. until P=nil;
  888. P:=GetMenuItemBefore(ToolsMenu^.SubMenu,nil);
  889. if (P<>nil) and IsSeparator(P) then
  890. RemoveMenuItem(ToolsMenu^.SubMenu,P);
  891. if GetToolCount>0 then
  892. AppendMenuItem(ToolsMenu^.SubMenu,NewLine(nil));
  893. for I:=1 to GetToolCount do
  894. begin
  895. GetToolParams(I-1,S1,S2,S3,W);
  896. P:=NewItem(S1,KillTilde(GetHotKeyName(W)),W,cmToolsBase+I,hcToolsBase+I,nil);
  897. AppendMenuItem(ToolsMenu^.SubMenu,P);
  898. end;
  899. end;
  900. procedure TIDEApp.DosShell;
  901. begin
  902. DoExecute(GetEnv('COMSPEC'), '', '', '', exDosShell);
  903. end;
  904. procedure TIDEApp.ShowReadme;
  905. var R,R2: TRect;
  906. D: PCenterDialog;
  907. M: PFPMemo;
  908. VSB: PScrollBar;
  909. S: PBufStream;
  910. begin
  911. New(S, Init(ReadmeName, stOpenRead, 4096));
  912. if S^.Status=stOK then
  913. begin
  914. R.Assign(0,0,63,18);
  915. New(D, Init(R, 'Free Pascal IDE'));
  916. with D^ do
  917. begin
  918. GetExtent(R);
  919. R.Grow(-2,-2); Inc(R.B.Y);
  920. R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
  921. New(VSB, Init(R2)); VSB^.GrowMode:=0; Insert(VSB);
  922. New(M, Init(R,nil,VSB,nil));
  923. M^.LoadFromStream(S);
  924. M^.ReadOnly:=true;
  925. Insert(M);
  926. end;
  927. InsertOK(D);
  928. ExecuteDialog(D,nil);
  929. end;
  930. Dispose(S, Done);
  931. end;
  932. {$I FPMFILE.INC}
  933. {$I FPMEDIT.INC}
  934. {$I FPMSRCH.INC}
  935. {$I FPMRUN.INC}
  936. {$I FPMCOMP.INC}
  937. {$I FPMDEBUG.INC}
  938. {$I FPMTOOLS.INC}
  939. {$I FPMOPTS.INC}
  940. {$I FPMWND.INC}
  941. {$I FPMHELP.INC}
  942. procedure TIDEApp.AddRecentFile(AFileName: string; CurX, CurY: integer);
  943. begin
  944. if SearchRecentFile(AFileName)<>-1 then Exit;
  945. if RecentFileCount>0 then
  946. Move(RecentFiles[1],RecentFiles[2],SizeOf(RecentFiles[1])*Min(RecentFileCount,High(RecentFiles)-1));
  947. if RecentFileCount<High(RecentFiles) then Inc(RecentFileCount);
  948. with RecentFiles[1] do
  949. begin
  950. FileName:=AFileName;
  951. LastPos.X:=CurX; LastPos.Y:=CurY;
  952. end;
  953. UpdateRecentFileList;
  954. end;
  955. function TIDEApp.SearchRecentFile(AFileName: string): integer;
  956. var Idx,I: integer;
  957. begin
  958. Idx:=-1;
  959. for I:=1 to RecentFileCount do
  960. if UpcaseStr(AFileName)=UpcaseStr(RecentFiles[I].FileName) then
  961. begin Idx:=I; Break; end;
  962. SearchRecentFile:=Idx;
  963. end;
  964. procedure TIDEApp.RemoveRecentFile(Index: integer);
  965. begin
  966. if Index<RecentFileCount then
  967. Move(RecentFiles[Index+1],RecentFiles[Index],SizeOf(RecentFiles[1])*(RecentFileCount-Index));
  968. Dec(RecentFileCount);
  969. end;
  970. function TIDEApp.GetPalette: PPalette;
  971. var P: string;
  972. begin
  973. P:=AppPalette;
  974. GetPalette:=@P;
  975. end;
  976. function TIDEApp.IsClosing: Boolean;
  977. begin
  978. IsClosing:=InsideDone;
  979. end;
  980. destructor TIDEApp.Done;
  981. begin
  982. InsideDone:=true;
  983. inherited Done;
  984. RemoveBrowsersCollection;
  985. DoneHelpSystem;
  986. end;
  987. END.
  988. {
  989. $Log$
  990. Revision 1.64 2000-06-16 21:19:41 pierre
  991. * Use Open instead of OpenSearch if OpenFileName is empty
  992. Revision 1.63 2000/06/16 08:50:40 pierre
  993. + new bunch of Gabor's changes
  994. Revision 1.62 2000/06/11 07:01:33 peter
  995. * give watches window also a number
  996. * leave watches window in the bottom when cascading windows
  997. Revision 1.61 2000/05/17 09:51:11 pierre
  998. Disable/Enable keyboard on UserScreen
  999. Revision 1.60 2000/05/02 10:20:40 pierre
  1000. * fix a small problem when deciding to call DosExecute directly
  1001. Revision 1.59 2000/05/02 08:42:27 pierre
  1002. * new set of Gabor changes: see fixes.txt
  1003. Revision 1.58 2000/04/25 08:42:33 pierre
  1004. * New Gabor changes : see fixes.txt
  1005. Revision 1.57 2000/04/18 11:42:37 pierre
  1006. lot of Gabor changes : see fixes.txt
  1007. Revision 1.56 2000/03/21 23:30:49 pierre
  1008. adapted to wcedit addition by Gabor
  1009. Revision 1.55 2000/03/13 20:41:35 pierre
  1010. + option -S to disable the mouse
  1011. * adapted to changes in fpusrscr for DOS
  1012. Revision 1.54 2000/03/07 21:57:59 pierre
  1013. + CtrlC handling
  1014. + UpdateMode method
  1015. Revision 1.53 2000/03/06 11:31:30 pierre
  1016. * Do not use COMSPEC to Run files with .EXE suffix
  1017. because Command.com at least does not return the errorcode
  1018. of the program called
  1019. Revision 1.52 2000/02/07 12:02:32 pierre
  1020. Gabor's changes
  1021. Revision 1.51 2000/01/23 21:25:17 florian
  1022. + start of internationalization support
  1023. Revision 1.50 2000/01/08 18:26:20 florian
  1024. + added a register window, doesn't work yet
  1025. Revision 1.49 2000/01/05 00:31:50 pierre
  1026. * avoid new files to use TABS
  1027. Revision 1.48 2000/01/03 11:38:33 michael
  1028. Changes from Gabor
  1029. Revision 1.47 1999/12/20 14:23:17 pierre
  1030. * MyApp renamed IDEApp
  1031. * TDebugController.ResetDebuggerRows added to
  1032. get resetting of debugger rows
  1033. Revision 1.46 1999/12/17 15:07:01 florian
  1034. + TIDEApp.Idle does always call GiveUpTimeSlice
  1035. Revision 1.45 1999/12/10 13:02:05 pierre
  1036. + VideoMode save/restore
  1037. Revision 1.44 1999/11/25 00:26:49 pierre
  1038. * RecentFiles missed the last char
  1039. Revision 1.43 1999/11/10 17:19:06 pierre
  1040. * Use DosExecute from Fpredir unit
  1041. Revision 1.42 1999/10/27 12:10:42 pierre
  1042. + With DebugUndo added 3 menu items
  1043. "Dump Undo" "Undo All" and "Redo All"
  1044. for Undo checks
  1045. Revision 1.41 1999/09/22 16:21:41 pierre
  1046. * Use ShrinkPas for RecentFiles
  1047. Revision 1.40 1999/09/22 13:04:31 pierre
  1048. + Close UserScreen to avoid store crash
  1049. Revision 1.39 1999/09/21 17:09:00 pierre
  1050. + Windows clipboard for win32
  1051. Revision 1.38 1999/09/13 16:24:43 peter
  1052. + clock
  1053. * backspace unident like tp7
  1054. Revision 1.37 1999/09/13 11:44:00 peter
  1055. * fixes from gabor, idle event, html fix
  1056. Revision 1.36 1999/09/09 14:15:27 pierre
  1057. + cmCopyWin,cmPasteWin
  1058. Revision 1.35 1999/08/16 18:25:19 peter
  1059. * Adjusting the selection when the editor didn't contain any line.
  1060. * Reserved word recognition redesigned, but this didn't affect the overall
  1061. syntax highlight speed remarkably (at least not on my Amd-K6/350).
  1062. The syntax scanner loop is a bit slow but the main problem is the
  1063. recognition of special symbols. Switching off symbol processing boosts
  1064. the performance up to ca. 200%...
  1065. * The editor didn't allow copying (for ex to clipboard) of a single character
  1066. * 'File|Save as' caused permanently run-time error 3. Not any more now...
  1067. * Compiler Messages window (actually the whole desktop) did not act on any
  1068. keypress when compilation failed and thus the window remained visible
  1069. + Message windows are now closed upon pressing Esc
  1070. + At 'Run' the IDE checks whether any sources are modified, and recompiles
  1071. only when neccessary
  1072. + BlockRead and BlockWrite (Ctrl+K+R/W) implemented in TCodeEditor
  1073. + LineSelect (Ctrl+K+L) implemented
  1074. * The IDE had problems closing help windows before saving the desktop
  1075. Revision 1.34 1999/08/03 20:22:32 peter
  1076. + TTab acts now on Ctrl+Tab and Ctrl+Shift+Tab...
  1077. + Desktop saving should work now
  1078. - History saved
  1079. - Clipboard content saved
  1080. - Desktop saved
  1081. - Symbol info saved
  1082. * syntax-highlight bug fixed, which compared special keywords case sensitive
  1083. (for ex. 'asm' caused asm-highlighting, while 'ASM' didn't)
  1084. * with 'whole words only' set, the editor didn't found occourences of the
  1085. searched text, if the text appeared previously in the same line, but didn't
  1086. satisfied the 'whole-word' condition
  1087. * ^QB jumped to (SelStart.X,SelEnd.X) instead of (SelStart.X,SelStart.Y)
  1088. (ie. the beginning of the selection)
  1089. * when started typing in a new line, but not at the start (X=0) of it,
  1090. the editor inserted the text one character more to left as it should...
  1091. * TCodeEditor.HideSelection (Ctrl-K+H) didn't update the screen
  1092. * Shift shouldn't cause so much trouble in TCodeEditor now...
  1093. * Syntax highlight had problems recognizing a special symbol if it was
  1094. prefixed by another symbol character in the source text
  1095. * Auto-save also occours at Dos shell, Tool execution, etc. now...
  1096. Revision 1.33 1999/07/12 13:14:18 pierre
  1097. * LineEnd bug corrected, now goes end of text even if selected
  1098. + Until Return for debugger
  1099. + Code for Quit inside GDB Window
  1100. Revision 1.32 1999/07/10 01:24:17 pierre
  1101. + First implementation of watches window
  1102. Revision 1.31 1999/06/29 22:50:14 peter
  1103. * more fixes from gabor
  1104. Revision 1.30 1999/06/28 19:32:20 peter
  1105. * fixes from gabor
  1106. Revision 1.29 1999/06/28 12:40:19 pierre
  1107. + RemoveBrowsersCollection in TIDEApp.Done
  1108. Revision 1.28 1999/06/25 00:46:33 pierre
  1109. + UpdateTarget to show current target
  1110. + SearchSymbol, not scope aware (this will need a PPU change !)
  1111. Revision 1.27 1999/05/22 13:44:30 peter
  1112. * fixed couple of bugs
  1113. Revision 1.26 1999/04/07 21:55:47 peter
  1114. + object support for browser
  1115. * html help fixes
  1116. * more desktop saving things
  1117. * NODEBUG directive to exclude debugger
  1118. Revision 1.25 1999/03/23 15:11:29 peter
  1119. * desktop saving things
  1120. * vesa mode
  1121. * preferences dialog
  1122. Revision 1.24 1999/03/19 16:04:29 peter
  1123. * new compiler dialog
  1124. Revision 1.23 1999/03/16 12:38:10 peter
  1125. * tools macro fixes
  1126. + tph writer
  1127. + first things for resource files
  1128. Revision 1.22 1999/03/12 01:13:57 peter
  1129. * flag if trytoopen should look for other extensions
  1130. + browser tab in the tools-compiler
  1131. Revision 1.21 1999/03/02 13:48:29 peter
  1132. * fixed far problem is fpdebug
  1133. * tile/cascading with message window
  1134. * grep fixes
  1135. Revision 1.20 1999/03/01 15:41:54 peter
  1136. + Added dummy entries for functions not yet implemented
  1137. * MenuBar didn't update itself automatically on command-set changes
  1138. * Fixed Debugging/Profiling options dialog
  1139. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  1140. set
  1141. * efBackSpaceUnindents works correctly
  1142. + 'Messages' window implemented
  1143. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  1144. + Added TP message-filter support (for ex. you can call GREP thru
  1145. GREP2MSG and view the result in the messages window - just like in TP)
  1146. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  1147. so topic search didn't work...
  1148. * In FPHELP.PAS there were still context-variables defined as word instead
  1149. of THelpCtx
  1150. * StdStatusKeys() was missing from the statusdef for help windows
  1151. + Topic-title for index-table can be specified when adding a HTML-files
  1152. Revision 1.19 1999/02/22 11:51:36 peter
  1153. * browser updates from gabor
  1154. Revision 1.18 1999/02/22 02:15:13 peter
  1155. + default extension for save in the editor
  1156. + Separate Text to Find for the grep dialog
  1157. * fixed redir crash with tp7
  1158. Revision 1.17 1999/02/20 15:18:30 peter
  1159. + ctrl-c capture with confirm dialog
  1160. + ascii table in the tools menu
  1161. + heapviewer
  1162. * empty file fixed
  1163. * fixed callback routines in fpdebug to have far for tp7
  1164. Revision 1.16 1999/02/18 13:44:31 peter
  1165. * search fixed
  1166. + backward search
  1167. * help fixes
  1168. * browser updates
  1169. Revision 1.15 1999/02/16 10:43:55 peter
  1170. * use -dGDB for the compiler
  1171. * only use gdb_file when -dDEBUG is used
  1172. * profiler switch is now a toggle instead of radiobutton
  1173. Revision 1.14 1999/02/11 19:07:22 pierre
  1174. * GDBWindow redesigned :
  1175. normal editor apart from
  1176. that any kbEnter will send the line (for begin to cursor)
  1177. to GDB command !
  1178. GDBWindow opened in Debugger Menu
  1179. still buggy :
  1180. -echo should not be present if at end of text
  1181. -GDBWindow becomes First after each step (I don't know why !)
  1182. Revision 1.13 1999/02/10 09:54:11 pierre
  1183. * cmSourceWindowClosing resets Debugger LastSource field to avoid problems
  1184. Revision 1.12 1999/02/08 17:43:44 pierre
  1185. * RestDebugger or multiple running of debugged program now works
  1186. + added DoContToCursor(F4)
  1187. * Breakpoints are now inserted correctly (was mainlyy a problem
  1188. of directories)
  1189. Revision 1.11 1999/02/08 10:37:44 peter
  1190. + html helpviewer
  1191. Revision 1.7 1999/02/04 13:32:03 pierre
  1192. * Several things added (I cannot commit them independently !)
  1193. + added TBreakpoint and TBreakpointCollection
  1194. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  1195. + Breakpoint list in INIFile
  1196. * Select items now also depend of SwitchMode
  1197. * Reading of option '-g' was not possible !
  1198. + added search for -Fu args pathes in TryToOpen
  1199. + added code for automatic opening of FileDialog
  1200. if source not found
  1201. Revision 1.6 1999/02/02 16:41:39 peter
  1202. + automatic .pas/.pp adding by opening of file
  1203. * better debuggerscreen changes
  1204. Revision 1.5 1999/01/22 18:13:22 pierre
  1205. * DoneScreen Removed I did not find any such proc ??
  1206. Revision 1.4 1999/01/22 10:24:03 peter
  1207. * first debugger things
  1208. Revision 1.3 1999/01/21 11:54:14 peter
  1209. + tools menu
  1210. + speedsearch in symbolbrowser
  1211. * working run command
  1212. Revision 1.2 1999/01/14 21:42:20 peter
  1213. * source tracking from Gabor
  1214. Revision 1.1 1999/01/12 14:29:34 peter
  1215. + Implemented still missing 'switch' entries in Options menu
  1216. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  1217. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  1218. ASCII chars and inserted directly in the text.
  1219. + Added symbol browser
  1220. * splitted fp.pas to fpide.pas
  1221. Revision 1.4 1999/01/04 11:49:41 peter
  1222. * 'Use tab characters' now works correctly
  1223. + Syntax highlight now acts on File|Save As...
  1224. + Added a new class to syntax highlight: 'hex numbers'.
  1225. * There was something very wrong with the palette managment. Now fixed.
  1226. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  1227. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  1228. process revised
  1229. Revision 1.2 1998/12/28 15:47:40 peter
  1230. + Added user screen support, display & window
  1231. + Implemented Editor,Mouse Options dialog
  1232. + Added location of .INI and .CFG file
  1233. + Option (INI) file managment implemented (see bottom of Options Menu)
  1234. + Switches updated
  1235. + Run program
  1236. Revision 1.3 1998/12/22 10:39:38 peter
  1237. + options are now written/read
  1238. + find and replace routines
  1239. }