mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 19:59:17 +02:00
IDE: fpdoc package name: allow only valid characters
git-svn-id: trunk@34828 -
This commit is contained in:
parent
1a5a4fbd4c
commit
e588d500e4
@ -363,6 +363,7 @@ function ToOSLineEnding(const s: String): String;
|
|||||||
function ReplaceLineEndings(const s, NewLineEnds: string): string;
|
function ReplaceLineEndings(const s, NewLineEnds: string): string;
|
||||||
function AppendLineEnding(const s: string): string; // append if not empty and there is not already a line ending
|
function AppendLineEnding(const s: string): string; // append if not empty and there is not already a line ending
|
||||||
function XMLUnescape(s: string): string; // convert escape characters
|
function XMLUnescape(s: string): string; // convert escape characters
|
||||||
|
function MakeValidFPDocPackageName(const s: string): string;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -523,6 +524,17 @@ begin
|
|||||||
Result:=s;
|
Result:=s;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function MakeValidFPDocPackageName(const s: string): string;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result:=s;
|
||||||
|
for i:=length(Result) downto 1 do
|
||||||
|
if not (Result[i] in ['a'..'z','A'..'Z','0'..'9','_',' ',',','+','-','/','(',')'])
|
||||||
|
then
|
||||||
|
system.Delete(Result,i,1);
|
||||||
|
end;
|
||||||
|
|
||||||
function CompareLazFPDocFilenames(Data1, Data2: Pointer): integer;
|
function CompareLazFPDocFilenames(Data1, Data2: Pointer): integer;
|
||||||
begin
|
begin
|
||||||
Result:=CompareFilenames(TLazFPDocFile(Data1).Filename,
|
Result:=CompareFilenames(TLazFPDocFile(Data1).Filename,
|
||||||
|
@ -6,7 +6,8 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||||
StdCtrls, Buttons, Project, IDEOptionsIntf, LazarusIDEStrConsts, IDEProcs;
|
StdCtrls, Buttons, Project, IDEOptionsIntf, LazarusIDEStrConsts, IDEProcs,
|
||||||
|
FPDocEditWindow, CodeHelp;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ type
|
|||||||
procedure PathsListBoxSelectionChange(Sender: TObject; User: boolean);
|
procedure PathsListBoxSelectionChange(Sender: TObject; User: boolean);
|
||||||
procedure PathEditChange(Sender: TObject);
|
procedure PathEditChange(Sender: TObject);
|
||||||
private
|
private
|
||||||
|
function GetFPDocPkgNameEditValue: string;
|
||||||
public
|
public
|
||||||
function GetTitle: string; override;
|
function GetTitle: string; override;
|
||||||
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
|
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
|
||||||
@ -91,8 +93,10 @@ end;
|
|||||||
|
|
||||||
procedure TProjectFPDocOptionsFrame.FPDocPackageNameEditExit(Sender: TObject);
|
procedure TProjectFPDocOptionsFrame.FPDocPackageNameEditExit(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if FPDocPackageNameEdit.Text='' then
|
if GetFPDocPkgNameEditValue='' then
|
||||||
FPDocPackageNameEdit.Text:=lisDefaultPlaceholder;
|
FPDocPackageNameEdit.Text:=lisDefaultPlaceholder
|
||||||
|
else
|
||||||
|
FPDocPackageNameEdit.Text:=GetFPDocPkgNameEditValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TProjectFPDocOptionsFrame.PathsListBoxSelectionChange(Sender: TObject; User: boolean);
|
procedure TProjectFPDocOptionsFrame.PathsListBoxSelectionChange(Sender: TObject; User: boolean);
|
||||||
@ -105,6 +109,14 @@ begin
|
|||||||
AddPathButton.Enabled:=(Sender as TEdit).Text <> '';
|
AddPathButton.Enabled:=(Sender as TEdit).Text <> '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TProjectFPDocOptionsFrame.GetFPDocPkgNameEditValue: string;
|
||||||
|
begin
|
||||||
|
if FPDocPackageNameEdit.Text=lisDefaultPlaceholder then
|
||||||
|
Result:=''
|
||||||
|
else
|
||||||
|
Result:=MakeValidFPDocPackageName(FPDocPackageNameEdit.Text);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TProjectFPDocOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
|
procedure TProjectFPDocOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions);
|
||||||
begin
|
begin
|
||||||
with AOptions as TProject do begin
|
with AOptions as TProject do begin
|
||||||
@ -120,10 +132,7 @@ procedure TProjectFPDocOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions)
|
|||||||
begin
|
begin
|
||||||
with AOptions as TProject do begin
|
with AOptions as TProject do begin
|
||||||
FPDocPaths := StringListToText(PathsListBox.Items, ';', True);
|
FPDocPaths := StringListToText(PathsListBox.Items, ';', True);
|
||||||
if FPDocPackageNameEdit.Text=lisDefaultPlaceholder then
|
FPDocPackageName:=GetFPDocPkgNameEditValue;
|
||||||
FPDocPackageName:=''
|
|
||||||
else
|
|
||||||
FPDocPackageName:=FPDocPackageNameEdit.Text;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -657,7 +657,7 @@
|
|||||||
</Target>
|
</Target>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="include"/>
|
<IncludeFiles Value="include"/>
|
||||||
<OtherUnitFiles Value="frames;../converter;../debugger;../debugger/frames;../packager;../designer;../packager/frames"/>
|
<OtherUnitFiles Value="frames;../converter;../debugger;../debugger/frames;../packager;../designer;../packager/frames;frames;../packager/frames"/>
|
||||||
<UnitOutputDirectory Value="$(LazarusDir)/units/$(TargetCPU)-$(TargetOS)"/>
|
<UnitOutputDirectory Value="$(LazarusDir)/units/$(TargetCPU)-$(TargetOS)"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Parsing>
|
<Parsing>
|
||||||
|
@ -7,7 +7,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, Forms, Controls, ExtCtrls, StdCtrls, Dialogs,
|
Classes, SysUtils, FileUtil, Forms, Controls, ExtCtrls, StdCtrls, Dialogs,
|
||||||
IDEOptionsIntf, MacroIntf,
|
IDEOptionsIntf, MacroIntf,
|
||||||
LazarusIDEStrConsts, PackageDefs, PathEditorDlg, IDEProcs;
|
LazarusIDEStrConsts, PackageDefs, PathEditorDlg, IDEProcs, CodeHelp;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -31,6 +31,7 @@ type
|
|||||||
procedure PathEditBtnClick(Sender: TObject);
|
procedure PathEditBtnClick(Sender: TObject);
|
||||||
procedure PathEditBtnExecuted(Sender: TObject);
|
procedure PathEditBtnExecuted(Sender: TObject);
|
||||||
function ShowMsgPackageTypeMustBeDesign: boolean;
|
function ShowMsgPackageTypeMustBeDesign: boolean;
|
||||||
|
function GetFPDocPkgNameEditValue: string;
|
||||||
public
|
public
|
||||||
function Check: Boolean; override;
|
function Check: Boolean; override;
|
||||||
function GetTitle: string; override;
|
function GetTitle: string; override;
|
||||||
@ -72,8 +73,10 @@ end;
|
|||||||
procedure TPackageIntegrationOptionsFrame.FPDocPackageNameEditExit(
|
procedure TPackageIntegrationOptionsFrame.FPDocPackageNameEditExit(
|
||||||
Sender: TObject);
|
Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if FPDocPackageNameEdit.Text='' then
|
if GetFPDocPkgNameEditValue='' then
|
||||||
FPDocPackageNameEdit.Text:=lisDefaultPlaceholder;
|
FPDocPackageNameEdit.Text:=lisDefaultPlaceholder
|
||||||
|
else
|
||||||
|
FPDocPackageNameEdit.Text:=GetFPDocPkgNameEditValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPackageIntegrationOptionsFrame.PathEditBtnClick(Sender: TObject);
|
procedure TPackageIntegrationOptionsFrame.PathEditBtnClick(Sender: TObject);
|
||||||
@ -212,6 +215,14 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TPackageIntegrationOptionsFrame.GetFPDocPkgNameEditValue: string;
|
||||||
|
begin
|
||||||
|
if FPDocPackageNameEdit.Text=lisDefaultPlaceholder then
|
||||||
|
Result:=''
|
||||||
|
else
|
||||||
|
Result:=MakeValidFPDocPackageName(FPDocPackageNameEdit.Text);
|
||||||
|
end;
|
||||||
|
|
||||||
function TPackageIntegrationOptionsFrame.Check: Boolean;
|
function TPackageIntegrationOptionsFrame.Check: Boolean;
|
||||||
var
|
var
|
||||||
NewPkgType: TLazPackageType;
|
NewPkgType: TLazPackageType;
|
||||||
@ -243,10 +254,7 @@ begin
|
|||||||
LazPackage.AutoUpdate := pupAsNeeded;
|
LazPackage.AutoUpdate := pupAsNeeded;
|
||||||
end;
|
end;
|
||||||
LazPackage.FPDocPaths := FPDocSearchPathsEdit.Text;
|
LazPackage.FPDocPaths := FPDocSearchPathsEdit.Text;
|
||||||
if FPDocPackageNameEdit.Text=lisDefaultPlaceholder then
|
LazPackage.FPDocPackageName := GetFPDocPkgNameEditValue;
|
||||||
LazPackage.FPDocPackageName := ''
|
|
||||||
else
|
|
||||||
LazPackage.FPDocPackageName := FPDocPackageNameEdit.Text;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TPackageIntegrationOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
|
class function TPackageIntegrationOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
|
||||||
|
Loading…
Reference in New Issue
Block a user