mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-19 19:49:31 +01:00
DocMgr: Added description editor. Conditional support for FCL packages
git-svn-id: trunk@35831 -
This commit is contained in:
parent
3681e6f4dd
commit
4ecdea86a6
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -3773,6 +3773,8 @@ examples/fpdocmanager/docs/umakeskel.xml svneol=native#text/plain
|
||||
examples/fpdocmanager/docs/umanager.xml svneol=native#text/plain
|
||||
examples/fpdocmanager/fconfig.lfm svneol=native#text/plain
|
||||
examples/fpdocmanager/fconfig.pas svneol=native#text/pascal
|
||||
examples/fpdocmanager/feditor.lfm svneol=native#text/plain
|
||||
examples/fpdocmanager/feditor.pas svneol=native#text/pascal
|
||||
examples/fpdocmanager/flogview.lfm svneol=native#text/plain
|
||||
examples/fpdocmanager/flogview.pas svneol=native#text/pascal
|
||||
examples/fpdocmanager/fmain.lfm svneol=native#text/plain
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="10">
|
||||
<Units Count="11">
|
||||
<Unit0>
|
||||
<Filename Value="FPDocManager.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
@ -95,9 +95,18 @@
|
||||
<UnitName Value="ConfigFile"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="text.txt"/>
|
||||
<Filename Value="..\..\doceditor\frmmain.pp"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<HasResources Value="True"/>
|
||||
<UnitName Value="FrmMain"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="feditor.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="ModuleEditor"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="fEditor"/>
|
||||
</Unit10>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
@ -108,7 +117,7 @@
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="$(FPCSrcDir)\utils\fpdoc;$(FPCSrcDir)\packages\fcl-passrc\src"/>
|
||||
<OtherUnitFiles Value="$(FPCSrcDir)\utils\fpdoc;$(FPCSrcDir)\packages\fcl-passrc\src;..\..\doceditor"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
@ -122,6 +131,7 @@
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CustomOptions Value="-uFCLadds"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
|
||||
@ -7,8 +7,8 @@ uses
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, umakeskel, fMain, fConfig, uManager, fLogView,
|
||||
fUpdateView, ulpk, ConfigFile;
|
||||
Forms, frmmain, umakeskel, fMain, fConfig, uManager, fLogView,
|
||||
fUpdateView, ulpk, ConfigFile, feditor;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
|
||||
@ -168,8 +168,8 @@ object CfgWizard: TCfgWizard
|
||||
end
|
||||
object MkLCL: TTabSheet
|
||||
Caption = 'LCL'
|
||||
ClientHeight = 211
|
||||
ClientWidth = 309
|
||||
ClientHeight = 212
|
||||
ClientWidth = 307
|
||||
OnShow = MkLCLShow
|
||||
object Label4: TLabel
|
||||
Left = 10
|
||||
@ -192,7 +192,7 @@ object CfgWizard: TCfgWizard
|
||||
Left = 100
|
||||
Height = 23
|
||||
Top = 66
|
||||
Width = 200
|
||||
Width = 198
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
OnChange = edLazDirChange
|
||||
TabOrder = 1
|
||||
@ -266,7 +266,7 @@ object CfgWizard: TCfgWizard
|
||||
end
|
||||
object NoParse: TTabSheet
|
||||
Caption = 'NoParse'
|
||||
ClientHeight = 211
|
||||
ClientHeight = 212
|
||||
ClientWidth = 307
|
||||
object Label7: TLabel
|
||||
Left = 10
|
||||
@ -289,7 +289,7 @@ object CfgWizard: TCfgWizard
|
||||
end
|
||||
object edNoParse: TMemo
|
||||
Left = 12
|
||||
Height = 122
|
||||
Height = 123
|
||||
Top = 88
|
||||
Width = 288
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
|
||||
@ -164,7 +164,11 @@ begin
|
||||
|
||||
edLazDir.Text := Manager.LazarusDir;
|
||||
|
||||
{$IFDEF FCLadds}
|
||||
swFCLads.Checked := Manager.IsExtended('fcl') <> '';
|
||||
{$ELSE}
|
||||
MkFCL.TabVisible := False;
|
||||
{$ENDIF}
|
||||
|
||||
swNoParse.Checked := Manager.ExcludeUnits;
|
||||
edNoParse.Lines.Assign(Manager.NoParseUnits);
|
||||
|
||||
9
examples/fpdocmanager/feditor.lfm
Normal file
9
examples/fpdocmanager/feditor.lfm
Normal file
@ -0,0 +1,9 @@
|
||||
object ModuleEditor: TModuleEditor
|
||||
Left = 758
|
||||
Height = 624
|
||||
Top = 140
|
||||
Width = 686
|
||||
Caption = 'ModuleEditor'
|
||||
OnCreate = NewCreate
|
||||
LCLVersion = '0.9.31'
|
||||
end
|
||||
70
examples/fpdocmanager/feditor.pas
Normal file
70
examples/fpdocmanager/feditor.pas
Normal file
@ -0,0 +1,70 @@
|
||||
unit fEditor;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
FrmMain;
|
||||
|
||||
type
|
||||
|
||||
{ TModuleEditor }
|
||||
|
||||
TModuleEditor = class(TMainForm)
|
||||
procedure NewCreate(Sender: TObject);
|
||||
private
|
||||
procedure BuildRecent(const AUnit: string);
|
||||
public
|
||||
constructor CreateFor(const AUnit: string; TheOwner: TComponent);
|
||||
end;
|
||||
|
||||
var
|
||||
ModuleEditor: TModuleEditor;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
LazDEOpts, IniFiles;
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TModuleEditor }
|
||||
|
||||
procedure TModuleEditor.NewCreate(Sender: TObject);
|
||||
begin
|
||||
(* New OnCreate handler - do adjustments before calling the inherited handler.
|
||||
*)
|
||||
//set Recent to current unit
|
||||
//what, how?
|
||||
MainFormCreate(Sender);
|
||||
end;
|
||||
|
||||
procedure TModuleEditor.BuildRecent(const AUnit: string);
|
||||
const
|
||||
SecPrefs = 'Preferences';
|
||||
begin
|
||||
With TInifile.Create(UTF8ToSys(GetoptionFileName)) do
|
||||
try
|
||||
EraseSection('Recent');
|
||||
WriteInteger('Recent','Count',1);
|
||||
WriteString('Recent','File1',AUnit);
|
||||
//for LoadOptions
|
||||
WriteBool(SecPrefs, 'StartMaximized', False);
|
||||
WriteBool(SecPrefs, 'ReopenLast', True);
|
||||
UpdateFile;
|
||||
Finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TModuleEditor.CreateFor(const AUnit: string; TheOwner: TComponent);
|
||||
begin
|
||||
MainForm := Self; //referenced in editor units
|
||||
BuildRecent(AUnit); //force loading of AUnit
|
||||
Create(TheOwner);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@ -10,6 +10,7 @@ object Main: TMain
|
||||
Menu = MainMenu1
|
||||
OnCreate = FormCreate
|
||||
OnResize = FormResize
|
||||
ShowHint = True
|
||||
LCLVersion = '0.9.31'
|
||||
object lbPackages: TComboBox
|
||||
Left = 0
|
||||
@ -38,11 +39,13 @@ object Main: TMain
|
||||
object lbUnits: TListBox
|
||||
Left = 0
|
||||
Height = 436
|
||||
Hint = 'Double click to edit the description file'
|
||||
Top = 0
|
||||
Width = 100
|
||||
Align = alLeft
|
||||
ItemHeight = 0
|
||||
OnClick = lbUnitsClick
|
||||
OnDblClick = lbUnitsDblClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object Panel1: TPanel
|
||||
@ -68,6 +71,7 @@ object Main: TMain
|
||||
object swAll: TRadioButton
|
||||
Left = 10
|
||||
Height = 19
|
||||
Hint = 'Action on all package units'
|
||||
Top = 10
|
||||
Width = 32
|
||||
Caption = 'all'
|
||||
@ -78,6 +82,7 @@ object Main: TMain
|
||||
object swSingle: TRadioButton
|
||||
Left = 48
|
||||
Height = 19
|
||||
Hint = 'Actions only on the selected unit'
|
||||
Top = 10
|
||||
Width = 43
|
||||
Caption = 'only'
|
||||
@ -87,6 +92,7 @@ object Main: TMain
|
||||
object edUnit: TEdit
|
||||
Left = 96
|
||||
Height = 23
|
||||
Hint = 'The selected unit'
|
||||
Top = 10
|
||||
Width = 260
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
@ -96,6 +102,7 @@ object Main: TMain
|
||||
object buRefresh: TButton
|
||||
Left = 96
|
||||
Height = 25
|
||||
Hint = 'Update descriptions from source files'
|
||||
Top = 40
|
||||
Width = 75
|
||||
Caption = 'Refresh'
|
||||
@ -122,6 +129,7 @@ object Main: TMain
|
||||
object buTest: TButton
|
||||
Left = 9
|
||||
Height = 25
|
||||
Hint = 'Syntax check of the description file'
|
||||
Top = 40
|
||||
Width = 75
|
||||
Caption = 'Test only'
|
||||
@ -179,7 +187,7 @@ object Main: TMain
|
||||
TabOrder = 9
|
||||
end
|
||||
end
|
||||
object GroupBox2: TGroupBox
|
||||
object gbAltDir: TGroupBox
|
||||
Left = 1
|
||||
Height = 95
|
||||
Top = 1
|
||||
@ -440,11 +448,11 @@ object Main: TMain
|
||||
end
|
||||
object ViewXML: TTabSheet
|
||||
Caption = 'Project'
|
||||
ClientHeight = 315
|
||||
ClientHeight = 436
|
||||
ClientWidth = 467
|
||||
inline edXML: TSynEdit
|
||||
Left = 0
|
||||
Height = 315
|
||||
Height = 436
|
||||
Top = 0
|
||||
Width = 467
|
||||
Align = alClient
|
||||
@ -928,16 +936,16 @@ object Main: TMain
|
||||
end
|
||||
object ViewINI: TTabSheet
|
||||
Caption = 'INI'
|
||||
ClientHeight = 375
|
||||
ClientHeight = 436
|
||||
ClientWidth = 467
|
||||
object edINI: TMemo
|
||||
Left = 0
|
||||
Height = 375
|
||||
Height = 436
|
||||
Top = 0
|
||||
Width = 467
|
||||
Align = alClient
|
||||
Lines.Strings = (
|
||||
'edINI'
|
||||
''
|
||||
)
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 0
|
||||
|
||||
@ -38,7 +38,7 @@ type
|
||||
edDefOut: TEdit;
|
||||
edUnit: TEdit;
|
||||
GroupBox1: TGroupBox;
|
||||
GroupBox2: TGroupBox;
|
||||
gbAltDir: TGroupBox;
|
||||
Label2: TLabel;
|
||||
Label3: TLabel;
|
||||
Label4: TLabel;
|
||||
@ -93,6 +93,7 @@ type
|
||||
procedure lbBackendExit(Sender: TObject);
|
||||
procedure lbPackagesClick(Sender: TObject);
|
||||
procedure lbUnitsClick(Sender: TObject);
|
||||
procedure lbUnitsDblClick(Sender: TObject);
|
||||
procedure mnConfigClick(Sender: TObject);
|
||||
procedure mnExitClick(Sender: TObject);
|
||||
procedure mnImportLpkClick(Sender: TObject);
|
||||
@ -133,6 +134,7 @@ implementation
|
||||
uses
|
||||
fConfig, fLogView, fUpdateView,
|
||||
//dwlinear,
|
||||
fEditor,
|
||||
dWriter;
|
||||
|
||||
{$R *.lfm}
|
||||
@ -145,6 +147,10 @@ var
|
||||
s: string;
|
||||
l: TStringList;
|
||||
begin
|
||||
{$IFDEF FCLAdds}
|
||||
{$ELSE}
|
||||
gbAltDir.Visible := False;
|
||||
{$ENDIF}
|
||||
Manager := TFPDocManager.Create(self);
|
||||
Manager.OnChange := @ProjectsChanged;
|
||||
if not Manager.LoadConfig(GetCurrentDir) then begin
|
||||
@ -495,11 +501,15 @@ begin
|
||||
//load units...
|
||||
lbUnits.Items.BeginUpdate;
|
||||
lbUnits.Clear;
|
||||
{$IFDEF old}
|
||||
for i := 0 to pkg.Units.Count - 1 do begin
|
||||
//fn := Manager.UnitName(pkg.Inputs, i);
|
||||
fn := pkg.Units.Names[i];
|
||||
lbUnits.AddItem(fn, nil);
|
||||
end;
|
||||
{$ELSE}
|
||||
pkg.EnumUnits(lbUnits.Items);
|
||||
{$ENDIF}
|
||||
lbUnits.Sorted := True;
|
||||
lbUnits.Items.EndUpdate;
|
||||
//remember selection
|
||||
@ -551,6 +561,20 @@ begin
|
||||
ShowUpdate;
|
||||
end;
|
||||
|
||||
procedure TMain.lbUnitsDblClick(Sender: TObject);
|
||||
var
|
||||
u: string;
|
||||
begin
|
||||
//edit unit description in LazDE form
|
||||
//setup unit
|
||||
//CurUnit := lbUnits.Items[lbUnits.ItemIndex]; - already set
|
||||
u := Manager.Package.DescrFileName(CurUnit);
|
||||
//create form
|
||||
ModuleEditor := TModuleEditor.CreateFor(u, self);
|
||||
//show it
|
||||
ModuleEditor.Show;
|
||||
end;
|
||||
|
||||
procedure TMain.swSingleClick(Sender: TObject);
|
||||
begin
|
||||
edUnit.Enabled := swSingle.Checked;
|
||||
|
||||
@ -74,6 +74,7 @@ type
|
||||
FRequires: TStrings;
|
||||
FUnitPath: string;
|
||||
FUnits: TStrings;
|
||||
function GetAltDir: string;
|
||||
procedure SetAllDirs(AValue: boolean);
|
||||
procedure SetAltDir(AValue: string);
|
||||
procedure SetCompOpts(AValue: string);
|
||||
@ -99,6 +100,8 @@ type
|
||||
function CreateProject(APrj: TFPDocHelper; const AFile: string): boolean; virtual; //new package project
|
||||
function ImportProject(APrj: TFPDocHelper; APkg: TFPDocPackage; const AFile: string): boolean;
|
||||
procedure UpdateConfig;
|
||||
procedure EnumUnits(AList: TStrings); virtual;
|
||||
function DescrFileName(const AUnit: string): string;
|
||||
property Name: string read FName write SetName;
|
||||
property Loaded: boolean read FLoaded write SetLoaded;
|
||||
property ProjectFile: string read FProjectFile write SetProjectFile; //xml?
|
||||
@ -110,7 +113,7 @@ type
|
||||
property ProjectDir: string read FProjectDir write SetProjectDir;
|
||||
property DescrDir: string read FDescrDir write SetDescrDir;
|
||||
property Descriptions: TStrings read FDescriptions write SetDescriptions;
|
||||
property AltDir: string read FAltDir write SetAltDir;
|
||||
property AltDir: string read GetAltDir write SetAltDir;
|
||||
property InputDir: string read FInputDir write SetInputDir;
|
||||
property SrcDirs: TStrings read FSrcDirs;
|
||||
property Units: TStrings read FUnits write SetUnits;
|
||||
@ -439,6 +442,15 @@ begin
|
||||
FAllDirs:=AValue;
|
||||
end;
|
||||
|
||||
function TDocPackage.GetAltDir: string;
|
||||
begin
|
||||
{$IFDEF FCLadds}
|
||||
Result := FAltDir;
|
||||
{$ELSE}
|
||||
Result := '';
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TDocPackage.SetDescriptions(AValue: TStrings);
|
||||
(* Shall we allow for multiple descriptions? (general + OS specific!?)
|
||||
*)
|
||||
@ -751,7 +763,7 @@ begin
|
||||
Config.WriteString(SecDoc, 'inputdir', InputDir);
|
||||
Config.WriteString(SecDoc, 'options', CompOpts);
|
||||
Config.WriteString(SecDoc, 'descrdir', DescrDir);
|
||||
Config.WriteString(SecDoc, 'AltDir', AltDir);
|
||||
Config.WriteString(SecDoc, 'AltDir', FAltDir);
|
||||
Config.WriteBool(SecDoc, 'AllDirs', AllDirs);
|
||||
Config.WriteString(SecDoc, 'requires', Requires.CommaText);
|
||||
//units
|
||||
@ -763,6 +775,25 @@ begin
|
||||
Loaded := True;
|
||||
end;
|
||||
|
||||
procedure TDocPackage.EnumUnits(AList: TStrings);
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
//override to add further units (from AltDir...)
|
||||
for i := 0 to Units.Count - 1 do
|
||||
AList.Add(Units.Names[i]);
|
||||
end;
|
||||
|
||||
function TDocPackage.DescrFileName(const AUnit: string): string;
|
||||
begin
|
||||
(* [ProjectDir +] DescrDir + AUnit + .xml
|
||||
*)
|
||||
Result := DescrDir;
|
||||
if (Result = '') or (Result[1] = '.') then
|
||||
Result := ProjectDir + Result;
|
||||
Result := Result + DirectorySeparator + AUnit + '.xml';
|
||||
end;
|
||||
|
||||
function TDocPackage.IniFileName: string;
|
||||
begin
|
||||
Result := Manager.RootDir + Name + '.ini';
|
||||
@ -1163,11 +1194,15 @@ function TFPDocManager.IsExtended(const APkg: string): string;
|
||||
var
|
||||
pkg: TDocPackage;
|
||||
begin
|
||||
{$IFDEF FCLadds}
|
||||
pkg := AddPackage(APkg);
|
||||
if pkg = nil then
|
||||
Result := ''
|
||||
else
|
||||
Result := pkg.AltDir;
|
||||
{$ELSE}
|
||||
Result := '';
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TFPDocManager.ImportLpk(const AFile: string): TDocPackage;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user