fpide.pas 46 KB

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