fpide.pas 49 KB

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