File: lazideintf.pas

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (1131 lines) | stat: -rw-r--r-- 47,566 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
{
 *****************************************************************************
  See the file COPYING.modifiedLGPL.txt, included in this distribution,
  for details about the license.
 *****************************************************************************

  Author: Mattias Gaertner

  Abstract:
    Interface to the general IDE functions.
}
unit LazIDEIntf;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils,
  // LCL
  LCLProc, Forms, Controls, Dialogs, LazHelpHTML,
  // LazUtils
  LazMethodList,
  // IdeIntf
  BaseIDEIntf, IDEOptionsIntf, IDEOptEditorIntf, CompOptsIntf, ProjectIntf,
  IDEExternToolIntf, SrcEditorIntf, IDEWindowIntf, PropEdits;

type
  TIDEDirective = (
    idedNone,
    idedBuildCommand,  // Filename plus params to build the file
                       //   default is '$(CompPath) $(EdFile)'
    idedBuildWorkingDir,// Working directory for building. Default is the
                       //   directory of the file
    idedBuildScan,     // Flags controlling what messages should be scanned for
                       //   during building. See TIDEDirBuildScanFlag.
    idedRunCommand,    // Filename plus params to run the file
                       //   default is '$NameOnly($(EdFile))'
    idedRunWorkingDir, // Working directory for building. Default is the
                       //   directory of the file
    idedRunFlags       // Flags for run. See TIDEDirRunFlag
    );
  TIDEDirectives = set of TIDEDirective;

  TIDEDirBuildScanFlag = (
    idedbsfNone,
    idedbsfFPC, // scan for FPC messages. FPC+ means on (default) and FPC- off.
    idedbsfMake // scan for MAKE messages. MAKE- means on (default) and MAKE- off.
    );
  TIDEDirBuildScanFlags = set of TIDEDirBuildScanFlag;

  TIDEDirRunFlag = (
    idedrfNone,
    idedrfBuildBeforeRun, // BUILD+ means on (default for non script), BUILD- means off
    idedrfMessages // show output in Messages window
    );
  TIDEDirRunFlags = set of TIDEDirRunFlag;
const
  IDEDirectiveNames: array[TIDEDirective] of string = (
    '',
    'BuildCommand',
    'BuildWorkingDir',
    'BuildScan',
    'RunCommand',
    'RunWorkingDir',
    'RunFlags'
    );
  IDEDirBuildScanFlagNames: array[TIDEDirBuildScanFlag] of string = (
    '',
    'FPC',
    'MAKE'
    );
  IDEDirRunFlagNames: array[TIDEDirRunFlag] of string = (
    '',
    'BUILD',
    'MESSAGES'
    );

type
  // open file flags
  // Normally you don't need to pass any flags.
  TOpenFlag = (
    ofProjectLoading,// this open is part of opening a whole project
    ofOnlyIfExists,  // do not auto create non existing files
    ofRevert,        // reload file if already open, any user changes are lost without question
    ofQuiet,         // less messages
    ofAddToRecent,   // add file to recent files
    ofRegularFile,   // open as regular file (e.g. do not open projects/packages)
    ofVirtualFile,   // open the virtual file
    ofConvertMacros, // replace macros in filename
    ofUseCache,      // do not update file from disk
    ofMultiOpen,     // set during loading multiple files
    ofDoNotLoadResource,// do not open form, datamodule, ... (overriding default)
    ofDoLoadResource,// do open form, datamodule, ... (overriding default)
    ofLoadHiddenResource,// load component hidden
    ofAddToProject,  // add file to project (if exists)
    ofInternalFile   // opening data from an internal source (e.g. an editor macro (pascal script) from memory)
    );
  TOpenFlags = set of TOpenFlag;

const
  OpnFlagsPlainFile = [ofOnlyIfExists,ofQuiet,ofRegularFile,ofVirtualFile,ofDoNotLoadResource];
