fpide.pas 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508
  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 Unix}
  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,WHTMLHlp,
  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 Unix}
  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 Unix}
  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 Unix}
  712. { the video has to be initialized already for linux (JM) }
  713. if Assigned(UserScreen) then
  714. UserScreen^.SwitchBack;
  715. {$endif Unix}
  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 Unix}
  730. if Assigned(UserScreen) then
  731. UserScreen^.SwitchBack;
  732. {$endif Unix}
  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 Unix}
  765. PosExe: sw_integer;
  766. {$endif Unix}
  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 Unix}
  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 Unix}
  791. if (InFile='') and (OutFile='') then
  792. DosExecute(ProgramPath,Params)
  793. else
  794. ExecuteRedir(ProgramPath,Params,InFile,OutFile,'stderr');
  795. {$ifndef Unix}
  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 Unix}
  802. {$ifdef Unix}
  803. if (DebuggeeTTY='') and (OutFile='') then
  804. begin
  805. Write(' Press any key to return to IDE');
  806. InitKeyBoard;
  807. Keyboard.GetKeyEvent;
  808. while (Keyboard.PollKeyEvent<>0) do
  809. Keyboard.GetKeyEvent;
  810. DoneKeyboard;
  811. end;
  812. {$endif}
  813. if ExecType<>exNoSwap then
  814. ShowIDEScreen;
  815. end;
  816. DoExecute:=CanRun;
  817. end;
  818. procedure TIDEApp.Update;
  819. begin
  820. SetCmdState([cmSaveAll],IsThereAnyEditor);
  821. SetCmdState([cmCloseAll,cmWindowList],IsThereAnyWindow);
  822. SetCmdState([cmTile,cmCascade],IsThereAnyVisibleWindow);
  823. SetCmdState([cmFindProcedure,cmObjects,cmModules,cmGlobals,cmSymbol{,cmInformation}],IsSymbolInfoAvailable);
  824. {$ifndef NODEBUG}
  825. SetCmdState([cmResetDebugger,cmUntilReturn],assigned(debugger) and debugger^.debuggee_started);
  826. {$endif}
  827. SetCmdState([cmToolsMsgNext,cmToolsMsgPrev],MessagesWindow<>nil);
  828. UpdateTools;
  829. UpdateRecentFileList;
  830. UpdatePrimaryFile;
  831. UpdateINIFile;
  832. Message(Application,evBroadcast,cmCommandSetChanged,nil);
  833. end;
  834. procedure TIDEApp.SourceWindowClosed;
  835. begin
  836. if not IsClosing then
  837. Update;
  838. end;
  839. procedure TIDEApp.CurDirChanged;
  840. begin
  841. Message(Application,evBroadcast,cmUpdateTitle,nil);
  842. UpdatePrimaryFile;
  843. UpdateINIFile;
  844. UpdateMenu(MenuBar^.Menu);
  845. end;
  846. procedure TIDEApp.UpdatePrimaryFile;
  847. begin
  848. SetMenuItemParam(SearchMenuItem(MenuBar^.Menu,cmPrimaryFile),SmartPath(PrimaryFile));
  849. SetCmdState([cmClearPrimary],PrimaryFile<>'');
  850. if PrimaryFile<>'' then
  851. SetCmdState(CompileCmds,true);
  852. UpdateMenu(MenuBar^.Menu);
  853. Message(ProgramInfoWindow,evBroadcast,cmUpdate,nil);
  854. end;
  855. procedure TIDEApp.UpdateINIFile;
  856. begin
  857. SetMenuItemParam(SearchMenuItem(MenuBar^.Menu,cmSaveINI),SmartPath(IniFileName));
  858. end;
  859. procedure TIDEApp.UpdateRecentFileList;
  860. var P: PMenuItem;
  861. {ID,}I: word;
  862. FileMenu: PMenuItem;
  863. begin
  864. { ID:=cmRecentFileBase;}
  865. FileMenu:=SearchSubMenu(MenuBar^.Menu,menuFile);
  866. repeat
  867. { Inc(ID);
  868. P:=SearchMenuItem(FileMenu^.SubMenu,ID);
  869. if FileMenu^.SubMenu^.Default=P then
  870. FileMenu^.SubMenu^.Default:=FileMenu^.SubMenu^.Items;
  871. if P<>nil then RemoveMenuItem(FileMenu^.SubMenu,P);}
  872. P:=GetMenuItemBefore(FileMenu^.SubMenu,nil);
  873. if (P<>nil) then
  874. begin
  875. if (cmRecentFileBase<P^.Command) and (P^.Command<=cmRecentFileBase+MaxRecentFileCount) then
  876. begin
  877. RemoveMenuItem(FileMenu^.SubMenu,P);
  878. if FileMenu^.SubMenu^.Default=P then
  879. FileMenu^.SubMenu^.Default:=FileMenu^.SubMenu^.Items;
  880. end
  881. else
  882. P:=nil;
  883. end;
  884. until P=nil;
  885. P:=GetMenuItemBefore(FileMenu^.SubMenu,nil);
  886. if (P<>nil) and IsSeparator(P) then
  887. RemoveMenuItem(FileMenu^.SubMenu,P);
  888. if RecentFileCount>0 then
  889. AppendMenuItem(FileMenu^.SubMenu,NewLine(nil));
  890. for I:=1 to RecentFileCount do
  891. begin
  892. P:=NewItem('~'+IntToStr(I)+'~ '+ShrinkPath(SmartPath(RecentFiles[I].FileName),27),' ',
  893. kbNoKey,cmRecentFileBase+I,hcRecentFileBase+I,nil);
  894. AppendMenuItem(FileMenu^.SubMenu,P);
  895. end;
  896. end;
  897. procedure TIDEApp.UpdateTools;
  898. var P: PMenuItem;
  899. { ID,}I: word;
  900. ToolsMenu: PMenuItem;
  901. S1,S2,S3: string;
  902. W: word;
  903. begin
  904. { ID:=cmToolsBase;}
  905. ToolsMenu:=SearchSubMenu(MenuBar^.Menu,menuTools);
  906. repeat
  907. P:=GetMenuItemBefore(ToolsMenu^.SubMenu,nil);
  908. if (P<>nil) then
  909. begin
  910. if (cmToolsBase<P^.Command) and (P^.Command<=cmToolsBase+MaxToolCount) then
  911. begin
  912. RemoveMenuItem(ToolsMenu^.SubMenu,P);
  913. if ToolsMenu^.SubMenu^.Default=P then
  914. ToolsMenu^.SubMenu^.Default:=ToolsMenu^.SubMenu^.Items;
  915. end
  916. else
  917. P:=nil;
  918. end;
  919. until P=nil;
  920. P:=GetMenuItemBefore(ToolsMenu^.SubMenu,nil);
  921. if (P<>nil) and IsSeparator(P) then
  922. RemoveMenuItem(ToolsMenu^.SubMenu,P);
  923. if GetToolCount>0 then
  924. AppendMenuItem(ToolsMenu^.SubMenu,NewLine(nil));
  925. for I:=1 to GetToolCount do
  926. begin
  927. GetToolParams(I-1,S1,S2,S3,W);
  928. P:=NewItem(S1,KillTilde(GetHotKeyName(W)),W,cmToolsBase+I,hcToolsBase+I,nil);
  929. AppendMenuItem(ToolsMenu^.SubMenu,P);
  930. end;
  931. end;
  932. procedure TIDEApp.DosShell;
  933. var
  934. s : string;
  935. begin
  936. {$ifdef Unix}
  937. s:=GetEnv('SHELL');
  938. if s='' then
  939. if ExistsFile('bin/sh') then
  940. s:='bin/sh';
  941. {$else}
  942. s:=GetEnv('COMSPEC');
  943. if s='' then
  944. if ExistsFile('c:\command.com') then
  945. s:='c:\command.com'
  946. else
  947. begin
  948. s:='command.com';
  949. if Not LocateExeFile(s) then
  950. s:='';
  951. end;
  952. {$endif}
  953. if s='' then
  954. ErrorBox(msg_errorexecutingshell,nil)
  955. else
  956. DoExecute(s, '', '', '', exDosShell);
  957. end;
  958. procedure TIDEApp.ShowReadme;
  959. var R,R2: TRect;
  960. D: PCenterDialog;
  961. M: PFPMemo;
  962. VSB: PScrollBar;
  963. S: PBufStream;
  964. begin
  965. New(S, Init(ReadmeName, stOpenRead, 4096));
  966. if S^.Status=stOK then
  967. begin
  968. R.Assign(0,0,63,18);
  969. New(D, Init(R, 'Free Pascal IDE'));
  970. with D^ do
  971. begin
  972. GetExtent(R);
  973. R.Grow(-2,-2); Inc(R.B.Y);
  974. R2.Copy(R); R2.Move(1,0); R2.A.X:=R2.B.X-1;
  975. New(VSB, Init(R2)); VSB^.GrowMode:=0; Insert(VSB);
  976. New(M, Init(R,nil,VSB,nil));
  977. M^.LoadFromStream(S);
  978. M^.ReadOnly:=true;
  979. Insert(M);
  980. end;
  981. InsertOK(D);
  982. ExecuteDialog(D,nil);
  983. end;
  984. Dispose(S, Done);
  985. end;
  986. {$I FPMFILE.INC}
  987. {$I FPMEDIT.INC}
  988. {$I FPMSRCH.INC}
  989. {$I FPMRUN.INC}
  990. {$I FPMCOMP.INC}
  991. {$I FPMDEBUG.INC}
  992. {$I FPMTOOLS.INC}
  993. {$I FPMOPTS.INC}
  994. {$I FPMWND.INC}
  995. {$I FPMHELP.INC}
  996. procedure TIDEApp.AddRecentFile(AFileName: string; CurX, CurY: integer);
  997. begin
  998. if SearchRecentFile(AFileName)<>-1 then Exit;
  999. if RecentFileCount>0 then
  1000. Move(RecentFiles[1],RecentFiles[2],SizeOf(RecentFiles[1])*Min(RecentFileCount,High(RecentFiles)-1));
  1001. if RecentFileCount<High(RecentFiles) then Inc(RecentFileCount);
  1002. with RecentFiles[1] do
  1003. begin
  1004. FileName:=AFileName;
  1005. LastPos.X:=CurX; LastPos.Y:=CurY;
  1006. end;
  1007. UpdateRecentFileList;
  1008. end;
  1009. function TIDEApp.SearchRecentFile(AFileName: string): integer;
  1010. var Idx,I: integer;
  1011. begin
  1012. Idx:=-1;
  1013. for I:=1 to RecentFileCount do
  1014. if UpcaseStr(AFileName)=UpcaseStr(RecentFiles[I].FileName) then
  1015. begin Idx:=I; Break; end;
  1016. SearchRecentFile:=Idx;
  1017. end;
  1018. procedure TIDEApp.RemoveRecentFile(Index: integer);
  1019. begin
  1020. if Index<RecentFileCount then
  1021. Move(RecentFiles[Index+1],RecentFiles[Index],SizeOf(RecentFiles[1])*(RecentFileCount-Index));
  1022. Dec(RecentFileCount);
  1023. end;
  1024. function TIDEApp.GetPalette: PPalette;
  1025. var P: string;
  1026. begin
  1027. P:=AppPalette;
  1028. GetPalette:=@P;
  1029. end;
  1030. function TIDEApp.IsClosing: Boolean;
  1031. begin
  1032. IsClosing:=InsideDone;
  1033. end;
  1034. destructor TIDEApp.Done;
  1035. begin
  1036. InsideDone:=true;
  1037. inherited Done;
  1038. RemoveBrowsersCollection;
  1039. DoneHelpSystem;
  1040. end;
  1041. END.
  1042. {
  1043. $Log$
  1044. Revision 1.5 2000-11-15 00:14:10 pierre
  1045. new merge
  1046. Revision 1.1.2.12 2000/11/14 09:23:55 marco
  1047. * Second batch
  1048. Revision 1.4 2000/10/31 22:35:54 pierre
  1049. * New big merge from fixes branch
  1050. Revision 1.1.2.11 2000/10/18 21:53:27 pierre
  1051. * several Gabor fixes
  1052. Revision 1.1.2.10 2000/10/09 16:28:25 pierre
  1053. * several linux enhancements
  1054. Revision 1.1.2.9 2000/10/04 13:30:50 pierre
  1055. * DosShell for linux
  1056. Revision 1.3 2000/09/22 15:24:04 jonas
  1057. * Linux now also uses the DosExecute and ExecuteRedir procedures
  1058. (merged from fixes branch)
  1059. Revision 1.1.2.8 2000/09/22 15:19:04 jonas
  1060. * Linux now also uses the DosExecute and ExecuteRedir procedures
  1061. Revision 1.2 2000/08/22 09:41:39 pierre
  1062. * first big merge from fixes branch
  1063. Revision 1.1.2.7 2000/08/21 12:10:19 jonas
  1064. * fixed errors in my previous commit, it now works properly
  1065. Revision 1.1.2.5 2000/08/16 18:46:14 peter
  1066. [*] double clicking on a droplistbox caused GPF (due to invalid recurson)
  1067. [*] Make, Build now possible even in Compiler Messages Window
  1068. [+] when started in a new dir the IDE now ask whether to create a local
  1069. config, or to use the one located in the IDE dir
  1070. Revision 1.1.2.4 2000/08/15 03:40:53 peter
  1071. [*] no more fatal exits when the IDE can't find the error file (containing
  1072. the redirected assembler/linker output) after compilation
  1073. [*] hidden windows are now added always at the end of the Window List
  1074. [*] TINIFile parsed entries encapsulated in string delimiters incorrectly
  1075. [*] selection was incorrectly adjusted when typing in overwrite mode
  1076. [*] the line wasn't expanded when it's end was reached in overw. mode
  1077. [*] the IDE now tries to locate source files also in the user specified
  1078. unit dirs (for ex. as a response to 'Open at cursor' (Ctrl+Enter) )
  1079. [*] 'Open at cursor' is now aware of the extension (if specified)
  1080. Revision 1.1.2.3 2000/08/10 07:10:37 michael
  1081. * 'Auto save editor files' option did the opposite than expected, due
  1082. to a typo in FPIDE.PAS
  1083. + saving of source files before compilation is no longer neccessary.
  1084. When a modified editor file is involved in the compilation, then the
  1085. IDE saves it's contents to a memory stream and passes this to the
  1086. compiler (instead of the file on the disk)
  1087. Revision 1.1.2.2 2000/08/04 14:05:18 michael
  1088. * Fixes from Gabor:
  1089. [*] the IDE now doesn't disable Compile|Make & Build when all windows
  1090. are closed, but there's still a primary file set
  1091. (set bug 1059 to fixed!)
  1092. [*] the IDE didn't read some compiler options correctly back from the
  1093. FP.CFG file, for ex. the linker options. Now it read everything
  1094. correctly, and also automatically handles smartlinking option synch-
  1095. ronization.
  1096. (set bug 1048 to fixed!)
  1097. Revision 1.1.2.1 2000/07/18 05:50:22 michael
  1098. + Merged Gabors fixes
  1099. Revision 1.1 2000/07/13 09:48:34 michael
  1100. + Initial import
  1101. Revision 1.65 2000/06/22 09:07:12 pierre
  1102. * Gabor changes: see fixes.txt
  1103. Revision 1.64 2000/06/16 21:19:41 pierre
  1104. * Use Open instead of OpenSearch if OpenFileName is empty
  1105. Revision 1.63 2000/06/16 08:50:40 pierre
  1106. + new bunch of Gabor's changes
  1107. Revision 1.62 2000/06/11 07:01:33 peter
  1108. * give watches window also a number
  1109. * leave watches window in the bottom when cascading windows
  1110. Revision 1.61 2000/05/17 09:51:11 pierre
  1111. Disable/Enable keyboard on UserScreen
  1112. Revision 1.60 2000/05/02 10:20:40 pierre
  1113. * fix a small problem when deciding to call DosExecute directly
  1114. Revision 1.59 2000/05/02 08:42:27 pierre
  1115. * new set of Gabor changes: see fixes.txt
  1116. Revision 1.58 2000/04/25 08:42:33 pierre
  1117. * New Gabor changes : see fixes.txt
  1118. Revision 1.57 2000/04/18 11:42:37 pierre
  1119. lot of Gabor changes : see fixes.txt
  1120. Revision 1.56 2000/03/21 23:30:49 pierre
  1121. adapted to wcedit addition by Gabor
  1122. Revision 1.55 2000/03/13 20:41:35 pierre
  1123. + option -S to disable the mouse
  1124. * adapted to changes in fpusrscr for DOS
  1125. Revision 1.54 2000/03/07 21:57:59 pierre
  1126. + CtrlC handling
  1127. + UpdateMode method
  1128. Revision 1.53 2000/03/06 11:31:30 pierre
  1129. * Do not use COMSPEC to Run files with .EXE suffix
  1130. because Command.com at least does not return the errorcode
  1131. of the program called
  1132. Revision 1.52 2000/02/07 12:02:32 pierre
  1133. Gabor's changes
  1134. Revision 1.51 2000/01/23 21:25:17 florian
  1135. + start of internationalization support
  1136. Revision 1.50 2000/01/08 18:26:20 florian
  1137. + added a register window, doesn't work yet
  1138. Revision 1.49 2000/01/05 00:31:50 pierre
  1139. * avoid new files to use TABS
  1140. Revision 1.48 2000/01/03 11:38:33 michael
  1141. Changes from Gabor
  1142. Revision 1.47 1999/12/20 14:23:17 pierre
  1143. * MyApp renamed IDEApp
  1144. * TDebugController.ResetDebuggerRows added to
  1145. get resetting of debugger rows
  1146. Revision 1.46 1999/12/17 15:07:01 florian
  1147. + TIDEApp.Idle does always call GiveUpTimeSlice
  1148. Revision 1.45 1999/12/10 13:02:05 pierre
  1149. + VideoMode save/restore
  1150. Revision 1.44 1999/11/25 00:26:49 pierre
  1151. * RecentFiles missed the last char
  1152. Revision 1.43 1999/11/10 17:19:06 pierre
  1153. * Use DosExecute from Fpredir unit
  1154. Revision 1.42 1999/10/27 12:10:42 pierre
  1155. + With DebugUndo added 3 menu items
  1156. "Dump Undo" "Undo All" and "Redo All"
  1157. for Undo checks
  1158. Revision 1.41 1999/09/22 16:21:41 pierre
  1159. * Use ShrinkPas for RecentFiles
  1160. Revision 1.40 1999/09/22 13:04:31 pierre
  1161. + Close UserScreen to avoid store crash
  1162. Revision 1.39 1999/09/21 17:09:00 pierre
  1163. + Windows clipboard for win32
  1164. Revision 1.38 1999/09/13 16:24:43 peter
  1165. + clock
  1166. * backspace unident like tp7
  1167. Revision 1.37 1999/09/13 11:44:00 peter
  1168. * fixes from gabor, idle event, html fix
  1169. Revision 1.36 1999/09/09 14:15:27 pierre
  1170. + cmCopyWin,cmPasteWin
  1171. Revision 1.35 1999/08/16 18:25:19 peter
  1172. * Adjusting the selection when the editor didn't contain any line.
  1173. * Reserved word recognition redesigned, but this didn't affect the overall
  1174. syntax highlight speed remarkably (at least not on my Amd-K6/350).
  1175. The syntax scanner loop is a bit slow but the main problem is the
  1176. recognition of special symbols. Switching off symbol processing boosts
  1177. the performance up to ca. 200%...
  1178. * The editor didn't allow copying (for ex to clipboard) of a single character
  1179. * 'File|Save as' caused permanently run-time error 3. Not any more now...
  1180. * Compiler Messages window (actually the whole desktop) did not act on any
  1181. keypress when compilation failed and thus the window remained visible
  1182. + Message windows are now closed upon pressing Esc
  1183. + At 'Run' the IDE checks whether any sources are modified, and recompiles
  1184. only when neccessary
  1185. + BlockRead and BlockWrite (Ctrl+K+R/W) implemented in TCodeEditor
  1186. + LineSelect (Ctrl+K+L) implemented
  1187. * The IDE had problems closing help windows before saving the desktop
  1188. Revision 1.34 1999/08/03 20:22:32 peter
  1189. + TTab acts now on Ctrl+Tab and Ctrl+Shift+Tab...
  1190. + Desktop saving should work now
  1191. - History saved
  1192. - Clipboard content saved
  1193. - Desktop saved
  1194. - Symbol info saved
  1195. * syntax-highlight bug fixed, which compared special keywords case sensitive
  1196. (for ex. 'asm' caused asm-highlighting, while 'ASM' didn't)
  1197. * with 'whole words only' set, the editor didn't found occourences of the
  1198. searched text, if the text appeared previously in the same line, but didn't
  1199. satisfied the 'whole-word' condition
  1200. * ^QB jumped to (SelStart.X,SelEnd.X) instead of (SelStart.X,SelStart.Y)
  1201. (ie. the beginning of the selection)
  1202. * when started typing in a new line, but not at the start (X=0) of it,
  1203. the editor inserted the text one character more to left as it should...
  1204. * TCodeEditor.HideSelection (Ctrl-K+H) didn't update the screen
  1205. * Shift shouldn't cause so much trouble in TCodeEditor now...
  1206. * Syntax highlight had problems recognizing a special symbol if it was
  1207. prefixed by another symbol character in the source text
  1208. * Auto-save also occours at Dos shell, Tool execution, etc. now...
  1209. Revision 1.33 1999/07/12 13:14:18 pierre
  1210. * LineEnd bug corrected, now goes end of text even if selected
  1211. + Until Return for debugger
  1212. + Code for Quit inside GDB Window
  1213. Revision 1.32 1999/07/10 01:24:17 pierre
  1214. + First implementation of watches window
  1215. Revision 1.31 1999/06/29 22:50:14 peter
  1216. * more fixes from gabor
  1217. Revision 1.30 1999/06/28 19:32:20 peter
  1218. * fixes from gabor
  1219. Revision 1.29 1999/06/28 12:40:19 pierre
  1220. + RemoveBrowsersCollection in TIDEApp.Done
  1221. Revision 1.28 1999/06/25 00:46:33 pierre
  1222. + UpdateTarget to show current target
  1223. + SearchSymbol, not scope aware (this will need a PPU change !)
  1224. Revision 1.27 1999/05/22 13:44:30 peter
  1225. * fixed couple of bugs
  1226. Revision 1.26 1999/04/07 21:55:47 peter
  1227. + object support for browser
  1228. * html help fixes
  1229. * more desktop saving things
  1230. * NODEBUG directive to exclude debugger
  1231. Revision 1.25 1999/03/23 15:11:29 peter
  1232. * desktop saving things
  1233. * vesa mode
  1234. * preferences dialog
  1235. Revision 1.24 1999/03/19 16:04:29 peter
  1236. * new compiler dialog
  1237. Revision 1.23 1999/03/16 12:38:10 peter
  1238. * tools macro fixes
  1239. + tph writer
  1240. + first things for resource files
  1241. Revision 1.22 1999/03/12 01:13:57 peter
  1242. * flag if trytoopen should look for other extensions
  1243. + browser tab in the tools-compiler
  1244. Revision 1.21 1999/03/02 13:48:29 peter
  1245. * fixed far problem is fpdebug
  1246. * tile/cascading with message window
  1247. * grep fixes
  1248. Revision 1.20 1999/03/01 15:41:54 peter
  1249. + Added dummy entries for functions not yet implemented
  1250. * MenuBar didn't update itself automatically on command-set changes
  1251. * Fixed Debugging/Profiling options dialog
  1252. * TCodeEditor converts spaces to tabs at save only if efUseTabChars is
  1253. set
  1254. * efBackSpaceUnindents works correctly
  1255. + 'Messages' window implemented
  1256. + Added '$CAP MSG()' and '$CAP EDIT' to available tool-macros
  1257. + Added TP message-filter support (for ex. you can call GREP thru
  1258. GREP2MSG and view the result in the messages window - just like in TP)
  1259. * A 'var' was missing from the param-list of THelpFacility.TopicSearch,
  1260. so topic search didn't work...
  1261. * In FPHELP.PAS there were still context-variables defined as word instead
  1262. of THelpCtx
  1263. * StdStatusKeys() was missing from the statusdef for help windows
  1264. + Topic-title for index-table can be specified when adding a HTML-files
  1265. Revision 1.19 1999/02/22 11:51:36 peter
  1266. * browser updates from gabor
  1267. Revision 1.18 1999/02/22 02:15:13 peter
  1268. + default extension for save in the editor
  1269. + Separate Text to Find for the grep dialog
  1270. * fixed redir crash with tp7
  1271. Revision 1.17 1999/02/20 15:18:30 peter
  1272. + ctrl-c capture with confirm dialog
  1273. + ascii table in the tools menu
  1274. + heapviewer
  1275. * empty file fixed
  1276. * fixed callback routines in fpdebug to have far for tp7
  1277. Revision 1.16 1999/02/18 13:44:31 peter
  1278. * search fixed
  1279. + backward search
  1280. * help fixes
  1281. * browser updates
  1282. Revision 1.15 1999/02/16 10:43:55 peter
  1283. * use -dGDB for the compiler
  1284. * only use gdb_file when -dDEBUG is used
  1285. * profiler switch is now a toggle instead of radiobutton
  1286. Revision 1.14 1999/02/11 19:07:22 pierre
  1287. * GDBWindow redesigned :
  1288. normal editor apart from
  1289. that any kbEnter will send the line (for begin to cursor)
  1290. to GDB command !
  1291. GDBWindow opened in Debugger Menu
  1292. still buggy :
  1293. -echo should not be present if at end of text
  1294. -GDBWindow becomes First after each step (I don't know why !)
  1295. Revision 1.13 1999/02/10 09:54:11 pierre
  1296. * cmSourceWindowClosing resets Debugger LastSource field to avoid problems
  1297. Revision 1.12 1999/02/08 17:43:44 pierre
  1298. * RestDebugger or multiple running of debugged program now works
  1299. + added DoContToCursor(F4)
  1300. * Breakpoints are now inserted correctly (was mainlyy a problem
  1301. of directories)
  1302. Revision 1.11 1999/02/08 10:37:44 peter
  1303. + html helpviewer
  1304. Revision 1.7 1999/02/04 13:32:03 pierre
  1305. * Several things added (I cannot commit them independently !)
  1306. + added TBreakpoint and TBreakpointCollection
  1307. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  1308. + Breakpoint list in INIFile
  1309. * Select items now also depend of SwitchMode
  1310. * Reading of option '-g' was not possible !
  1311. + added search for -Fu args pathes in TryToOpen
  1312. + added code for automatic opening of FileDialog
  1313. if source not found
  1314. Revision 1.6 1999/02/02 16:41:39 peter
  1315. + automatic .pas/.pp adding by opening of file
  1316. * better debuggerscreen changes
  1317. Revision 1.5 1999/01/22 18:13:22 pierre
  1318. * DoneScreen Removed I did not find any such proc ??
  1319. Revision 1.4 1999/01/22 10:24:03 peter
  1320. * first debugger things
  1321. Revision 1.3 1999/01/21 11:54:14 peter
  1322. + tools menu
  1323. + speedsearch in symbolbrowser
  1324. * working run command
  1325. Revision 1.2 1999/01/14 21:42:20 peter
  1326. * source tracking from Gabor
  1327. Revision 1.1 1999/01/12 14:29:34 peter
  1328. + Implemented still missing 'switch' entries in Options menu
  1329. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  1330. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  1331. ASCII chars and inserted directly in the text.
  1332. + Added symbol browser
  1333. * splitted fp.pas to fpide.pas
  1334. Revision 1.4 1999/01/04 11:49:41 peter
  1335. * 'Use tab characters' now works correctly
  1336. + Syntax highlight now acts on File|Save As...
  1337. + Added a new class to syntax highlight: 'hex numbers'.
  1338. * There was something very wrong with the palette managment. Now fixed.
  1339. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  1340. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  1341. process revised
  1342. Revision 1.2 1998/12/28 15:47:40 peter
  1343. + Added user screen support, display & window
  1344. + Implemented Editor,Mouse Options dialog
  1345. + Added location of .INI and .CFG file
  1346. + Option (INI) file managment implemented (see bottom of Options Menu)
  1347. + Switches updated
  1348. + Run program
  1349. Revision 1.3 1998/12/22 10:39:38 peter
  1350. + options are now written/read
  1351. + find and replace routines
  1352. }