I'm trying to develop an IDE Extension for Lazarus (following
https://wiki.lazarus.freepascal.org/Extending_the_IDE).
While there are examples of how to get the currently open project, all examples I've found for opening packages assume the developer knows the package name.
I'm trying to develop an extension that will be accessed via a menu item on the Package Editor form. I've succeeded in creating the menu item, as follows:
unit UGenerateGitIgnore;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, MenuIntf;
procedure WriteGitIgnoreForPackage(Sender: TObject);
procedure Register;
implementation
procedure WriteGitIgnoreForPackage(Sender: TObject);
begin
end;
procedure Register;
begin
RegisterIDEMenuCommand(
PkgEditMenuSectionMisc,
'gitignore',
'Generate .gitignore',
nil,
@WriteGitIgnoreForPackage
);
end;
end.
My current problem is, how do I know,
inside the WriteGitIgnoreForPackage procedure, which package did the user clicked the menu item from?
For this particular use case what I really must know is where the .lpk file resides, but ideally I would be able to get an TIDEPackage reference.
I've already tried using
PackageEditingInterface.GetPackageOfEditorItem(Sender);
(found this being done on ToDoDlg.pas, on lazarus/components/todolist) but this always returns nil.