type
  // new file flags
  // Normally you don't need to pass any flags.
  TNewFlag = (
    nfIsPartOfProject, // force IsPartOfProject,
                       //   default is to use a heuristic
    nfIsNotPartOfProject,// forbid IsPartOfProject
    nfOpenInEditor,    // open in editor
    nfSave,            // save file instantly
    nfAddToRecent,     // add file to recent files
    nfQuiet,           // less messages
    nfConvertMacros,   // replace macros in filename
    nfBeautifySrc,     // beautify custom source
    nfCreateDefaultSrc,// create initial source based on the type
    nfAskForFilename   // ask for filename
    );
  TNewFlags = set of TNewFlag;

  // save file flags
  // Normally you don't need to pass any flags.
  TSaveFlag = (
    sfSaveAs,
    sfSaveToTestDir,
    sfProjectSaving,
    sfCheckAmbiguousFiles,
    sfSaveNonProjectFiles,
    sfDoNotSaveVirtualFiles,
    sfCanAbort,  // show 'Cancel all' button in error messages
    sfSaveMainSourceAs,  // on sfSaveAs use .lpr file instead of .lpi file
    sfQuietUnitCheck     // don't ask questions when adding unit dependency.
    );
  TSaveFlags = set of TSaveFlag;
  
  // close file flags
  // Normally you don't need to pass any flags.
  TCloseFlag = (
    cfSaveFirst, // check if modified and save
    cfQuiet,
    cfProjectClosing,
    cfCloseDependencies,
    cfSaveDependencies // set cfSaveFirst to close the dependencies
    );
  TCloseFlags = set of TCloseFlag;

  // build project flags
  // Normally you don't need to pass any flags.
  TProjectBuildFlag = (
    pbfDoNotCompileDependencies,
    pbfDoNotCompileProject,
    pbfCompileDependenciesClean,
    pbfDoNotSaveEditorFiles,
    pbfSkipLinking,
    pbfSkipAssembler,
    pbfSkipTools,
    pbfCreateMakefile
    );
  TProjectBuildFlags = set of TProjectBuildFlag;
  
  // new filename flags
  // Normally you don't need to pass any flags.
  TSearchIDEFileFlag = (
    siffDoNotCheckAllPackages, // do not search filename in unrelated packages (e.g. installed but not used by project)
    siffCheckAllProjects, // search filename in all loaded projects
    siffCaseSensitive,  // check case sensitive, otherwise use Pascal case insensitivity (CompareText)
    siffDoNotCheckOpenFiles,  // do not search in files opened in source editor
    siffIgnoreExtension  // compare only filename, ignore file extension
    );
  TSearchIDEFileFlags = set of TSearchIDEFileFlag;

  // find unit flags
  // Normally you don't need to pass any flags.
  TFindUnitFileFlag = (
    fuffIgnoreUninstallPackages
    );
  TFindUnitFileFlags = set of TFindUnitFileFlag;

  // selected part of IDE
  TTabDisplayState = (
    tdsNone,
    tdsCode,     // focussing sourcenotebook or source tab
    tdsDesign,   // focussing designer form/design tab
    tdsOther     // focussing other (user defined) tab assigned to module (like History Tab)
    );

  // find source flags
  // Normally you don't need to pass any flags.
  TFindSourceFlag = (
    fsfSearchForProject,
    fsfUseIncludePaths,
    fsfUseDebugPath,
    fsfMapTempToVirtualFiles,
    fsfSkipPackages
    );
  TFindSourceFlags = set of TFindSourceFlag;

  TFindUnitsOfOwnerFlag = (
    fuooListed, // add units listed in lpi/lpk aka project inspector/package editor
    fuooUsed,   // add units used by main source file (depends on current build mode and environment)
    fuooPackages, // extends fuooListed and fuooUsed by units from used packages
    fuooSourceEditor // add units in source editor
    );
  TFindUnitsOfOwnerFlags = set of TFindUnitsOfOwnerFlag;
  
  TModalResultFunction = function(Sender: TObject): TModalResult of object;
  TLazProjectChangedFunction = function(Sender: TObject;
                                 AProject: TLazProject): TModalResult of object;
  TModalHandledFunction = function(Sender: TObject; var Handled: boolean
                              ): TModalResult of object;
  TGetFPCFrontEndParams = function(Sender: TObject;
    var Params: string // these parameters are passed to fpc.
      // Global options should be prependended, project options should be appended.
    ): boolean of object;

  TSaveEditorFileStep = (
    sefsBeforeWrite,
    sefsAfterWrite
    );
  TSaveEditorFileEvent = function(Sender: TObject; aFile: TLazProjectFile;
    SaveStep: TSaveEditorFileStep; TargetFilename: string): TModalResult of object;

  TShowDesignerFormOfSourceFunction = procedure(Sender: TObject; AEditor: TSourceEditorInterface;
                                 AComponentPaletteClassSelected: Boolean) of object;
  TGetFPCFrontEndPath = function(Sender: TObject;
    var Path: string // this path is prepended to fpc.
    ): boolean of object;

  TLazarusIDEHandlerType = (
    lihtSavingAll, // called before IDE saves everything
    lihtSavedAll,  // called after IDE saved everything
    lihtSaveEditorFile, // called when IDE saves an editor file to disk
    lihtIDERestoreWindows, // called when IDE is restoring the windows (before opening the first project)
    lihtIDEClose, // called when IDE is shutting down (after closequery, so no more interactivity)
    lihtProjectOpened,// called after IDE opened a project
    lihtProjectClose, // called before IDE closes a project
    lihtProjectBuilding, // called before IDE builds the project
    lihtProjectDependenciesCompiling, // called before IDE compiles dependencies of project
    lihtProjectDependenciesCompiled, // called after IDE compiled dependencies of project
    lihtProjectBuildingFinished, // called after IDE builds the project
    lihtLazarusBuilding, // called before IDE builds Lazarus IDE
    lihtLazarusBuildingFinished, // called after IDE builds Lazarus IDE
    lihtQuickSyntaxCheck,  // called when quick syntax check is clicked (menu item or shortcut)
    lihtGetFPCFrontEndParams, // called when the IDE gets the parameters of the 'fpc' front end tool
    lihtGetFPCFrontEndPath, // called when the IDE gets the path of the 'fpc' front end tool
    lihtShowDesignerFormOfSource, // called after showing a designer form for code editor (AEditor can be nil!)
    lihtShowSourceOfActiveDesignerForm, // called after showing a code of designer form
    lihtChangeToolStatus, //called when IDEToolStatus has changed (e.g. itNone->itBuilder etc.)
    lihtRunDebug, // called when Run was clicked, after building, before starting the debugger
    lihtRunWithoutDebugBuilding, // called when Run a project without debugger was clicked, before building
    lihtRunWithoutDebugInit, // called when Run a project without debugger was clicked, after building
    lihtRunFinished //called when ran program finishes
    );
    
  TLazToolStatus = (
    itNone,            // The default mode. All editing allowed.
    itExiting,         // the ide is shutting down
    itBuilder,         // compiling (the project, a package, IDE itself, an external tool)
                       //    Loading/Saving/Debugging is not allowed.
    itDebugger,        // debugging the project.
                       //    Loading/Saving/Compiling is not allowed.
    itCodeTools,       // the CodeToolBoss is working and has called the progress event.
    itCodeToolAborting,// the CodeToolBoss is working and is about to abort
    itCustom           // this state is not used yet.
    );
  TLazToolStatusChangeEvent = procedure(Sender: TObject; OldStatus, NewStatus: TLazToolStatus) of object;

  TLazBuildingFinishedEvent = procedure(Sender: TObject; BuildSuccessful: Boolean) of object;

  { TLazIDEInterface }

  TLazIDEInterface = class(TComponent)
  private
    FToolStatus: TLazToolStatus;
    FMainBarSubTitle: string;
    FOpenEditorsOnCodeToolChange: boolean;
    FOpenMainSourceOnCodeToolChange: boolean;
    FSaveClosedSourcesOnCodeToolChange: boolean;
    FCheckFilesOnDiskEnabled: boolean;
    procedure AddHandler(HandlerType: TLazarusIDEHandlerType;
                         const AMethod: TMethod; AsLast: boolean = false);
    procedure RemoveHandler(HandlerType: TLazarusIDEHandlerType;
                            const AMethod: TMethod);
  protected
    FLazarusIDEHandlers: array[TLazarusIDEHandlerType] of TMethodList;
    FOwningComponent: TComponent;
    FIDEStarted: boolean;
    FIDEIsClosing: Boolean;
    FLastActivatedWindows: TFPList;
    // used to find the last form so you can display the correct tab
    FLastFormActivated: TCustomForm;

    procedure SetToolStatus(const AToolStatus: TLazToolStatus); virtual;
    function GetActiveProject: TLazProject; virtual; abstract;
    procedure DoCallNotifyHandler(HandlerType: TLazarusIDEHandlerType); overload;
    function DoCallModalFunctionHandler(HandlerType: TLazarusIDEHandlerType
                                        ): TModalResult;
    function DoCallModalHandledHandler(HandlerType: TLazarusIDEHandlerType;
                                       var Handled: boolean): TModalResult;
    procedure DoCallNotifyHandler(HandlerType: TLazarusIDEHandlerType;
                                  Sender: TObject); overload;
    procedure DoCallShowDesignerFormOfSourceHandler(
      HandlerType: TLazarusIDEHandlerType;
      Sender: TObject; AEditor: TSourceEditorInterface;
      AComponentPaletteClassSelected: Boolean);
    procedure DoCallBuildingFinishedHandler(HandlerType: TLazarusIDEHandlerType;
      Sender: TObject; BuildSuccessful: Boolean);

    procedure SetMainBarSubTitle(const AValue: string); virtual;
  public
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
    property OwningComponent: TComponent read FOwningComponent;
    
    property ToolStatus: TLazToolStatus read FToolStatus write SetToolStatus;

    // the main window with the IDE menu
    function GetMainBar: TForm; virtual; abstract;
    property MainBarSubTitle: string read FMainBarSubTitle write SetMainBarSubTitle;

    // find file
    function FindUnitFile(const AFilename: string; TheOwner: TObject = nil;
                          Flags: TFindUnitFileFlags = []): string; virtual; abstract;
    function FindSourceFile(const AFilename, BaseDirectory: string;
                            Flags: TFindSourceFlags): string; virtual; abstract;

    // file
    function DoNewEditorFile(NewFileDescriptor: TProjectFileDescriptor;
                             NewFilename: string; const NewSource: string;
                             NewFlags: TNewFlags): TModalResult;
    function DoNewFile(NewFileDescriptor: TProjectFileDescriptor;
                       var NewFilename: string; NewSource: string;
                       NewFlags: TNewFlags; NewOwner: TObject): TModalResult; virtual; abstract;
    function DoSaveEditorFile(AEditor: TSourceEditorInterface;
                              Flags: TSaveFlags): TModalResult; virtual; abstract;
    function DoSaveEditorFile(const Filename: string;
                              Flags: TSaveFlags): TModalResult; virtual; abstract;
    function DoSaveAll(Flags: TSaveFlags): TModalResult; virtual; abstract;
    function DoCloseEditorFile(AEditor: TSourceEditorInterface;
                               Flags: TCloseFlags):TModalResult; virtual; abstract;
    function DoCloseEditorFile(const Filename: string;
                               Flags: TCloseFlags): TModalResult; virtual; abstract;
    function DoOpenEditorFile(AFileName:string; PageIndex, WindowIndex: integer;
                              Flags: TOpenFlags): TModalResult; virtual; abstract;
    function DoOpenFileAndJumpToIdentifier(const AFilename, AnIdentifier: string;
                       PageIndex, WindowIndex: integer; Flags: TOpenFlags): TModalResult; virtual; abstract;
    function DoOpenFileAndJumpToPos(const AFilename: string;
                       const CursorPosition: TPoint; TopLine: integer;
                       PageIndex, WindowIndex: integer; Flags: TOpenFlags): TModalResult; overload;
    function DoOpenFileAndJumpToPos(const AFilename: string;
                       const CursorPosition: TPoint; TopLine, BlockTopLine, BlockBottomLine: integer;
                       PageIndex, WindowIndex: integer; Flags: TOpenFlags): TModalResult; virtual; abstract; overload;
    function DoRevertEditorFile(const Filename: string): TModalResult; virtual; abstract;
    function DoOpenComponent(const UnitFilename: string; OpenFlags: TOpenFlags;
                       CloseFlags: TCloseFlags;
                       out Component: TComponent): TModalResult; virtual; abstract;
    procedure DoDropFiles(Sender: TObject; const FileNames: array of String;
      WindowIndex: integer = -1); virtual; abstract;
    function DoConfigureBuildFile: TModalResult; virtual; abstract;
    function DoBuildFile({%H-}ShowAbort: Boolean;
      Filename: string = '' // if empty use active source editor file
      ): TModalResult; virtual; abstract;
    function DoRunFile(Filename: string = '' // if empty use active source editor file
      ): TModalResult; virtual; abstract;

    // project
    property ActiveProject: TLazProject read GetActiveProject;
    function DoNewProject(ProjectDesc: TProjectDescriptor): TModalResult; virtual; abstract;
    function DoSaveProject(Flags: TSaveFlags): TModalResult; virtual; abstract;
    function DoCloseProject: TModalResult; virtual; abstract;
    function DoOpenProjectFile(AFileName: string;
                               Flags: TOpenFlags): TModalResult; virtual; abstract;
    function DoPublishProject(Flags: TSaveFlags;
                              ShowDialog: boolean): TModalResult; virtual; abstract;
    function DoBuildProject(const AReason: TCompileReason;
                            Flags: TProjectBuildFlags;
                            FinalizeResources: boolean = True): TModalResult; virtual; abstract;
    function DoRunProject: TModalResult; virtual; abstract;
    function DoRunProjectWithoutDebug: TModalResult; virtual; abstract;
    function GetProjectFileForProjectEditor(AEditor: TSourceEditorInterface): TLazProjectFile; virtual; abstract;
    function DoCallProjectChangedHandler(HandlerType: TLazarusIDEHandlerType;
                                         AProject: TLazProject): TModalResult;
    function DoCallRunDebug(var Handled: boolean): TModalResult;
    function DoCallRunWithoutDebugBuilding(var Handled: boolean): TModalResult;
    function DoCallRunWithoutDebugInit(var Handled: boolean): TModalResult;
    procedure DoCallRunFinishedHandler;
    function DoAddUnitToProject(AEditor: TSourceEditorInterface): TModalResult; virtual; abstract;

    // configs
    class function GetPrimaryConfigPath: String; virtual; abstract;
    class function GetSecondaryConfigPath: String; virtual; abstract;
    procedure CopySecondaryConfigFile(const AFilename: String); virtual; abstract;
    function DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass = nil;
      ACaption: String = ''): Boolean; overload;
    function DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass;
      ACaption: String; AOptionsFilter: array of TAbstractIDEOptionsClass;
      ASettings: TIDEOptionsEditorSettings): Boolean; overload; virtual; abstract;

    // filenames, paths
    function CreateNewUniqueFilename(const Prefix, Ext: string;
                          NewOwner: TObject; Flags: TSearchIDEFileFlags;
                          TryWithoutNumber: boolean): string; virtual; abstract;
    function GetTestBuildDirectory: string; virtual; abstract;
    function GetCompilerFilename: string; virtual; abstract;
    function GetFPCompilerFilename: string; virtual; abstract;
    function GetFPCFrontEndOptions: string; virtual; abstract;

    // codetools
    function BeginCodeTools: boolean; virtual; abstract;
    function DoShowCodeToolBossError: TMessageLine; virtual; abstract;
    procedure DoJumpToCodeToolBossError; virtual; abstract;
    function NeedSaveSourceEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean; virtual; abstract;
    function SaveSourceEditorChangesToCodeCache(AEditor: TSourceEditorInterface): boolean; virtual; abstract; // true if something was saved
    function FindUnitsOfOwner(TheOwner: TObject; Flags: TFindUnitsOfOwnerFlags): TStrings; virtual; abstract;
    property OpenEditorsOnCodeToolChange: boolean read FOpenEditorsOnCodeToolChange
                                             write FOpenEditorsOnCodeToolChange;
    property SaveClosedSourcesOnCodeToolChange: boolean read FSaveClosedSourcesOnCodeToolChange
                                             write FSaveClosedSourcesOnCodeToolChange;
    property OpenMainSourceOnCodeToolChange: boolean read FOpenMainSourceOnCodeToolChange
                                             write FOpenMainSourceOnCodeToolChange;

    // progress and error messages
    function ShowProgress(const SomeText: string;
      Step, MaxStep: integer): boolean; virtual; abstract; // False if canceled by user
    function GetSelectedCompilerMessage: TMessageLine; virtual; abstract;
    function DoJumpToCompilerMessage(FocusEditor: boolean;
                              Msg: TMessageLine = nil // if nil then it jumps to first message
                              ): boolean; virtual; abstract;
    procedure DoJumpToNextCompilerMessage(aMinUrgency: TMessageLineUrgency; DirectionDown: boolean); virtual; abstract;
    procedure DoJumpToNextError(DirectionDown: boolean);
    procedure DoShowMessagesView(BringToFront: boolean = true); virtual; abstract;
    function DoCheckFilesOnDisk(Instantaneous: boolean = false): TModalResult; virtual; abstract;
    // call this after changing TargetOS/TargetCPU of the ActiveProject
    procedure PrepareBuildTarget(Quiet: boolean;
                     ScanFPCSrc: TScanModeFPCSources = smsfsBackground); virtual; abstract;
    procedure AbortBuild; virtual; abstract;

    // search results
    procedure DoShowSearchResultsView(State: TIWGetFormState = iwgfShowOnTop); virtual; abstract;

    // designer
    function GetDesignerForProjectEditor(AEditor: TSourceEditorInterface;
                              LoadForm: boolean): TIDesigner; virtual; abstract;
    function GetDesignerWithProjectFile(AFile: TLazProjectFile;
                              LoadForm: boolean): TIDesigner; virtual; abstract;
    function GetProjectFileWithRootComponent(AComponent: TComponent): TLazProjectFile; virtual; abstract;
    function GetProjectFileWithDesigner(ADesigner: TIDesigner): TLazProjectFile; virtual; abstract;

    procedure DoShowDesignerFormOfSrc(AEditor: TSourceEditorInterface); virtual; abstract; overload;
    procedure DoShowMethod(AEditor: TSourceEditorInterface; const AMethodName: String); virtual; abstract;
    procedure DoShowDesignerFormOfSrc(AEditor: TSourceEditorInterface; out AForm: TCustomForm); virtual; abstract; overload;

    // events
    procedure RemoveAllHandlersOfObject(AnObject: TObject);
    procedure AddHandlerOnSavingAll(const OnSaveAllEvent: TModalResultFunction;
                                    AsLast: boolean = false);
    procedure RemoveHandlerOnSavingAll(const OnSaveAllEvent: TModalResultFunction);
    procedure AddHandlerOnSavedAll(const OnSaveAllEvent: TModalResultFunction;
                                   AsLast: boolean = false);
    procedure RemoveHandlerOnSavedAll(const OnSaveAllEvent: TModalResultFunction);
    procedure AddHandlerOnSaveEditorFile(const OnSaveEditorFile: TSaveEditorFileEvent;
                                    AsLast: boolean = false);
    procedure RemoveHandlerOnSaveEditorFile(const OnSaveEditorFile: TSaveEditorFileEvent);
    procedure AddHandlerOnIDERestoreWindows(const OnIDERestoreWindowsEvent: TNotifyEvent;
                                   AsLast: boolean = false);
    procedure RemoveHandlerOnIDERestoreWindows(
                                  const OnIDERestoreWindowsEvent: TNotifyEvent);
    procedure AddHandlerOnIDEClose(const OnIDECloseEvent: TNotifyEvent;
                                   AsLast: boolean = false);
    procedure RemoveHandlerOnIDEClose(const OnIDECloseEvent: TNotifyEvent);
    procedure AddHandlerOnProjectOpened(
                         const OnProjectOpenedEvent: TLazProjectChangedFunction;
                         AsLast: boolean = false);
    procedure RemoveHandlerOnProjectOpened(
                        const OnProjectOpenedEvent: TLazProjectChangedFunction);
    procedure AddHandlerOnProjectClose(
                          const OnProjectCloseEvent: TLazProjectChangedFunction;
                          AsLast: boolean = false);
    procedure RemoveHandlerOnProjectClose(
                         const OnProjectCloseEvent: TLazProjectChangedFunction);
    procedure AddHandlerOnProjectBuilding(
                                const OnProjBuildingEvent: TModalResultFunction;
                                AsLast: boolean = false);
    procedure RemoveHandlerOnProjectBuilding(
                                const OnProjBuildingEvent: TModalResultFunction);
    procedure AddHandlerOnProjectBuildingFinished(
                           const OnProjBuildingFinishedEvent: TLazBuildingFinishedEvent;
                           AsLast: boolean = false);
    procedure RemoveHandlerOnProjectBuildingFinished(
                               const OnProjBuildingFinishedEvent: TLazBuildingFinishedEvent);
    procedure AddHandlerOnProjectDependenciesCompiling(
                   const OnProjDependenciesCompilingEvent: TModalResultFunction;
                   AsLast: boolean = false);
    procedure RemoveHandlerOnProjectDependenciesCompiling(
                  const OnProjDependenciesCompilingEvent: TModalResultFunction);
    procedure AddHandlerOnProjectDependenciesCompiled(
                    const OnProjDependenciesCompiledEvent: TModalResultFunction;
                    AsLast: boolean = false);
    procedure RemoveHandlerOnProjectDependenciesCompiled(
                   const OnProjDependenciesCompiledEvent: TModalResultFunction);
    procedure AddHandlerOnLazarusBuilding(
                                const OnLazBuildingEvent: TModalResultFunction;
                                AsLast: boolean = false);
    procedure RemoveHandlerOnLazarusBuilding(
                                const OnLazBuildingEvent: TModalResultFunction);
    procedure AddHandlerOnLazarusBuildingFinished(
                           const OnLazBuildingFinishedEvent: TLazBuildingFinishedEvent;
                           AsLast: boolean = false);
    procedure RemoveHandlerOnLazarusBuildingFinished(
                               const OnLazBuildingFinishedEvent: TLazBuildingFinishedEvent);
    procedure AddHandlerOnQuickSyntaxCheck(
                           const OnQuickSyntaxCheckEvent: TModalHandledFunction;
                           AsLast: boolean = false);
    procedure RemoveHandlerOnQuickSyntaxCheck(
                          const OnQuickSyntaxCheckEvent: TModalHandledFunction);
    procedure AddHandlerGetFPCFrontEndParams(
                 const Handler: TGetFPCFrontEndParams; AsLast: boolean = false);
    procedure RemoveHandlerGetFPCFrontEndParams(
                                          const Handler: TGetFPCFrontEndParams);
    function CallHandlerGetFPCFrontEndParams(Sender: TObject; var Params: string): boolean;
    procedure AddHandlerGetFPCFrontEndPath(
                 const Handler: TGetFPCFrontEndPath; AsLast: boolean = false);
    procedure RemoveHandlerGetFPCFrontEndPath(const Handler: TGetFPCFrontEndPath);
    function CallHandlerGetFPCFrontEndPath(Sender: TObject; var Path: string): boolean;
    procedure AddHandlerOnShowDesignerFormOfSource(
                           const OnShowDesignerFormOfSourceEvent: TShowDesignerFormOfSourceFunction;
                           AsLast: boolean = false);
    procedure RemoveHandlerOnShowDesignerFormOfSource(
                               const OnShowDesignerFormOfSourceEvent: TShowDesignerFormOfSourceFunction);
    procedure AddHandlerOnShowSourceOfActiveDesignerForm(
                           const OnShowSourceOfActiveDesignerForm: TNotifyEvent;
                           AsLast: boolean = false);
    procedure RemoveHandlerOnShowSourceOfActiveDesignerForm(
                               const OnShowSourceOfActiveDesignerForm: TNotifyEvent);
    procedure AddHandlerOnChangeToolStatus(
                           const OnChangeToolStatus: TLazToolStatusChangeEvent;
                           AsLast: boolean = false);
    procedure RemoveHandlerOnChangeToolStatus(
                               const OnChangeToolStatus: TLazToolStatusChangeEvent);
    procedure AddHandlerOnRunDebug(const Event: TModalHandledFunction;
                                   AsLast: boolean = false);
    procedure RemoveHandlerOnRunDebug(const Event: TModalHandledFunction);
    procedure AddHandlerOnRunWithoutDebugBuilding(const Event: TModalHandledFunction;
                                      AsLast: boolean = false);
    procedure RemoveHandlerOnRunWithoutDebugBuilding(const Event: TModalHandledFunction);
    procedure AddHandlerOnRunWithoutDebugInit(const Event: TModalHandledFunction;
                                      AsLast: boolean = false);
    procedure RemoveHandlerOnRunWithoutDebugInit(const Event: TModalHandledFunction);
    procedure AddHandlerOnRunFinished(const OnRunFinishedEvent: TNotifyEvent;
                                      AsLast: boolean = false);
    procedure RemoveHandlerOnRunFinished(const OnRunFinishedEvent: TNotifyEvent);

    property IDEStarted: boolean read FIDEStarted;
    property IDEIsClosing: boolean read FIDEIsClosing;
    property LastActivatedWindows: TFPList read FLastActivatedWindows;
    property LastFormActivated: TCustomForm read FLastFormActivated write FLastFormActivated;
    property CheckFilesOnDiskEnabled: boolean read FCheckFilesOnDiskEnabled write FCheckFilesOnDiskEnabled;
  end;

  { TIDETabMaster }

  TIDETabMaster = class
  protected
    function GetTabDisplayState: TTabDisplayState; virtual; abstract;
    function GetTabDisplayStateEditor(Index: TSourceEditorInterface): TTabDisplayState; virtual; abstract;
  public
    function AutoSizeInShowDesigner(AControl: TControl): Boolean; virtual; abstract;
    procedure ToggleFormUnit; virtual; abstract;
    procedure JumpToCompilerMessage(ASourceEditor: TSourceEditorInterface); virtual; abstract;

    property TabDisplayState: TTabDisplayState read GetTabDisplayState;
    property TabDisplayStateEditor[Index: TSourceEditorInterface]: TTabDisplayState read GetTabDisplayStateEditor;

    procedure ShowCode(ASourceEditor: TSourceEditorInterface); virtual; abstract;
    procedure ShowDesigner(ASourceEditor: TSourceEditorInterface; AIndex: Integer = 0); virtual; abstract;

    procedure ShowForm(AForm: TCustomForm); virtual; abstract;
  end;

