Recent

Author Topic: Package - code documentation  (Read 1717 times)

J-23

  • Full Member
  • ***
  • Posts: 108
Package - code documentation
« on: April 12, 2020, 08:28:48 pm »
Hello,
In the editor of his own component, he needs access to the 'component palette' installed in Lazarus. I tried to get this palette out of the code, but it is related to many things in the IDE.

So I have two options:
1. Has anyone a component that can retrieve information about installed packages / components?
2. Is there any additional documentation about how the packages work? - So that you can write such a palette as a component. (Is all I need to do is code analysis?)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Package - code documentation
« Reply #1 on: April 12, 2020, 08:49:05 pm »
The IDE has an entire menu devoted to packages.
The Open xxx menu items open a loaded, or recent or specifically-browsed-for package in the package editor, which gives you access to information about the package, as well as ability to edit aspects of the package.
The Package Graph... and Package Links... items give you access to tons of information about all the packages the IDE knows about, and their inter-relationships and inter-dependencies.
The New Component... item is a wizard-style series of dialogs which walks you through the process of creating and registering a new component (and perhaps a new component editor, if needed).
Components are registered in the component palette using the Register call which must contain one or more calls to RegisterComponents().
This procedure takes two parameters, a string specifying the page in the component palette where the component will be placed (it can be a new page, or an existing page), and an array of component classes containing the classes to be registered (the array may contain one or more classes).
« Last Edit: April 12, 2020, 08:55:57 pm by howardpc »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9867
  • Debugger - SynEdit - and more
    • wiki
Re: Package - code documentation
« Reply #2 on: April 12, 2020, 09:32:35 pm »
I do not know if there is, but you would have to search the package IdeIntf.
That is, how 3rd party package can access some parts of the IDE.

J-23

  • Full Member
  • ***
  • Posts: 108
Re: Package - code documentation
« Reply #3 on: April 14, 2020, 01:48:31 am »
I do not know if there is, but you would have to search the package IdeIntf.

Yes i know

I wonder how to enter Lazarus Debug code - step by step.

To know how the procedure works:
Code: Pascal  [Select][+][-]
  1. PkgBoss.LoadInstalledPackages;
  2.  

The procedure is located on the line: 1590 unit: "Main.pp"

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9867
  • Debugger - SynEdit - and more
    • wiki
Re: Package - code documentation
« Reply #4 on: April 14, 2020, 02:01:49 am »
I wonder how to enter Lazarus Debug code - step by step.
Do you mean: How to debug the Lazarus IDE itself.

- Compile from menu: Tools -> Configure Build Lazarus
  It the "Custom Options" enter: -gw -godwarfsets
  Press "build"
- Open project: ide/lazarus.lpi
- Set breakpoints
- Run with F9

If you change the code, you must build from Tools menu again.

J-23

  • Full Member
  • ***
  • Posts: 108
Re: Package - code documentation
« Reply #5 on: April 14, 2020, 09:26:51 pm »
I wonder how to enter Lazarus Debug code - step by step.
Do you mean: How to debug the Lazarus IDE itself.

- Compile from menu: Tools -> Configure Build Lazarus
  It the "Custom Options" enter: -gw -godwarfsets
  Press "build"
- Open project: ide/lazarus.lpi
- Set breakpoints
- Run with F9

If you change the code, you must build from Tools menu again.

Works :)

J-23

  • Full Member
  • ***
  • Posts: 108
Re: Package - code documentation
« Reply #6 on: April 14, 2020, 10:00:52 pm »
Hello,

Everything is based on the list:
Code: Pascal  [Select][+][-]
  1. RegisteredPackages


which is declared like this:
Code: Pascal  [Select][+][-]
  1. RegisteredPackages: TFPList; // list of PRegisteredPackage

which is created in the Lazarus compilation process and then read in function:
Code: Pascal  [Select][+][-]
  1. procedure TPkgManager.LoadStaticCustomPackages;
  2. var
  3.   StaticPackages: TFPList;
  4.   StaticPackage: PRegisteredPackage;
  5.   i: Integer;
  6.   APackage: TLazPackage;
  7.   Quiet: Boolean;
  8. begin
  9.   StaticPackages:=LazarusPackageIntf.RegisteredPackages;
  10.   if StaticPackages=nil then exit;
  11.   Quiet:=false;
  12.  
  13.   // register IDE's FCL components
  14.  
  15.   // register components in Lazarus packages
  16.   for i:=0 to StaticPackages.Count-1 do begin
  17.     StaticPackage:=PRegisteredPackage(StaticPackages[i]);
  18.     //debugln(['TPkgManager.LoadStaticCustomPackages ',StaticPackage^.Name]);
  19.  
  20.     // check package name
  21.     if not IsValidPkgName(StaticPackage^.Name)
  22.     then begin
  23.       DebugLn('Warning: (lazarus) [TPkgManager.LoadStaticCustomPackages] Invalid Package Name: "',
  24.         BinaryStrToText(StaticPackage^.Name),'"');
  25.       continue;
  26.     end;
  27.    
  28.     // check RegisterFCLBaseComponents procedure
  29.     if (StaticPackage^.RegisterProc=nil) then begin
  30.       DebugLn('Warning: (lazarus) [TPkgManager.LoadStaticCustomPackages]',
  31.         ' Package "',StaticPackage^.Name,'" has no register procedure.');
  32.       continue;
  33.     end;
  34.    
  35.     // load package
  36.     APackage:=LoadInstalledPackage(StaticPackage^.Name,KeepInstalledPackages,
  37.                                    Quiet);
  38.  
  39.     PackageGraph.RegisterStaticPackage(APackage,StaticPackage^.RegisterProc);
  40.   end;
  41.   PackageGraph.SortAutoInstallDependencies;
  42.   ClearRegisteredPackages;
  43. end;
  44.  

I did not find any external configuration files with information about installed packages (I was hoping for that :))

This information would help me build the component palette as a component for use in the IDE.

I have two solutions:
1. Interference with the Lazarus code (Which is not my goal)
2. Read the used memory address of the list so as to access its contents

What do you think about idea 2?

 

TinyPortal © 2005-2018