1 {
2 *****************************************************************************
3 See the file COPYING.modifiedLGPL.txt, included in this distribution,
4 for details about the license.
5 *****************************************************************************
6
7 Author: Mattias Gaertner
8
9 Abstract:
10 Interface to the general IDE functions.
11 }
12 unit LazIDEIntf;
13
14 {$mode objfpc}{$H+}
15
16 interface
17
18 uses
19 Classes, SysUtils,
20 // LCL
21 Forms, Controls, LazHelpHTML,
22 // LazUtils
23 UITypes, LazMethodList,
24 // BuildIntf
25 BaseIDEIntf, IDEOptionsIntf, CompOptsIntf, ProjectIntf, IDEExternToolIntf,
26 // IdeIntf
27 IDEOptEditorIntf, SrcEditorIntf, IDEWindowIntf;
28
29 type
30 TIDEDirective = (
31 idedNone,
32 idedBuildCommand, // Filename plus params to build the file
33 // default is '$(CompPath) $(EdFile)'
34 idedBuildWorkingDir,// Working directory for building. Default is the
35 // directory of the file
36 idedBuildScan, // Flags controlling what messages should be scanned for
37 // during building. See TIDEDirBuildScanFlag.
38 idedRunCommand, // Filename plus params to run the file
39 // default is '$NameOnly($(EdFile))'
40 idedRunWorkingDir, // Working directory for building. Default is the
41 // directory of the file
42 idedRunFlags // Flags for run. See TIDEDirRunFlag
43 );
44 TIDEDirectives = set of TIDEDirective;
45
46 TIDEDirBuildScanFlag = (
47 idedbsfNone,
48 idedbsfFPC, // scan for FPC messages. FPC+ means on (default) and FPC- off.
49 idedbsfMake // scan for MAKE messages. MAKE- means on (default) and MAKE- off.
50 );
51 TIDEDirBuildScanFlags = set of TIDEDirBuildScanFlag;
52
53 TIDEDirRunFlag = (
54 idedrfNone,
55 idedrfBuildBeforeRun, // BUILD+ means on (default for non script), BUILD- means off
56 idedrfMessages // show output in Messages window
57 );
58 TIDEDirRunFlags = set of TIDEDirRunFlag;
59 const
60 IDEDirectiveNames: array[TIDEDirective] of string = (
61 '',
62 'BuildCommand',
63 'BuildWorkingDir',
64 'BuildScan',
65 'RunCommand',
66 'RunWorkingDir',
67 'RunFlags'
68 );
69 IDEDirBuildScanFlagNames: array[TIDEDirBuildScanFlag] of string = (
70 '',
71 'FPC',
72 'MAKE'
73 );
74 IDEDirRunFlagNames: array[TIDEDirRunFlag] of string = (
75 '',
76 'BUILD',
77 'MESSAGES'
78 );
79
80 type
81 // open file flags
82 // Normally you don't need to pass any flags.
83 TOpenFlag = (
84 ofProjectLoading,// this open is part of opening a whole project
85 ofOnlyIfExists, // do not auto create non existing files
86 ofRevert, // reload file if already open, any user changes are lost without question
87 ofQuiet, // less messages
88 ofAddToRecent, // add file to recent files
89 ofRegularFile, // open as regular file (e.g. do not open projects/packages)
90 ofVirtualFile, // open the virtual file
91 ofConvertMacros, // replace macros in filename
92 ofUseCache, // do not update file from disk
93 ofMultiOpen, // set during loading multiple files
94 ofDoNotLoadResource,// do not open form, datamodule, ... (overriding default)
95 ofDoLoadResource,// do open form, datamodule, ... (overriding default)
96 ofLoadHiddenResource,// load component hidden
97 ofAddToProject, // add file to project (if exists)
98 ofInternalFile // opening data from an internal source (e.g. an editor macro (pascal script) from memory)
99 );
100 TOpenFlags = set of TOpenFlag;
101
102 const
103 OpnFlagsPlainFile = [ofOnlyIfExists,ofQuiet,ofRegularFile,ofVirtualFile,ofDoNotLoadResource];
104 type
105 // new file flags
106 // Normally you don't need to pass any flags.
107 TNewFlag = (
108 nfIsPartOfProject, // force IsPartOfProject,
109 // default is to use a heuristic
110 nfIsNotPartOfProject,// forbid IsPartOfProject
111 nfOpenInEditor, // open in editor
112 nfSave, // save file instantly
113 nfAddToRecent, // add file to recent files
114 nfQuiet, // less messages
115 nfConvertMacros, // replace macros in filename
116 nfBeautifySrc, // beautify custom source
117 nfCreateDefaultSrc,// create initial source based on the type
118 nfAskForFilename // ask for filename
119 );
120 TNewFlags = set of TNewFlag;
121
122 // save file flags
123 // Normally you don't need to pass any flags.
124 TSaveFlag = (
125 sfSaveAs,
126 sfSaveToTestDir,
127 sfProjectSaving,
128 sfCheckAmbiguousFiles,
129 sfSaveNonProjectFiles,
130 sfDoNotSaveVirtualFiles,
131 sfCanAbort, // show 'Cancel all' button in error messages
132 sfSaveMainSourceAs, // on sfSaveAs use .lpr file instead of .lpi file
133 sfQuietUnitCheck // don't ask questions when adding unit dependency.
134 );
135 TSaveFlags = set of TSaveFlag;
136
137 // close file flags
138 // Normally you don't need to pass any flags.
139 TCloseFlag = (
140 cfSaveFirst, // check if modified and save
141 cfQuiet,
142 cfProjectClosing,
143 cfCloseDependencies,
144 cfSaveDependencies // set cfSaveFirst to close the dependencies
145 );
146 TCloseFlags = set of TCloseFlag;
147
148 // build project flags
149 // Normally you don't need to pass any flags.
150 TProjectBuildFlag = (
151 pbfDoNotCompileDependencies,
152 pbfDoNotCompileProject,
153 pbfCompileDependenciesClean,
154 pbfDoNotSaveEditorFiles,
155 pbfSkipLinking,
156 pbfSkipAssembler,
157 pbfSkipTools,
158 pbfCreateMakefile
159 );
160 TProjectBuildFlags = set of TProjectBuildFlag;
161
162 // new filename flags
163 // Normally you don't need to pass any flags.
164 TSearchIDEFileFlag = (
165 siffDoNotCheckAllPackages, // do not search filename in unrelated packages (e.g. installed but not used by project)
166 siffCheckAllProjects, // search filename in all loaded projects
167 siffCaseSensitive, // check case sensitive, otherwise use Pascal case insensitivity (CompareText)
168 siffDoNotCheckOpenFiles, // do not search in files opened in source editor
169 siffIgnoreExtension // compare only filename, ignore file extension
170 );
171 TSearchIDEFileFlags = set of TSearchIDEFileFlag;
172
173 // find unit flags
174 // Normally you don't need to pass any flags.
175 TFindUnitFileFlag = (
176 fuffIgnoreUninstallPackages
177 );
178 TFindUnitFileFlags = set of TFindUnitFileFlag;
179
180 // selected part of IDE
181 TTabDisplayState = (
182 tdsNone,
183 tdsCode, // focussing sourcenotebook or source tab
184 tdsDesign, // focussing designer form/design tab
185 tdsOther // focussing other (user defined) tab assigned to module (like History Tab)
186 );
187
188 // find source flags
189 // Normally you don't need to pass any flags.
190 TFindSourceFlag = (
191 fsfSearchForProject,
192 fsfUseIncludePaths,
193 fsfUseDebugPath,
194 fsfMapTempToVirtualFiles,
195 fsfSkipPackages
196 );
197 TFindSourceFlags = set of TFindSourceFlag;
198
199 TFindUnitsOfOwnerFlag = (
200 fuooListed, // add units listed in lpi/lpk aka project inspector/package editor
201 fuooUsed, // add units used by main source file (depends on current build mode and environment)
202 fuooPackages, // extends fuooListed and fuooUsed by units from used packages
203 fuooSourceEditor // add units in source editor
204 );
205 TFindUnitsOfOwnerFlags = set of TFindUnitsOfOwnerFlag;
206
207 TModalResultFunction = function(Sender: TObject): TModalResult of object;
208 TLazProjectChangedFunction = function(Sender: TObject;
209 AProject: TLazProject): TModalResult of object;
210 TModalHandledFunction = function(Sender: TObject; var Handled: boolean
211 ): TModalResult of object;
212 TGetFPCFrontEndParams = function(Sender: TObject;
213 var Params: string // these parameters are passed to fpc.
214 // Global options should be prependended, project options should be appended.
215 ): boolean of object;
216
217 TSaveEditorFileStep = (
218 sefsSaveAs, // called after user selected a new filename and IDE did some sanity checks
219 sefsBeforeWrite, // called before writing to disk, aFile.Filename=TargetFilename
220 sefsAfterWrite, // called after writing to disk, aFile.Filename=TargetFilename
221 sefsSavedAs // see sefsSaveAs, called after writing and cleaning up, TargetFilename is old filename
222 );
223 TSaveEditorFileEvent = function(Sender: TObject; aFile: TLazProjectFile;
224 SaveStep: TSaveEditorFileStep; TargetFilename: string): TModalResult of object;
225
226 TShowDesignerFormOfSourceFunction = procedure(Sender: TObject; AEditor: TSourceEditorInterface;
227 AComponentPaletteClassSelected: Boolean) of object;
228 TGetFPCFrontEndPath = function(Sender: TObject;
229 var Path: string // this path is prepended to fpc.
230 ): boolean of object;
231
232 TLazarusIDEHandlerType = (
233 lihtSavingAll, // called before IDE saves everything
234 lihtSavedAll, // called after IDE saved everything
235 lihtSaveEditorFile, // called when IDE saves an editor file to disk
236 lihtSaveAsEditorFile, // called after user selected a new filename for an editor file
237 lihtIDERestoreWindows, // called when IDE is restoring the windows (before opening the first project)
238 lihtIDEClose, // called when IDE is shutting down (after closequery, so no more interactivity)
239 lihtProjectOpening,// called before IDE opens a project
240 lihtProjectOpened,// called after IDE opened a project
241 lihtProjectClose, // called before IDE closes a project
242 lihtProjectBuilding, // called before IDE builds the project
243 lihtProjectDependenciesCompiling, // called before IDE compiles dependencies of project
244 lihtProjectDependenciesCompiled, // called after IDE compiled dependencies of project
245 lihtProjectBuildingFinished, // called after IDE builds the project
246 lihtLazarusBuilding, // called before IDE builds Lazarus IDE
247 lihtLazarusBuildingFinished, // called after IDE builds Lazarus IDE
248 lihtQuickSyntaxCheck, // called when quick syntax check is clicked (menu item or shortcut)
249 lihtGetFPCFrontEndParams, // called when the IDE gets the parameters of the 'fpc' front end tool
250 lihtGetFPCFrontEndPath, // called when the IDE gets the path of the 'fpc' front end tool
251 lihtShowDesignerFormOfSource, // called after showing a designer form for code editor (AEditor can be nil!)
252 lihtShowSourceOfActiveDesignerForm, // called after showing a code of designer form
253 lihtChangeToolStatus, //called when IDEToolStatus has changed (e.g. itNone->itBuilder etc.)
254 lihtRunDebugInit, // called when Run was clicked, after building, before debugger class is initialized
255 lihtRunDebug, // called when Run was clicked, after building, after debugger class was initialized, before starting the debugger
256 lihtRunWithoutDebugBuilding, // called when Run a project without debugger was clicked, before building
257 lihtRunWithoutDebugInit, // called when Run a project without debugger was clicked, after building
258 lihtRunFinished //called when ran program finishes
259 );
260
261 TLazToolStatus = (
262 itNone, // The default mode. All editing allowed.
263 itExiting, // the ide is shutting down
264 itBuilder, // compiling (the project, a package, IDE itself, an external tool)
265 // Loading/Saving/Debugging is not allowed.
266 itDebugger, // debugging the project.
267 // Loading/Saving/Compiling is not allowed.
268 itCodeTools, // the CodeToolBoss is working and has called the progress event.
269 itCodeToolAborting,// the CodeToolBoss is working and is about to abort
270 itCustom // this state is not used yet.
271 );
272 TLazToolStatusChangeEvent = procedure(Sender: TObject; OldStatus, NewStatus: TLazToolStatus) of object;
273
274 TLazBuildingFinishedEvent = procedure(Sender: TObject; BuildSuccessful: Boolean) of object;
275
276 { TLazIDEInterface }
277
278 TLazIDEInterface = class(TComponent)
279 private
280 FToolStatus: TLazToolStatus;
281 FMainBarSubTitle: string;
282 FOpenEditorsOnCodeToolChange: boolean;
283 FOpenMainSourceOnCodeToolChange: boolean;
284 FSaveClosedSourcesOnCodeToolChange: boolean;
285 FCheckFilesOnDiskEnabled: boolean;
286 procedure AddHandler(HandlerType: TLazarusIDEHandlerType;
287 const AMethod: TMethod; AsLast: boolean = false);
288 procedure RemoveHandler(HandlerType: TLazarusIDEHandlerType;
289 const AMethod: TMethod);
290 protected
291 FLazarusIDEHandlers: array[TLazarusIDEHandlerType] of TMethodList;
292 FOwningComponent: TComponent;
293 FIDEStarted: boolean;
294 FIDEIsClosing: Boolean;
295 FLastActivatedWindows: TFPList;
296 // used to find the last form so you can display the correct tab
297 FLastFormActivated: TCustomForm;
298
299 procedure SetToolStatus(const AToolStatus: TLazToolStatus); virtual;
300 function GetActiveProject: TLazProject; virtual; abstract;
301 procedure DoCallNotifyHandler(HandlerType: TLazarusIDEHandlerType); overload;
302 function DoCallModalFunctionHandler(HandlerType: TLazarusIDEHandlerType
303 ): TModalResult;
304 function DoCallModalHandledHandler(HandlerType: TLazarusIDEHandlerType;
305 var Handled: boolean): TModalResult;
306 procedure DoCallNotifyHandler(HandlerType: TLazarusIDEHandlerType;
307 Sender: TObject); overload;
308 procedure DoCallShowDesignerFormOfSourceHandler(Sender: TObject;
309 AEditor: TSourceEditorInterface; AComponentPaletteClassSelected: Boolean);
310 procedure DoCallBuildingFinishedHandler(HandlerType: TLazarusIDEHandlerType;
311 Sender: TObject; BuildSuccessful: Boolean);
312
313 procedure SetMainBarSubTitle(const AValue: string); virtual;
314 public
315 constructor Create(TheOwner: TComponent); override;
316 destructor Destroy; override;
317 property OwningComponent: TComponent read FOwningComponent;
318
319 property ToolStatus: TLazToolStatus read FToolStatus write SetToolStatus;
320
321 // the main window with the IDE menu
322 function GetMainBar: TForm; virtual; abstract;
323 property MainBarSubTitle: string read FMainBarSubTitle write SetMainBarSubTitle;
324
325 // find file
326 function FindUnitFile(const AFilename: string; TheOwner: TObject = nil;
327 Flags: TFindUnitFileFlags = []): string; virtual; abstract;
328 function FindSourceFile(const AFilename, BaseDirectory: string;
329 Flags: TFindSourceFlags): string; virtual; abstract;
330
331 // file
332 function DoNewEditorFile(NewFileDescriptor: TProjectFileDescriptor;
333 NewFilename: string; const NewSource: string;
334 NewFlags: TNewFlags): TModalResult;
335 function DoNewFile(NewFileDescriptor: TProjectFileDescriptor;
336 var NewFilename: string; NewSource: string;
337 NewFlags: TNewFlags; NewOwner: TObject): TModalResult; virtual; abstract;
338 function DoSaveEditorFile(AEditor: TSourceEditorInterface;
339 Flags: TSaveFlags): TModalResult; virtual; abstract;
340 function DoSaveEditorFile(const Filename: string;
341 Flags: TSaveFlags): TModalResult; virtual; abstract;
342 function DoSaveAll(Flags: TSaveFlags): TModalResult; virtual; abstract;
343 function DoCloseEditorFile(AEditor: TSourceEditorInterface;
344 Flags: TCloseFlags):TModalResult; virtual; abstract;
345 function DoCloseEditorFile(const Filename: string;
346 Flags: TCloseFlags): TModalResult; virtual; abstract;
347 function DoOpenEditorFile(AFileName:string; PageIndex, WindowIndex: integer;
348 Flags: TOpenFlags): TModalResult; virtual; abstract;
349 function DoOpenFileAndJumpToIdentifier(const AFilename, AnIdentifier: string;
350 PageIndex, WindowIndex: integer; Flags: TOpenFlags): TModalResult; virtual; abstract;
351 function DoOpenFileAndJumpToPos(const AFilename: string;
352 const CursorPosition: TPoint; TopLine: integer;
353 PageIndex, WindowIndex: integer; Flags: TOpenFlags): TModalResult; overload;
354 function DoOpenFileAndJumpToPos(const AFilename: string;
355 const CursorPosition: TPoint; TopLine, BlockTopLine, BlockBottomLine: integer;
356 PageIndex, WindowIndex: integer; Flags: TOpenFlags): TModalResult; virtual; abstract; overload;
357 function DoRevertEditorFile(const Filename: string): TModalResult; virtual; abstract;
358 function DoOpenComponent(const UnitFilename: string; OpenFlags: TOpenFlags;
359 CloseFlags: TCloseFlags;
360 out Component: TComponent): TModalResult; virtual; abstract;
361 procedure DoDropFiles(Sender: TObject; const FileNames: array of String;
362 WindowIndex: integer = -1); virtual; abstract;
363 function DoConfigureBuildFile: TModalResult; virtual; abstract;
364 function DoBuildFile({%H-}ShowAbort: Boolean;
365 Filename: string = '' // if empty use active source editor file
366 ): TModalResult; virtual; abstract;
367 function DoRunFile(Filename: string = '' // if empty use active source editor file
368 ): TModalResult; virtual; abstract;
369
370 // project
371 property ActiveProject: TLazProject read GetActiveProject;
372 function DoNewProject(ProjectDesc: TProjectDescriptor): TModalResult; virtual; abstract;
373 function DoSaveProject(Flags: TSaveFlags): TModalResult; virtual; abstract;
374 function DoCloseProject: TModalResult; virtual; abstract;
375 function DoOpenProjectFile(AFileName: string;
376 Flags: TOpenFlags): TModalResult; virtual; abstract;
377 function DoPublishProject(Flags: TSaveFlags;
378 ShowDialog: boolean): TModalResult; virtual; abstract;
379 function DoBuildProject(const AReason: TCompileReason;
380 Flags: TProjectBuildFlags;
381 FinalizeResources: boolean = True): TModalResult; virtual; abstract;
382 function DoRunProject: TModalResult; virtual; abstract;
383 function DoRunProjectWithoutDebug: TModalResult; virtual; abstract;
384 function GetProjectFileForProjectEditor(AEditor: TSourceEditorInterface): TLazProjectFile; virtual; abstract;
385 function DoCallProjectChangedHandler(HandlerType: TLazarusIDEHandlerType;
386 AProject: TLazProject): TModalResult;
387 function DoCallRunDebugInit(var Handled: boolean): TModalResult;
388 function DoCallRunDebug(var Handled: boolean): TModalResult;
389 function DoCallRunWithoutDebugBuilding(var Handled: boolean): TModalResult;
390 function DoCallRunWithoutDebugInit(var Handled: boolean): TModalResult;
391 procedure DoCallRunFinishedHandler;
392 function DoAddUnitToProject(AEditor: TSourceEditorInterface): TModalResult; virtual; abstract;
393
394 // configs
395 class function GetPrimaryConfigPath: String; virtual; abstract;
396 class function GetSecondaryConfigPath: String; virtual; abstract;
397 procedure CopySecondaryConfigFile(const AFilename: String); virtual; abstract;
398 function DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass = nil;
399 ACaption: String = ''): Boolean; overload;
400 function DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass;
401 ACaption: String; AOptionsFilter: array of TAbstractIDEOptionsClass;
402 ASettings: TIDEOptionsEditorSettings): Boolean; overload; virtual; abstract;
403
404 // filenames, paths
405 function CreateNewUniqueFilename(const Prefix, Ext: string;
406 NewOwner: TObject; Flags: TSearchIDEFileFlags;
407 TryWithoutNumber: boolean): string; virtual; abstract;
408 function GetTestBuildDirectory: string; virtual; abstract;
409 function GetCompilerFilename: string; virtual; abstract;
410 function GetFPCompilerFilename: string; virtual; abstract;
411 function GetFPCFrontEndOptions: string; virtual; abstract;
412
413 // codetools
414 function BeginCodeTools: boolean; virtual; abstract;
415 function DoShowCodeToolBossError: TMessageLine; virtual; abstract;
416 procedure DoJumpToCodeToolBossError; virtual; abstract;
417 function NeedSaveSourceEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean; virtual; abstract;
418 function SaveSourceEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean; virtual; abstract; // true if something was saved
419 function FindUnitsOfOwner(TheOwner: TObject; Flags: TFindUnitsOfOwnerFlags): TStrings; virtual; abstract;
420 property OpenEditorsOnCodeToolChange: boolean read FOpenEditorsOnCodeToolChange
421 write FOpenEditorsOnCodeToolChange;
422 property SaveClosedSourcesOnCodeToolChange: boolean read FSaveClosedSourcesOnCodeToolChange
423 write FSaveClosedSourcesOnCodeToolChange;
424 property OpenMainSourceOnCodeToolChange: boolean read FOpenMainSourceOnCodeToolChange
425 write FOpenMainSourceOnCodeToolChange;
426
427 // progress and error messages
428 function ShowProgress(const SomeText: string;
429 Step, MaxStep: integer): boolean; virtual; abstract; // False if canceled by user
430 function GetSelectedCompilerMessage: TMessageLine; virtual; abstract;
431 function DoJumpToCompilerMessage(FocusEditor: boolean;
432 Msg: TMessageLine = nil // if nil then it jumps to first message
433 ): boolean; virtual; abstract;
434 procedure DoJumpToNextCompilerMessage(aMinUrgency: TMessageLineUrgency; DirectionDown: boolean); virtual; abstract;
435 procedure DoJumpToNextError(DirectionDown: boolean);
436 procedure DoShowMessagesView(BringToFront: boolean = true); virtual; abstract;
437 function DoCheckFilesOnDisk(Instantaneous: boolean = false): TModalResult; virtual; abstract;
438 // call this after changing TargetOS/TargetCPU of the ActiveProject
439 procedure PrepareBuildTarget(Quiet: boolean;
440 ScanFPCSrc: TScanModeFPCSources = smsfsBackground); virtual; abstract;
441 procedure AbortBuild; virtual; abstract;
442
443 // search results
444 procedure DoShowSearchResultsView(State: TIWGetFormState = iwgfShowOnTop); virtual; abstract;
445
446 // designer
447 function GetDesignerForProjectEditor(AEditor: TSourceEditorInterface;
448 LoadForm: boolean): TIDesigner; virtual; abstract;
449 function GetDesignerWithProjectFile(AFile: TLazProjectFile;
450 LoadForm: boolean): TIDesigner; virtual; abstract;
451 function GetProjectFileWithRootComponent(AComponent: TComponent): TLazProjectFile; virtual; abstract;
452 function GetProjectFileWithDesigner(ADesigner: TIDesigner): TLazProjectFile; virtual; abstract;
453
454 procedure DoShowDesignerFormOfSrc(AEditor: TSourceEditorInterface); virtual; abstract; overload;
455 procedure DoShowMethod(AEditor: TSourceEditorInterface; const AMethodName: String); virtual; abstract;
456 procedure DoShowDesignerFormOfSrc(AEditor: TSourceEditorInterface; out AForm: TCustomForm); virtual; abstract; overload;
457
458 // events
459 procedure RemoveAllHandlersOfObject(AnObject: TObject);
460 procedure AddHandlerOnSavingAll(const OnSaveAllEvent: TModalResultFunction;
461 AsLast: boolean = false);
462 procedure RemoveHandlerOnSavingAll(const OnSaveAllEvent: TModalResultFunction);
463 procedure AddHandlerOnSavedAll(const OnSaveAllEvent: TModalResultFunction;
464 AsLast: boolean = false);
465 procedure RemoveHandlerOnSavedAll(const OnSaveAllEvent: TModalResultFunction);
466 procedure AddHandlerOnSaveEditorFile(const OnSaveEditorFile: TSaveEditorFileEvent;
467 AsLast: boolean = false);
468 procedure RemoveHandlerOnSaveEditorFile(const OnSaveEditorFile: TSaveEditorFileEvent);
469 procedure AddHandlerOnIDERestoreWindows(const OnIDERestoreWindowsEvent: TNotifyEvent;
470 AsLast: boolean = false);
471 procedure RemoveHandlerOnIDERestoreWindows(
472 const OnIDERestoreWindowsEvent: TNotifyEvent);
473 procedure AddHandlerOnIDEClose(const OnIDECloseEvent: TNotifyEvent;
474 AsLast: boolean = false);
475 procedure RemoveHandlerOnIDEClose(const OnIDECloseEvent: TNotifyEvent);
476 procedure AddHandlerOnProjectOpening(
477 const OnProjectOpeningEvent: TLazProjectChangedFunction;
478 AsLast: boolean = false);
479 procedure RemoveHandlerOnProjectOpening(
480 const OnProjectOpeningEvent: TLazProjectChangedFunction);
481 procedure AddHandlerOnProjectOpened(
482 const OnProjectOpenedEvent: TLazProjectChangedFunction;
483 AsLast: boolean = false);
484 procedure RemoveHandlerOnProjectOpened(
485 const OnProjectOpenedEvent: TLazProjectChangedFunction);
486 procedure AddHandlerOnProjectClose(
487 const OnProjectCloseEvent: TLazProjectChangedFunction;
488 AsLast: boolean = false);
489 procedure RemoveHandlerOnProjectClose(
490 const OnProjectCloseEvent: TLazProjectChangedFunction);
491 procedure AddHandlerOnProjectBuilding(
492 const OnProjBuildingEvent: TModalResultFunction;
493 AsLast: boolean = false);
494 procedure RemoveHandlerOnProjectBuilding(
495 const OnProjBuildingEvent: TModalResultFunction);
496 procedure AddHandlerOnProjectBuildingFinished(
497 const OnProjBuildingFinishedEvent: TLazBuildingFinishedEvent;
498 AsLast: boolean = false);
499 procedure RemoveHandlerOnProjectBuildingFinished(
500 const OnProjBuildingFinishedEvent: TLazBuildingFinishedEvent);
501 procedure AddHandlerOnProjectDependenciesCompiling(
502 const OnProjDependenciesCompilingEvent: TModalResultFunction;
503 AsLast: boolean = false);
504 procedure RemoveHandlerOnProjectDependenciesCompiling(
505 const OnProjDependenciesCompilingEvent: TModalResultFunction);
506 procedure AddHandlerOnProjectDependenciesCompiled(
507 const OnProjDependenciesCompiledEvent: TModalResultFunction;
508 AsLast: boolean = false);
509 procedure RemoveHandlerOnProjectDependenciesCompiled(
510 const OnProjDependenciesCompiledEvent: TModalResultFunction);
511 procedure AddHandlerOnLazarusBuilding(
512 const OnLazBuildingEvent: TModalResultFunction;
513 AsLast: boolean = false);
514 procedure RemoveHandlerOnLazarusBuilding(
515 const OnLazBuildingEvent: TModalResultFunction);
516 procedure AddHandlerOnLazarusBuildingFinished(
517 const OnLazBuildingFinishedEvent: TLazBuildingFinishedEvent;
518 AsLast: boolean = false);
519 procedure RemoveHandlerOnLazarusBuildingFinished(
520 const OnLazBuildingFinishedEvent: TLazBuildingFinishedEvent);
521 procedure AddHandlerOnQuickSyntaxCheck(
522 const OnQuickSyntaxCheckEvent: TModalHandledFunction;
523 AsLast: boolean = false);
524 procedure RemoveHandlerOnQuickSyntaxCheck(
525 const OnQuickSyntaxCheckEvent: TModalHandledFunction);
526 procedure AddHandlerGetFPCFrontEndParams(
527 const Handler: TGetFPCFrontEndParams; AsLast: boolean = false);
528 procedure RemoveHandlerGetFPCFrontEndParams(
529 const Handler: TGetFPCFrontEndParams);
530 function CallHandlerGetFPCFrontEndParams(Sender: TObject; var Params: string): boolean;
531 procedure AddHandlerGetFPCFrontEndPath(
532 const Handler: TGetFPCFrontEndPath; AsLast: boolean = false);
533 procedure RemoveHandlerGetFPCFrontEndPath(const Handler: TGetFPCFrontEndPath);
534 function CallHandlerGetFPCFrontEndPath(Sender: TObject; var Path: string): boolean;
535 procedure AddHandlerOnShowDesignerFormOfSource(
536 const OnShowDesignerFormOfSourceEvent: TShowDesignerFormOfSourceFunction;
537 AsLast: boolean = false);
538 procedure RemoveHandlerOnShowDesignerFormOfSource(
539 const OnShowDesignerFormOfSourceEvent: TShowDesignerFormOfSourceFunction);
540 procedure AddHandlerOnShowSourceOfActiveDesignerForm(
541 const OnShowSourceOfActiveDesignerForm: TNotifyEvent;
542 AsLast: boolean = false);
543 procedure RemoveHandlerOnShowSourceOfActiveDesignerForm(
544 const OnShowSourceOfActiveDesignerForm: TNotifyEvent);
545 procedure AddHandlerOnChangeToolStatus(
546 const OnChangeToolStatus: TLazToolStatusChangeEvent;
547 AsLast: boolean = false);
548 procedure RemoveHandlerOnChangeToolStatus(
549 const OnChangeToolStatus: TLazToolStatusChangeEvent);
550 procedure AddHandlerOnRunDebugInit(const Event: TModalHandledFunction;
551 AsLast: boolean = false);
552 procedure RemoveHandlerOnRunDebugInit(const Event: TModalHandledFunction);
553 procedure AddHandlerOnRunDebug(const Event: TModalHandledFunction;
554 AsLast: boolean = false);
555 procedure RemoveHandlerOnRunDebug(const Event: TModalHandledFunction);
556 procedure AddHandlerOnRunWithoutDebugBuilding(const Event: TModalHandledFunction;
557 AsLast: boolean = false);
558 procedure RemoveHandlerOnRunWithoutDebugBuilding(const Event: TModalHandledFunction);
559 procedure AddHandlerOnRunWithoutDebugInit(const Event: TModalHandledFunction;
560 AsLast: boolean = false);
561 procedure RemoveHandlerOnRunWithoutDebugInit(const Event: TModalHandledFunction);
562 procedure AddHandlerOnRunFinished(const OnRunFinishedEvent: TNotifyEvent;
563 AsLast: boolean = false);
564 procedure RemoveHandlerOnRunFinished(const OnRunFinishedEvent: TNotifyEvent);
565
566 property IDEStarted: boolean read FIDEStarted;
567 property IDEIsClosing: boolean read FIDEIsClosing;
568 property LastActivatedWindows: TFPList read FLastActivatedWindows;
569 property LastFormActivated: TCustomForm read FLastFormActivated write FLastFormActivated;
570 property CheckFilesOnDiskEnabled: boolean read FCheckFilesOnDiskEnabled write FCheckFilesOnDiskEnabled;
571 end;
572
573 { TIDETabMaster }
574
575 TIDETabMaster = class
576 protected
577 function GetTabDisplayState: TTabDisplayState; virtual; abstract;
578 function GetTabDisplayStateEditor(Index: TSourceEditorInterface): TTabDisplayState; virtual; abstract;
579 public
580 function AutoSizeInShowDesigner(AControl: TControl): Boolean; virtual; abstract;
581 function GetDesigner(ASourceEditor: TSourceEditorInterface; ATabDisplayState: TTabDisplayState): TIDesigner; virtual;
582 procedure ToggleFormUnit; virtual; abstract;
583 procedure JumpToCompilerMessage(ASourceEditor: TSourceEditorInterface); virtual; abstract;
584 procedure ShowCode(ASourceEditor: TSourceEditorInterface); virtual; abstract;
585 procedure ShowDesigner(ASourceEditor: TSourceEditorInterface; AIndex: Integer = 0); virtual; abstract;
586 procedure ShowForm(AForm: TCustomForm); virtual; abstract;
587 public
588 property TabDisplayState: TTabDisplayState read GetTabDisplayState;
589 property TabDisplayStateEditor[Index: TSourceEditorInterface]: TTabDisplayState read GetTabDisplayStateEditor;
590 end;
591
592 var
593 LazarusIDE: TLazIDEInterface = nil; // will be set by the IDE
594 IDETabMaster: TIDETabMaster = nil;
595
596 type
597 TLazarusIDEBootHandlerType = (
598 libhTransferMacrosCreated, // called after IDEMacros were created
599 libhEnvironmentOptionsLoaded // called after IDE loaded environment options
600 );
601
602 procedure AddBootHandler(ht: TLazarusIDEBootHandlerType; const OnBoot: TProcedure);
603
604 implementation
605
606 type
607 TArrayOfProc = array of TProcedure;
608 var
609 BootHandlers: array[TLazarusIDEBootHandlerType] of TArrayOfProc;
610
611 procedure AddBootHandler(ht: TLazarusIDEBootHandlerType; const OnBoot: TProcedure);
612 var
613 l: Integer;
614 begin
615 l:=length(BootHandlers[ht]);
616 SetLength(BootHandlers[ht],l+1);
617 BootHandlers[ht][l]:=OnBoot;
618 end;
619
620 procedure RunBootHandlers(ht: TLazarusIDEBootHandlerType);Public name 'ideintf_LazIDEIntf_RunBootHandlers';
621 var
622 i: Integer;
623 begin
624 for i:=0 to length(BootHandlers[ht])-1 do
625 BootHandlers[ht][i]();
626 end;
627
628 { TIDETabMaster }
629
GetDesignernull630 function TIDETabMaster.GetDesigner(ASourceEditor: TSourceEditorInterface;
631 ATabDisplayState: TTabDisplayState): TIDesigner;
632 begin
633 case ATabDisplayState of
634 tdsDesign:
635 Result := ASourceEditor.GetDesigner(True);
636 else
637 Result := nil;
638 end;
639 end;
640
641 { TLazIDEInterface }
642
643 procedure TLazIDEInterface.AddHandler(HandlerType: TLazarusIDEHandlerType;
644 const AMethod: TMethod; AsLast: boolean);
645 begin
646 if FLazarusIDEHandlers[HandlerType]=nil then
647 FLazarusIDEHandlers[HandlerType]:=TMethodList.Create;
648 FLazarusIDEHandlers[HandlerType].Add(AMethod,AsLast);
649 end;
650
651 procedure TLazIDEInterface.RemoveHandler(HandlerType: TLazarusIDEHandlerType;
652 const AMethod: TMethod);
653 begin
654 FLazarusIDEHandlers[HandlerType].Remove(AMethod);
655 end;
656
657 procedure TLazIDEInterface.SetMainBarSubTitle(const AValue: string);
658 begin
659 if FMainBarSubTitle=AValue then exit;
660 FMainBarSubTitle:=AValue;
661 end;
662
663 procedure TLazIDEInterface.SetToolStatus(const AToolStatus: TLazToolStatus);
664 var
665 xMethod: TLazToolStatusChangeEvent;
666 I: Integer;
667 OldToolStatus: TLazToolStatus;
668 begin
669 if FToolStatus=aToolStatus then Exit;
670
671 OldToolStatus:=FToolStatus;
672 FToolStatus:=AToolStatus;
673
674 for I := 0 to FLazarusIDEHandlers[lihtChangeToolStatus].Count-1 do
675 begin
676 xMethod := TLazToolStatusChangeEvent(FLazarusIDEHandlers[lihtChangeToolStatus][I]);
677 xMethod(Self, OldToolStatus, AToolStatus);
678 end;
679 end;
680
681 procedure TLazIDEInterface.DoCallNotifyHandler(
682 HandlerType: TLazarusIDEHandlerType);
683 begin
684 FLazarusIDEHandlers[HandlerType].CallNotifyEvents(Self);
685 end;
686
DoCallModalFunctionHandlernull687 function TLazIDEInterface.DoCallModalFunctionHandler(
688 HandlerType: TLazarusIDEHandlerType): TModalResult;
689 var
690 i: Integer;
691 CurResult: TModalResult;
692 Handler: TMethodList;
693 begin
694 Result:=mrOk;
695 Handler:=FLazarusIDEHandlers[HandlerType];
696 i:=Handler.Count;
697 while Handler.NextDownIndex(i) do begin
698 CurResult:=TModalResultFunction(Handler[i])(Self);
699 if CurResult=mrAbort then exit(mrAbort);
700 if CurResult<>mrOk then Result:=mrCancel;
701 end;
702 end;
703
DoCallProjectChangedHandlernull704 function TLazIDEInterface.DoCallProjectChangedHandler(
705 HandlerType: TLazarusIDEHandlerType; AProject: TLazProject): TModalResult;
706 var
707 i: Integer;
708 CurResult: TModalResult;
709 Handler: TMethodList;
710 begin
711 Result:=mrOk;
712 LastActivatedWindows.Clear; // IDE windows may change.
713 Handler:=FLazarusIDEHandlers[HandlerType];
714 i:=Handler.Count;
715 while Handler.NextDownIndex(i) do begin
716 CurResult:=TLazProjectChangedFunction(Handler[i])(Self,AProject);
717 if CurResult=mrAbort then exit(mrAbort);
718 if CurResult<>mrOk then Result:=mrCancel;
719 end;
720 end;
721
DoCallModalHandledHandlernull722 function TLazIDEInterface.DoCallModalHandledHandler(
723 HandlerType: TLazarusIDEHandlerType; var Handled: boolean): TModalResult;
724 var
725 i: longint;
726 Handler: TMethodList;
727 begin
728 Handler:=FLazarusIDEHandlers[HandlerType];
729 i:=Handler.Count;
730 while Handler.NextDownIndex(i) do
731 begin
732 Handled:=false;
733 Result:=TModalHandledFunction(Handler[i])(Self,Handled);
734 if Handled then exit;
735 end;
736 Result:=mrOk;
737 end;
738
739 procedure TLazIDEInterface.DoCallNotifyHandler(HandlerType: TLazarusIDEHandlerType; Sender: TObject);
740 begin
741 FLazarusIDEHandlers[HandlerType].CallNotifyEvents(Sender);
742 end;
743
744 procedure TLazIDEInterface.DoCallShowDesignerFormOfSourceHandler(Sender: TObject;
745 AEditor: TSourceEditorInterface; AComponentPaletteClassSelected: Boolean);
746 var
747 i: Integer;
748 Handler: TMethodList;
749 begin
750 Handler:=FLazarusIDEHandlers[lihtShowDesignerFormOfSource];
751 i := Handler.Count;
752 while Handler.NextDownIndex(i) do
753 TShowDesignerFormOfSourceFunction(Handler[i])(Sender, AEditor,
754 AComponentPaletteClassSelected);
755 end;
756
757 procedure TLazIDEInterface.DoJumpToNextError(DirectionDown: boolean);
758 begin
759 DoJumpToNextCompilerMessage(mluError, DirectionDown);
760 end;
761
762 constructor TLazIDEInterface.Create(TheOwner: TComponent);
763 begin
764 LazarusIDE:=Self;
765 FCheckFilesOnDiskEnabled:=True;
766 inherited Create(TheOwner);
767 end;
768
769 destructor TLazIDEInterface.Destroy;
770 var
771 HandlerType: TLazarusIDEHandlerType;
772 begin
773 for HandlerType := Low(TLazarusIDEHandlerType) to High(TLazarusIDEHandlerType) do
774 FreeAndNil(FLazarusIDEHandlers[HandlerType]);
775 inherited Destroy;
776 LazarusIDE:=nil;
777 end;
778
DoNewEditorFilenull779 function TLazIDEInterface.DoNewEditorFile(
780 NewFileDescriptor: TProjectFileDescriptor; NewFilename: string;
781 const NewSource: string; NewFlags: TNewFlags): TModalResult;
782 begin
783 Result:=DoNewFile(NewFileDescriptor,NewFilename,NewSource,NewFlags,nil);
784 end;
785
DoOpenFileAndJumpToPosnull786 function TLazIDEInterface.DoOpenFileAndJumpToPos(const AFilename: string;
787 const CursorPosition: TPoint; TopLine: integer; PageIndex,
788 WindowIndex: integer; Flags: TOpenFlags): TModalResult;
789 begin
790 Result := DoOpenFileAndJumpToPos(AFilename, CursorPosition, TopLine, TopLine, TopLine, PageIndex, WindowIndex, Flags);
791 end;
792
DoOpenIDEOptionsnull793 function TLazIDEInterface.DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass;
794 ACaption: String): Boolean;
795 begin
796 Result := DoOpenIDEOptions(AEditor, ACaption, [], []);
797 end;
798
799 procedure TLazIDEInterface.DoCallBuildingFinishedHandler(
800 HandlerType: TLazarusIDEHandlerType; Sender: TObject; BuildSuccessful: Boolean);
801 var
802 I: Integer;
803 xMethod: TLazBuildingFinishedEvent;
804 begin
805 for I := 0 to FLazarusIDEHandlers[HandlerType].Count-1 do
806 begin
807 xMethod := TLazBuildingFinishedEvent(FLazarusIDEHandlers[HandlerType][I]);
808 xMethod(Sender, BuildSuccessful);
809 end;
810 end;
811
DoCallRunDebugInitnull812 function TLazIDEInterface.DoCallRunDebugInit(var Handled: boolean
813 ): TModalResult;
814 begin
815 Result:=DoCallModalHandledHandler(lihtRunDebugInit,Handled);
816 end;
817
DoCallRunDebugnull818 function TLazIDEInterface.DoCallRunDebug(var Handled: boolean): TModalResult;
819 begin
820 Result:=DoCallModalHandledHandler(lihtRunDebug,Handled);
821 end;
822
DoCallRunWithoutDebugBuildingnull823 function TLazIDEInterface.DoCallRunWithoutDebugBuilding(var Handled: boolean
824 ): TModalResult;
825 begin
826 Result:=DoCallModalHandledHandler(lihtRunWithoutDebugBuilding,Handled);
827 end;
828
DoCallRunWithoutDebugInitnull829 function TLazIDEInterface.DoCallRunWithoutDebugInit(var Handled: boolean
830 ): TModalResult;
831 begin
832 Result:=DoCallModalHandledHandler(lihtRunWithoutDebugInit,Handled);
833 end;
834
835 procedure TLazIDEInterface.DoCallRunFinishedHandler;
836 begin
837 DoCallNotifyHandler(lihtRunFinished);
838 end;
839
840 procedure TLazIDEInterface.RemoveAllHandlersOfObject(AnObject: TObject);
841 var
842 HandlerType: TLazarusIDEHandlerType;
843 begin
844 for HandlerType:=Low(HandlerType) to High(HandlerType) do
845 FLazarusIDEHandlers[HandlerType].RemoveAllMethodsOfObject(AnObject);
846 end;
847
848 procedure TLazIDEInterface.AddHandlerOnSavingAll(
849 const OnSaveAllEvent: TModalResultFunction; AsLast: boolean);
850 begin
851 AddHandler(lihtSavingAll,TMethod(OnSaveAllEvent),AsLast);
852 end;
853
854 procedure TLazIDEInterface.RemoveHandlerOnSavingAll(
855 const OnSaveAllEvent: TModalResultFunction);
856 begin
857 RemoveHandler(lihtSavingAll,TMethod(OnSaveAllEvent));
858 end;
859
860 procedure TLazIDEInterface.AddHandlerOnSavedAll(
861 const OnSaveAllEvent: TModalResultFunction; AsLast: boolean);
862 begin
863 AddHandler(lihtSavedAll,TMethod(OnSaveAllEvent),AsLast);
864 end;
865
866 procedure TLazIDEInterface.RemoveHandlerOnSavedAll(
867 const OnSaveAllEvent: TModalResultFunction);
868 begin
869 RemoveHandler(lihtSavedAll,TMethod(OnSaveAllEvent));
870 end;
871
872 procedure TLazIDEInterface.AddHandlerOnSaveEditorFile(
873 const OnSaveEditorFile: TSaveEditorFileEvent; AsLast: boolean);
874 begin
875 AddHandler(lihtSaveEditorFile,TMethod(OnSaveEditorFile),AsLast);
876 end;
877
878 procedure TLazIDEInterface.RemoveHandlerOnSaveEditorFile(
879 const OnSaveEditorFile: TSaveEditorFileEvent);
880 begin
881 RemoveHandler(lihtSaveEditorFile,TMethod(OnSaveEditorFile));
882 end;
883
884 procedure TLazIDEInterface.AddHandlerOnIDERestoreWindows(
885 const OnIDERestoreWindowsEvent: TNotifyEvent; AsLast: boolean);
886 begin
887 AddHandler(lihtIDERestoreWindows,TMethod(OnIDERestoreWindowsEvent),AsLast);
888 end;
889
890 procedure TLazIDEInterface.AddHandlerOnLazarusBuilding(
891 const OnLazBuildingEvent: TModalResultFunction; AsLast: boolean);
892 begin
893 AddHandler(lihtLazarusBuilding,TMethod(OnLazBuildingEvent), AsLast);
894 end;
895
896 procedure TLazIDEInterface.AddHandlerOnLazarusBuildingFinished(
897 const OnLazBuildingFinishedEvent: TLazBuildingFinishedEvent; AsLast: boolean);
898 begin
899 AddHandler(lihtLazarusBuildingFinished,TMethod(OnLazBuildingFinishedEvent), AsLast);
900 end;
901
902 procedure TLazIDEInterface.RemoveHandlerOnIDERestoreWindows(
903 const OnIDERestoreWindowsEvent: TNotifyEvent);
904 begin
905 RemoveHandler(lihtIDERestoreWindows,TMethod(OnIDERestoreWindowsEvent));
906 end;
907
908 procedure TLazIDEInterface.RemoveHandlerOnLazarusBuilding(
909 const OnLazBuildingEvent: TModalResultFunction);
910 begin
911 RemoveHandler(lihtLazarusBuilding,TMethod(OnLazBuildingEvent));
912 end;
913
914 procedure TLazIDEInterface.RemoveHandlerOnLazarusBuildingFinished(
915 const OnLazBuildingFinishedEvent: TLazBuildingFinishedEvent);
916 begin
917 RemoveHandler(lihtLazarusBuildingFinished,TMethod(OnLazBuildingFinishedEvent));
918 end;
919
920 procedure TLazIDEInterface.AddHandlerOnIDEClose(
921 const OnIDECloseEvent: TNotifyEvent; AsLast: boolean);
922 begin
923 AddHandler(lihtIDEClose,TMethod(OnIDECloseEvent),AsLast);
924 end;
925
926 procedure TLazIDEInterface.RemoveHandlerOnIDEClose(
927 const OnIDECloseEvent: TNotifyEvent);
928 begin
929 RemoveHandler(lihtIDEClose,TMethod(OnIDECloseEvent));
930 end;
931
932 procedure TLazIDEInterface.AddHandlerOnProjectOpening(
933 const OnProjectOpeningEvent: TLazProjectChangedFunction; AsLast: boolean);
934 begin
935 AddHandler(lihtProjectOpening,TMethod(OnProjectOpeningEvent),AsLast);
936 end;
937
938 procedure TLazIDEInterface.RemoveHandlerOnProjectOpening(
939 const OnProjectOpeningEvent: TLazProjectChangedFunction);
940 begin
941 RemoveHandler(lihtProjectOpening,TMethod(OnProjectOpeningEvent));
942 end;
943
944 procedure TLazIDEInterface.AddHandlerOnProjectOpened(
945 const OnProjectOpenedEvent: TLazProjectChangedFunction; AsLast: boolean);
946 begin
947 AddHandler(lihtProjectOpened,TMethod(OnProjectOpenedEvent),AsLast);
948 end;
949
950 procedure TLazIDEInterface.RemoveHandlerOnProjectOpened(
951 const OnProjectOpenedEvent: TLazProjectChangedFunction);
952 begin
953 RemoveHandler(lihtProjectOpened,TMethod(OnProjectOpenedEvent));
954 end;
955
956 procedure TLazIDEInterface.AddHandlerOnProjectClose(
957 const OnProjectCloseEvent: TLazProjectChangedFunction; AsLast: boolean);
958 begin
959 AddHandler(lihtProjectClose,TMethod(OnProjectCloseEvent),AsLast);
960 end;
961
962 procedure TLazIDEInterface.RemoveHandlerOnProjectClose(
963 const OnProjectCloseEvent: TLazProjectChangedFunction);
964 begin
965 RemoveHandler(lihtProjectClose,TMethod(OnProjectCloseEvent));
966 end;
967
968 procedure TLazIDEInterface.AddHandlerOnProjectBuilding(
969 const OnProjBuildingEvent: TModalResultFunction; AsLast: boolean);
970 begin
971 AddHandler(lihtProjectBuilding,TMethod(OnProjBuildingEvent),AsLast);
972 end;
973
974 procedure TLazIDEInterface.RemoveHandlerOnProjectBuilding(
975 const OnProjBuildingEvent: TModalResultFunction);
976 begin
977 RemoveHandler(lihtProjectBuilding,TMethod(OnProjBuildingEvent));
978 end;
979
980 procedure TLazIDEInterface.AddHandlerOnProjectDependenciesCompiling(
981 const OnProjDependenciesCompilingEvent: TModalResultFunction; AsLast: boolean);
982 begin
983 AddHandler(lihtProjectDependenciesCompiling,
984 TMethod(OnProjDependenciesCompilingEvent),AsLast);
985 end;
986
987 procedure TLazIDEInterface.RemoveHandlerOnProjectDependenciesCompiling(
988 const OnProjDependenciesCompilingEvent: TModalResultFunction);
989 begin
990 RemoveHandler(lihtProjectDependenciesCompiling,
991 TMethod(OnProjDependenciesCompilingEvent));
992 end;
993
994 procedure TLazIDEInterface.AddHandlerOnProjectDependenciesCompiled(
995 const OnProjDependenciesCompiledEvent: TModalResultFunction; AsLast: boolean);
996 begin
997 AddHandler(lihtProjectDependenciesCompiled,
998 TMethod(OnProjDependenciesCompiledEvent),AsLast);
999 end;
1000
1001 procedure TLazIDEInterface.RemoveHandlerOnProjectDependenciesCompiled(
1002 const OnProjDependenciesCompiledEvent: TModalResultFunction);
1003 begin
1004 RemoveHandler(lihtProjectDependenciesCompiled,
1005 TMethod(OnProjDependenciesCompiledEvent));
1006 end;
1007
1008 procedure TLazIDEInterface.AddHandlerOnQuickSyntaxCheck(
1009 const OnQuickSyntaxCheckEvent: TModalHandledFunction; AsLast: boolean);
1010 begin
1011 AddHandler(lihtQuickSyntaxCheck,TMethod(OnQuickSyntaxCheckEvent),AsLast);
1012 end;
1013
1014 procedure TLazIDEInterface.RemoveHandlerOnQuickSyntaxCheck(
1015 const OnQuickSyntaxCheckEvent: TModalHandledFunction);
1016 begin
1017 RemoveHandler(lihtQuickSyntaxCheck,TMethod(OnQuickSyntaxCheckEvent));
1018 end;
1019
1020 procedure TLazIDEInterface.AddHandlerGetFPCFrontEndParams(
1021 const Handler: TGetFPCFrontEndParams; AsLast: boolean);
1022 begin
1023 AddHandler(lihtGetFPCFrontEndParams,TMethod(Handler),AsLast);
1024 end;
1025
1026 procedure TLazIDEInterface.RemoveHandlerGetFPCFrontEndParams(
1027 const Handler: TGetFPCFrontEndParams);
1028 begin
1029 RemoveHandler(lihtGetFPCFrontEndParams,TMethod(Handler));
1030 end;
1031
CallHandlerGetFPCFrontEndParamsnull1032 function TLazIDEInterface.CallHandlerGetFPCFrontEndParams(Sender: TObject;
1033 var Params: string): boolean;
1034 var
1035 i: longint;
1036 begin
1037 i:=FLazarusIDEHandlers[lihtGetFPCFrontEndParams].Count;
1038 while FLazarusIDEHandlers[lihtGetFPCFrontEndParams].NextDownIndex(i) do
1039 begin
1040 if not TGetFPCFrontEndParams(FLazarusIDEHandlers[lihtGetFPCFrontEndParams][i])(Self,Params)
1041 then exit(false);
1042 end;
1043 Result:=true;
1044 end;
1045
1046 procedure TLazIDEInterface.AddHandlerGetFPCFrontEndPath(
1047 const Handler: TGetFPCFrontEndPath; AsLast: boolean);
1048 begin
1049 AddHandler(lihtGetFPCFrontEndPath,TMethod(Handler),AsLast);
1050 end;
1051
1052 procedure TLazIDEInterface.AddHandlerOnProjectBuildingFinished(
1053 const OnProjBuildingFinishedEvent: TLazBuildingFinishedEvent; AsLast: boolean);
1054 begin
1055 AddHandler(lihtProjectBuildingFinished,TMethod(OnProjBuildingFinishedEvent),AsLast);
1056 end;
1057
1058 procedure TLazIDEInterface.AddHandlerOnChangeToolStatus(
1059 const OnChangeToolStatus: TLazToolStatusChangeEvent; AsLast: boolean);
1060 begin
1061 AddHandler(lihtChangeToolStatus,TMethod(OnChangeToolStatus),AsLast);
1062 end;
1063
1064 procedure TLazIDEInterface.RemoveHandlerGetFPCFrontEndPath(
1065 const Handler: TGetFPCFrontEndPath);
1066 begin
1067 RemoveHandler(lihtGetFPCFrontEndPath,TMethod(Handler));
1068 end;
1069
1070 procedure TLazIDEInterface.RemoveHandlerOnProjectBuildingFinished(
1071 const OnProjBuildingFinishedEvent: TLazBuildingFinishedEvent);
1072 begin
1073 RemoveHandler(lihtProjectBuildingFinished,TMethod(OnProjBuildingFinishedEvent));
1074 end;
1075
1076 procedure TLazIDEInterface.RemoveHandlerOnChangeToolStatus(
1077 const OnChangeToolStatus: TLazToolStatusChangeEvent);
1078 begin
1079 RemoveHandler(lihtChangeToolStatus,TMethod(OnChangeToolStatus));
1080 end;
1081
1082 procedure TLazIDEInterface.AddHandlerOnRunDebugInit(
1083 const Event: TModalHandledFunction; AsLast: boolean);
1084 begin
1085 AddHandler(lihtRunDebugInit,TMethod(Event),AsLast);
1086 end;
1087
1088 procedure TLazIDEInterface.RemoveHandlerOnRunDebugInit(
1089 const Event: TModalHandledFunction);
1090 begin
1091 RemoveHandler(lihtRunDebugInit,TMethod(Event));
1092 end;
1093
1094 procedure TLazIDEInterface.AddHandlerOnRunDebug(
1095 const Event: TModalHandledFunction; AsLast: boolean);
1096 begin
1097 AddHandler(lihtRunDebug,TMethod(Event),AsLast);
1098 end;
1099
1100 procedure TLazIDEInterface.RemoveHandlerOnRunDebug(
1101 const Event: TModalHandledFunction);
1102 begin
1103 RemoveHandler(lihtRunDebug,TMethod(Event));
1104 end;
1105
1106 procedure TLazIDEInterface.AddHandlerOnRunWithoutDebugBuilding(
1107 const Event: TModalHandledFunction; AsLast: boolean);
1108 begin
1109 AddHandler(lihtRunWithoutDebugBuilding,TMethod(Event),AsLast);
1110 end;
1111
1112 procedure TLazIDEInterface.RemoveHandlerOnRunWithoutDebugBuilding(
1113 const Event: TModalHandledFunction);
1114 begin
1115 RemoveHandler(lihtRunWithoutDebugBuilding,TMethod(Event));
1116 end;
1117
1118 procedure TLazIDEInterface.AddHandlerOnRunWithoutDebugInit(
1119 const Event: TModalHandledFunction; AsLast: boolean);
1120 begin
1121 AddHandler(lihtRunWithoutDebugInit,TMethod(Event),AsLast);
1122 end;
1123
1124 procedure TLazIDEInterface.RemoveHandlerOnRunWithoutDebugInit(
1125 const Event: TModalHandledFunction);
1126 begin
1127 RemoveHandler(lihtRunWithoutDebugInit,TMethod(Event));
1128 end;
1129
1130 procedure TLazIDEInterface.AddHandlerOnRunFinished(
1131 const OnRunFinishedEvent: TNotifyEvent; AsLast: boolean);
1132 begin
1133 AddHandler(lihtRunFinished,TMethod(OnRunFinishedEvent),AsLast);
1134 end;
1135
1136 procedure TLazIDEInterface.RemoveHandlerOnRunFinished(
1137 const OnRunFinishedEvent: TNotifyEvent);
1138 begin
1139 RemoveHandler(lihtRunFinished,TMethod(OnRunFinishedEvent));
1140 end;
1141
CallHandlerGetFPCFrontEndPathnull1142 function TLazIDEInterface.CallHandlerGetFPCFrontEndPath(Sender: TObject;
1143 var Path: string): boolean;
1144 var
1145 i: longint;
1146 begin
1147 i:=FLazarusIDEHandlers[lihtGetFPCFrontEndPath].Count;
1148 while FLazarusIDEHandlers[lihtGetFPCFrontEndPath].NextDownIndex(i) do
1149 begin
1150 if not TGetFPCFrontEndPath(FLazarusIDEHandlers[lihtGetFPCFrontEndPath][i])(Self,Path)
1151 then exit(false);
1152 end;
1153 Result:=true;
1154 end;
1155
1156 procedure TLazIDEInterface.AddHandlerOnShowDesignerFormOfSource(
1157 const OnShowDesignerFormOfSourceEvent: TShowDesignerFormOfSourceFunction; AsLast: boolean);
1158 begin
1159 AddHandler(lihtShowDesignerFormOfSource,TMethod(OnShowDesignerFormOfSourceEvent),AsLast);
1160 end;
1161
1162 procedure TLazIDEInterface.RemoveHandlerOnShowDesignerFormOfSource(
1163 const OnShowDesignerFormOfSourceEvent: TShowDesignerFormOfSourceFunction);
1164 begin
1165 RemoveHandler(lihtShowDesignerFormOfSource,TMethod(OnShowDesignerFormOfSourceEvent));
1166 end;
1167
1168 procedure TLazIDEInterface.AddHandlerOnShowSourceOfActiveDesignerForm(
1169 const OnShowSourceOfActiveDesignerForm: TNotifyEvent; AsLast: boolean);
1170 begin
1171 AddHandler(lihtShowSourceOfActiveDesignerForm,TMethod(OnShowSourceOfActiveDesignerForm),AsLast);
1172 end;
1173
1174 procedure TLazIDEInterface.RemoveHandlerOnShowSourceOfActiveDesignerForm(
1175 const OnShowSourceOfActiveDesignerForm: TNotifyEvent);
1176 begin
1177 RemoveHandler(lihtShowSourceOfActiveDesignerForm,TMethod(OnShowSourceOfActiveDesignerForm));
1178 end;
1179
1180 end.
1181
1182