var
  LazarusIDE: TLazIDEInterface = nil; // will be set by the IDE
  IDETabMaster: TIDETabMaster = nil;

type
  TLazarusIDEBootHandlerType = (
    libhTransferMacrosCreated,  // called after IDEMacros were created
    libhEnvironmentOptionsLoaded  // called after IDE loaded environment options
    );

procedure AddBootHandler(ht: TLazarusIDEBootHandlerType; const OnBoot: TProcedure);

implementation

type
  TArrayOfProc = array of TProcedure;
var
  BootHandlers: array[TLazarusIDEBootHandlerType] of TArrayOfProc;

procedure AddBootHandler(ht: TLazarusIDEBootHandlerType; const OnBoot: TProcedure);
var
  l: Integer;
begin
  l:=length(BootHandlers[ht]);
  SetLength(BootHandlers[ht],l+1);
  BootHandlers[ht][l]:=OnBoot;
end;

procedure RunBootHandlers(ht: TLazarusIDEBootHandlerType);Public name 'ideintf_LazIDEIntf_RunBootHandlers';
var
  i: Integer;
begin
  for i:=0 to length(BootHandlers[ht])-1 do
    BootHandlers[ht][i]();
end;

{ TLazIDEInterface }

procedure TLazIDEInterface.AddHandler(HandlerType: TLazarusIDEHandlerType;
  const AMethod: TMethod; AsLast: boolean);
