diff --git a/Pasfmt.Main.pas b/Pasfmt.Main.pas index bd0c4e7..b0a9ce8 100644 --- a/Pasfmt.Main.pas +++ b/Pasfmt.Main.pas @@ -20,6 +20,7 @@ implementation System.JSON, Pasfmt.Log, Pasfmt.OnSave, + Pasfmt.ProjectNotifier, System.Generics.Collections; type @@ -29,6 +30,7 @@ TPlugin = class(TObject) FKeyboardBindingIndex: Integer; FInfoIndex: Integer; FEditorIndex: Integer; + FProjectIndex: Integer; FAddInOptions: TPasfmtAddInOptions; FBitmaps: TObjectList; @@ -99,6 +101,7 @@ constructor TPlugin.Create; FBitmaps := TObjectList.Create; FEditorIndex := (BorlandIDEServices as IOTAEditorServices).AddNotifier(OnSaveInstaller); + FProjectIndex := (BorlandIDEServices as IOTAProject).AddNotifier(OnProjectNotify); OnSaveInstaller.ConfigureFormatter := ConfigureFormatter; FPasfmtMenu := TMenuItem.Create((BorlandIDEServices as INTAServices).MainMenu); @@ -139,6 +142,7 @@ destructor TPlugin.Destroy; begin FinalizeLog; (BorlandIDEServices as IOTAEditorServices).RemoveNotifier(FEditorIndex); + (BorlandIDEServices as IOTAProject).RemoveNotifier(FProjectIndex); (BorlandIDEServices as IOTAAboutBoxServices).RemovePluginInfo(FInfoIndex); (BorlandIDEServices as INTAEnvironmentOptionsServices).UnregisterAddInOptions(FAddInOptions); (BorlandIDEServices as IOTAKeyboardServices).RemoveKeyboardBinding(FKeyboardBindingIndex); diff --git a/Pasfmt.ProjectNotifier.pas b/Pasfmt.ProjectNotifier.pas new file mode 100644 index 0000000..5b6bc73 --- /dev/null +++ b/Pasfmt.ProjectNotifier.pas @@ -0,0 +1,93 @@ +unit Pasfmt.ProjectNotifier; + +interface + +uses + ToolsAPI, + System.SysUtils, + System.StrUtils; + +type + TProjectNotifier = class(TNotifierObject, IOTANotifier, IOTAModuleNotifier, IOTAProjectNotifier) + public + { IOTANotifier } + procedure AfterSave; + procedure BeforeSave; + procedure Destroyed; + procedure Modified; + + { IOTAModuleNotifier } + function CheckOverwrite: Boolean; + procedure ModuleRenamed(const NewName: string); overload; + + { IOTAProjectNotifier } + procedure ModuleAdded(const AFileName: string); + procedure ModuleRemoved(const AFileName: string); + procedure ModuleRenamed(const AOldFileName, ANewFileName: string); overload; + end; + +function OnProjectNotify: TProjectNotifier; + +implementation + +var + GOnProjectNotifier: IOTAProjectNotifier; + +function OnProjectNotify: TProjectNotifier; +begin + if not Assigned(GOnProjectNotifier) then + begin + GOnProjectNotifier := TProjectNotifier.Create; + end; + + Result := TProjectNotifier(GOnProjectNotifier); +end; + +{ TProjectNotifier } + +procedure TProjectNotifier.AfterSave; +begin + inherited; +end; + +procedure TProjectNotifier.BeforeSave; +begin + inherited; +end; + +function TProjectNotifier.CheckOverwrite: Boolean; +begin + Result := True; +end; + +procedure TProjectNotifier.Destroyed; +begin + inherited; +end; + +procedure TProjectNotifier.Modified; +begin + +end; + +procedure TProjectNotifier.ModuleAdded(const AFileName: string); +begin + +end; + +procedure TProjectNotifier.ModuleRemoved(const AFileName: string); +begin + +end; + +procedure TProjectNotifier.ModuleRenamed(const NewName: string); +begin + +end; + +procedure TProjectNotifier.ModuleRenamed(const AOldFileName, ANewFileName: string); +begin + +end; + +end. diff --git a/Pasfmt.dpk b/Pasfmt.dpk index 0a5874d..7533e87 100644 --- a/Pasfmt.dpk +++ b/Pasfmt.dpk @@ -44,6 +44,7 @@ contains Pasfmt.Settings in 'Pasfmt.Settings.pas', Pasfmt.SettingsFrame in 'Pasfmt.SettingsFrame.pas' {PasfmtSettingsFrame: TFrame}, Pasfmt.OnSave in 'Pasfmt.OnSave.pas', - Pasfmt.Cursors in 'Pasfmt.Cursors.pas'; + Pasfmt.Cursors in 'Pasfmt.Cursors.pas', + Pasfmt.ProjectNotifier in 'Pasfmt.ProjectNotifier.pas'; end. diff --git a/Pasfmt.dproj b/Pasfmt.dproj index 6b21cd8..fc1eaf0 100644 --- a/Pasfmt.dproj +++ b/Pasfmt.dproj @@ -7,8 +7,9 @@ Pasfmt.dpk Win32 {5B79110C-4DE7-4913-8685-8C1C2B22ED1D} - 19.5 - 1 + Pasfmt + 20.3 + 1048577 true @@ -18,6 +19,11 @@ Base true + + true + Base + true + true Base @@ -61,6 +67,13 @@ true 1033 + + true + Debug + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + true + 1033 + true true @@ -106,6 +119,7 @@ + ResourceItem RCDATA @@ -144,6 +158,7 @@ True False + True 12