begin
  if FLazarusIDEHandlers[HandlerType]=nil then
    FLazarusIDEHandlers[HandlerType]:=TMethodList.Create;
  FLazarusIDEHandlers[HandlerType].Add(AMethod,AsLast);
end;

procedure TLazIDEInterface.RemoveHandler(HandlerType: TLazarusIDEHandlerType;
  const AMethod: TMethod);
begin
  FLazarusIDEHandlers[HandlerType].Remove(AMethod);
end;

procedure TLazIDEInterface.SetMainBarSubTitle(const AValue: string);
begin
  if FMainBarSubTitle=AValue then exit;
  FMainBarSubTitle:=AValue;
end;

procedure TLazIDEInterface.SetToolStatus(const AToolStatus: TLazToolStatus);
var
  xMethod: TLazToolStatusChangeEvent;
  I: Integer;
  OldToolStatus: TLazToolStatus;
begin
  if FToolStatus=aToolStatus then Exit;

  OldToolStatus:=FToolStatus;
  FToolStatus:=AToolStatus;

  for I := 0 to FLazarusIDEHandlers[lihtChangeToolStatus].Count-1 do
  begin
    xMethod := TLazToolStatusChangeEvent(FLazarusIDEHandlers[lihtChangeToolStatus][I]);
    xMethod(Self, OldToolStatus, AToolStatus);
  end;
end;

procedure TLazIDEInterface.DoCallNotifyHandler(
  HandlerType: TLazarusIDEHandlerType);
begin
  FLazarusIDEHandlers[HandlerType].CallNotifyEvents(Self);
end;

function TLazIDEInterface.DoCallModalFunctionHandler(
  HandlerType: TLazarusIDEHandlerType): TModalResult;
var
  i: Integer;
  CurResult: TModalResult;
  Handler: TMethodList;
begin
  Result:=mrOk;
  Handler:=FLazarusIDEHandlers[HandlerType];
  i:=Handler.Count;
  while Handler.NextDownIndex(i) do begin
    CurResult:=TModalResultFunction(Handler[i])(Self);
    if CurResult=mrAbort then exit(mrAbort);
    if CurResult<>mrOk then Result:=mrCancel;
  end;
end;

function TLazIDEInterface.DoCallProjectChangedHandler(
  HandlerType: TLazarusIDEHandlerType; AProject: TLazProject): TModalResult;
var
  i: Integer;
  CurResult: TModalResult;
  Handler: TMethodList;
begin
  Result:=mrOk;
  LastActivatedWindows.Clear;               // IDE windows may change.
  Handler:=FLazarusIDEHandlers[HandlerType];
  i:=Handler.Count;
  while Handler.NextDownIndex(i) do begin
    CurResult:=TLazProjectChangedFunction(Handler[i])(Self,AProject);
    if CurResult=mrAbort then exit(mrAbort);
    if CurResult<>mrOk then Result:=mrCancel;
  end;
end;

function TLazIDEInterface.DoCallModalHandledHandler(
  HandlerType: TLazarusIDEHandlerType; var Handled: boolean): TModalResult;
var
  i: longint;
  Handler: TMethodList;
begin
  Handler:=FLazarusIDEHandlers[HandlerType];
  i:=Handler.Count;
  while Handler.NextDownIndex(i) do
  begin
    Handled:=false;
    Result:=TModalHandledFunction(Handler[i])(Self,Handled);
    if Handled then exit;
  end;
  Result:=mrOk;
end;

procedure TLazIDEInterface.DoCallNotifyHandler(HandlerType: TLazarusIDEHandlerType; Sender: TObject);
begin
  FLazarusIDEHandlers[HandlerType].CallNotifyEvents(Sender);
end;

procedure TLazIDEInterface.DoCallShowDesignerFormOfSourceHandler(
  HandlerType: TLazarusIDEHandlerType; Sender: TObject;
  AEditor: TSourceEditorInterface; AComponentPaletteClassSelected: Boolean);
var
  i: Integer;
  Handler: TMethodList;
begin
  Handler:=FLazarusIDEHandlers[HandlerType];
  i := Handler.Count;
  while Handler.NextDownIndex(i) do
    TShowDesignerFormOfSourceFunction(Handler[i])(Sender, AEditor,
                                                 AComponentPaletteClassSelected);
end;

procedure TLazIDEInterface.DoJumpToNextError(DirectionDown: boolean);
begin
  DoJumpToNextCompilerMessage(mluError, DirectionDown);
end;

constructor TLazIDEInterface.Create(TheOwner: TComponent);
begin
  LazarusIDE:=Self;
  FCheckFilesOnDiskEnabled:=True;
  inherited Create(TheOwner);
end;

destructor TLazIDEInterface.Destroy;
var
  HandlerType: TLazarusIDEHandlerType;
begin
  for HandlerType := Low(TLazarusIDEHandlerType) to High(TLazarusIDEHandlerType) do
    FreeAndNil(FLazarusIDEHandlers[HandlerType]);
  inherited Destroy;
  LazarusIDE:=nil;
end;

function TLazIDEInterface.DoNewEditorFile(
  NewFileDescriptor: TProjectFileDescriptor; NewFilename: string;
  const NewSource: string; NewFlags: TNewFlags): TModalResult;
begin
  Result:=DoNewFile(NewFileDescriptor,NewFilename,NewSource,NewFlags,nil);
end;

function TLazIDEInterface.DoOpenFileAndJumpToPos(const AFilename: string;
  const CursorPosition: TPoint; TopLine: integer; PageIndex,
  WindowIndex: integer; Flags: TOpenFlags): TModalResult;
begin
  Result := DoOpenFileAndJumpToPos(AFilename, CursorPosition, TopLine, TopLine, TopLine, PageIndex, WindowIndex, Flags);
end;

function TLazIDEInterface.DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass;
  ACaption: String): Boolean;
begin
  Result := DoOpenIDEOptions(AEditor, ACaption, [], []);
end;

procedure TLazIDEInterface.DoCallBuildingFinishedHandler(
  HandlerType: TLazarusIDEHandlerType; Sender: TObject; BuildSuccessful: Boolean);
var
  I: Integer;
  xMethod: TLazBuildingFinishedEvent;
begin
  for I := 0 to FLazarusIDEHandlers[HandlerType].Count-1 do
  begin
    xMethod := TLazBuildingFinishedEvent(FLazarusIDEHandlers[HandlerType][I]);
    xMethod(Sender, BuildSuccessful);
  end;
end;

function TLazIDEInterface.DoCallRunDebug(var Handled: boolean): TModalResult;
begin
  Result:=DoCallModalHandledHandler(lihtRunDebug,Handled);
end;

function TLazIDEInterface.DoCallRunWithoutDebugBuilding(var Handled: boolean
  ): TModalResult;
begin
  Result:=DoCallModalHandledHandler(lihtRunWithoutDebugBuilding,Handled);
end;

function TLazIDEInterface.DoCallRunWithoutDebugInit(var Handled: boolean
  ): TModalResult;
begin
  Result:=DoCallModalHandledHandler(lihtRunWithoutDebugInit,Handled);
end;

procedure TLazIDEInterface.DoCallRunFinishedHandler;
begin
  DoCallNotifyHandler(lihtRunFinished);
end;

procedure TLazIDEInterface.RemoveAllHandlersOfObject(AnObject: TObject);
var
  HandlerType: TLazarusIDEHandlerType;
begin
  for HandlerType:=Low(HandlerType) to High(HandlerType) do
    FLazarusIDEHandlers[HandlerType].RemoveAllMethodsOfObject(AnObject);
end;

procedure TLazIDEInterface.AddHandlerOnSavingAll(
  const OnSaveAllEvent: TModalResultFunction; AsLast: boolean);
begin
  AddHandler(lihtSavingAll,TMethod(OnSaveAllEvent),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnSavingAll(
  const OnSaveAllEvent: TModalResultFunction);
begin
  RemoveHandler(lihtSavingAll,TMethod(OnSaveAllEvent));
end;

procedure TLazIDEInterface.AddHandlerOnSavedAll(
  const OnSaveAllEvent: TModalResultFunction; AsLast: boolean);
begin
  AddHandler(lihtSavedAll,TMethod(OnSaveAllEvent),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnSavedAll(
  const OnSaveAllEvent: TModalResultFunction);
begin
  RemoveHandler(lihtSavedAll,TMethod(OnSaveAllEvent));
end;

procedure TLazIDEInterface.AddHandlerOnSaveEditorFile(
  const OnSaveEditorFile: TSaveEditorFileEvent; AsLast: boolean);
begin
  AddHandler(lihtSaveEditorFile,TMethod(OnSaveEditorFile),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnSaveEditorFile(
  const OnSaveEditorFile: TSaveEditorFileEvent);
begin
  RemoveHandler(lihtSaveEditorFile,TMethod(OnSaveEditorFile));
end;

procedure TLazIDEInterface.AddHandlerOnIDERestoreWindows(
  const OnIDERestoreWindowsEvent: TNotifyEvent; AsLast: boolean);
begin
  AddHandler(lihtIDERestoreWindows,TMethod(OnIDERestoreWindowsEvent),AsLast);
end;

procedure TLazIDEInterface.AddHandlerOnLazarusBuilding(
  const OnLazBuildingEvent: TModalResultFunction; AsLast: boolean);
begin
  AddHandler(lihtLazarusBuilding,TMethod(OnLazBuildingEvent), AsLast);
end;

procedure TLazIDEInterface.AddHandlerOnLazarusBuildingFinished(
  const OnLazBuildingFinishedEvent: TLazBuildingFinishedEvent; AsLast: boolean);
begin
  AddHandler(lihtLazarusBuildingFinished,TMethod(OnLazBuildingFinishedEvent), AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnIDERestoreWindows(
  const OnIDERestoreWindowsEvent: TNotifyEvent);
begin
  RemoveHandler(lihtIDERestoreWindows,TMethod(OnIDERestoreWindowsEvent));
end;

procedure TLazIDEInterface.RemoveHandlerOnLazarusBuilding(
  const OnLazBuildingEvent: TModalResultFunction);
begin
  RemoveHandler(lihtLazarusBuilding,TMethod(OnLazBuildingEvent));
end;

procedure TLazIDEInterface.RemoveHandlerOnLazarusBuildingFinished(
  const OnLazBuildingFinishedEvent: TLazBuildingFinishedEvent);
begin
  RemoveHandler(lihtLazarusBuildingFinished,TMethod(OnLazBuildingFinishedEvent));
end;

procedure TLazIDEInterface.AddHandlerOnIDEClose(
  const OnIDECloseEvent: TNotifyEvent; AsLast: boolean);
begin
  AddHandler(lihtIDEClose,TMethod(OnIDECloseEvent),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnIDEClose(
  const OnIDECloseEvent: TNotifyEvent);
begin
  RemoveHandler(lihtIDEClose,TMethod(OnIDECloseEvent));
end;

procedure TLazIDEInterface.AddHandlerOnProjectOpened(
  const OnProjectOpenedEvent: TLazProjectChangedFunction; AsLast: boolean);
begin
  AddHandler(lihtProjectOpened,TMethod(OnProjectOpenedEvent),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnProjectOpened(
  const OnProjectOpenedEvent: TLazProjectChangedFunction);
begin
  RemoveHandler(lihtProjectOpened,TMethod(OnProjectOpenedEvent));
end;

procedure TLazIDEInterface.AddHandlerOnProjectClose(
  const OnProjectCloseEvent: TLazProjectChangedFunction; AsLast: boolean);
begin
  AddHandler(lihtProjectClose,TMethod(OnProjectCloseEvent),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnProjectClose(
  const OnProjectCloseEvent: TLazProjectChangedFunction);
begin
  RemoveHandler(lihtProjectClose,TMethod(OnProjectCloseEvent));
end;

procedure TLazIDEInterface.AddHandlerOnProjectBuilding(
  const OnProjBuildingEvent: TModalResultFunction; AsLast: boolean);
begin
  AddHandler(lihtProjectBuilding,TMethod(OnProjBuildingEvent),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnProjectBuilding(
  const OnProjBuildingEvent: TModalResultFunction);
begin
  RemoveHandler(lihtProjectBuilding,TMethod(OnProjBuildingEvent));
end;

procedure TLazIDEInterface.AddHandlerOnProjectDependenciesCompiling(
  const OnProjDependenciesCompilingEvent: TModalResultFunction; AsLast: boolean);
begin
  AddHandler(lihtProjectDependenciesCompiling,
             TMethod(OnProjDependenciesCompilingEvent),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnProjectDependenciesCompiling(
  const OnProjDependenciesCompilingEvent: TModalResultFunction);
begin
  RemoveHandler(lihtProjectDependenciesCompiling,
                TMethod(OnProjDependenciesCompilingEvent));
end;

procedure TLazIDEInterface.AddHandlerOnProjectDependenciesCompiled(
  const OnProjDependenciesCompiledEvent: TModalResultFunction; AsLast: boolean);
begin
  AddHandler(lihtProjectDependenciesCompiled,
             TMethod(OnProjDependenciesCompiledEvent),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnProjectDependenciesCompiled(
  const OnProjDependenciesCompiledEvent: TModalResultFunction);
begin
  RemoveHandler(lihtProjectDependenciesCompiled,
                TMethod(OnProjDependenciesCompiledEvent));
end;

procedure TLazIDEInterface.AddHandlerOnQuickSyntaxCheck(
  const OnQuickSyntaxCheckEvent: TModalHandledFunction; AsLast: boolean);
begin
  AddHandler(lihtQuickSyntaxCheck,TMethod(OnQuickSyntaxCheckEvent),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnQuickSyntaxCheck(
  const OnQuickSyntaxCheckEvent: TModalHandledFunction);
begin
  RemoveHandler(lihtQuickSyntaxCheck,TMethod(OnQuickSyntaxCheckEvent));
end;

procedure TLazIDEInterface.AddHandlerGetFPCFrontEndParams(
  const Handler: TGetFPCFrontEndParams; AsLast: boolean);
begin
  AddHandler(lihtGetFPCFrontEndParams,TMethod(Handler),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerGetFPCFrontEndParams(
  const Handler: TGetFPCFrontEndParams);
begin
  RemoveHandler(lihtGetFPCFrontEndParams,TMethod(Handler));
end;

function TLazIDEInterface.CallHandlerGetFPCFrontEndParams(Sender: TObject;
  var Params: string): boolean;
var
  i: longint;
begin
  i:=FLazarusIDEHandlers[lihtGetFPCFrontEndParams].Count;
  while FLazarusIDEHandlers[lihtGetFPCFrontEndParams].NextDownIndex(i) do
  begin
    if not TGetFPCFrontEndParams(FLazarusIDEHandlers[lihtGetFPCFrontEndParams][i])(Self,Params)
    then exit(false);
  end;
  Result:=true;
end;

procedure TLazIDEInterface.AddHandlerGetFPCFrontEndPath(
  const Handler: TGetFPCFrontEndPath; AsLast: boolean);
begin
  AddHandler(lihtGetFPCFrontEndPath,TMethod(Handler),AsLast);
end;

procedure TLazIDEInterface.AddHandlerOnProjectBuildingFinished(
  const OnProjBuildingFinishedEvent: TLazBuildingFinishedEvent; AsLast: boolean);
begin
  AddHandler(lihtProjectBuildingFinished,TMethod(OnProjBuildingFinishedEvent),AsLast);
end;

procedure TLazIDEInterface.AddHandlerOnChangeToolStatus(
  const OnChangeToolStatus: TLazToolStatusChangeEvent; AsLast: boolean);
begin
  AddHandler(lihtChangeToolStatus,TMethod(OnChangeToolStatus),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerGetFPCFrontEndPath(
  const Handler: TGetFPCFrontEndPath);
begin
  RemoveHandler(lihtGetFPCFrontEndPath,TMethod(Handler));
end;

procedure TLazIDEInterface.RemoveHandlerOnProjectBuildingFinished(
  const OnProjBuildingFinishedEvent: TLazBuildingFinishedEvent);
begin
  RemoveHandler(lihtProjectBuildingFinished,TMethod(OnProjBuildingFinishedEvent));
end;

procedure TLazIDEInterface.RemoveHandlerOnChangeToolStatus(
  const OnChangeToolStatus: TLazToolStatusChangeEvent);
begin
  RemoveHandler(lihtChangeToolStatus,TMethod(OnChangeToolStatus));
end;

procedure TLazIDEInterface.AddHandlerOnRunDebug(
  const Event: TModalHandledFunction; AsLast: boolean);
begin
  AddHandler(lihtRunDebug,TMethod(Event),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnRunDebug(
  const Event: TModalHandledFunction);
begin
  RemoveHandler(lihtRunDebug,TMethod(Event));
end;

procedure TLazIDEInterface.AddHandlerOnRunWithoutDebugBuilding(
  const Event: TModalHandledFunction; AsLast: boolean);
begin
  AddHandler(lihtRunWithoutDebugBuilding,TMethod(Event),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnRunWithoutDebugBuilding(
  const Event: TModalHandledFunction);
begin
  RemoveHandler(lihtRunWithoutDebugBuilding,TMethod(Event));
end;

procedure TLazIDEInterface.AddHandlerOnRunWithoutDebugInit(
  const Event: TModalHandledFunction; AsLast: boolean);
begin
  AddHandler(lihtRunWithoutDebugInit,TMethod(Event),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnRunWithoutDebugInit(
  const Event: TModalHandledFunction);
begin
  RemoveHandler(lihtRunWithoutDebugInit,TMethod(Event));
end;

procedure TLazIDEInterface.AddHandlerOnRunFinished(
  const OnRunFinishedEvent: TNotifyEvent; AsLast: boolean);
begin
  AddHandler(lihtRunFinished,TMethod(OnRunFinishedEvent),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnRunFinished(
  const OnRunFinishedEvent: TNotifyEvent);
begin
  RemoveHandler(lihtRunFinished,TMethod(OnRunFinishedEvent));
end;

function TLazIDEInterface.CallHandlerGetFPCFrontEndPath(Sender: TObject;
  var Path: string): boolean;
var
  i: longint;
begin
  i:=FLazarusIDEHandlers[lihtGetFPCFrontEndPath].Count;
  while FLazarusIDEHandlers[lihtGetFPCFrontEndPath].NextDownIndex(i) do
  begin
    if not TGetFPCFrontEndPath(FLazarusIDEHandlers[lihtGetFPCFrontEndPath][i])(Self,Path)
    then exit(false);
  end;
  Result:=true;
end;

procedure TLazIDEInterface.AddHandlerOnShowDesignerFormOfSource(
  const OnShowDesignerFormOfSourceEvent: TShowDesignerFormOfSourceFunction; AsLast: boolean);
begin
  AddHandler(lihtShowDesignerFormOfSource,TMethod(OnShowDesignerFormOfSourceEvent),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnShowDesignerFormOfSource(
  const OnShowDesignerFormOfSourceEvent: TShowDesignerFormOfSourceFunction);
begin
  RemoveHandler(lihtShowDesignerFormOfSource,TMethod(OnShowDesignerFormOfSourceEvent));
end;

procedure TLazIDEInterface.AddHandlerOnShowSourceOfActiveDesignerForm(
  const OnShowSourceOfActiveDesignerForm: TNotifyEvent; AsLast: boolean);
begin
  AddHandler(lihtShowSourceOfActiveDesignerForm,TMethod(OnShowSourceOfActiveDesignerForm),AsLast);
end;

procedure TLazIDEInterface.RemoveHandlerOnShowSourceOfActiveDesignerForm(
  const OnShowSourceOfActiveDesignerForm: TNotifyEvent);
begin
  RemoveHandler(lihtShowSourceOfActiveDesignerForm,TMethod(OnShowSourceOfActiveDesignerForm));
end;

initialization
  RegisterPropertyEditor(TypeInfo(AnsiString),
    THTMLBrowserHelpViewer,'BrowserPath',TFileNamePropertyEditor);

end.