IDE: Let TPathEditorButton show the list of paths in edit control's hint.

git-svn-id: trunk@47493 -
This commit is contained in:
juha 2015-01-22 23:03:38 +00:00
parent a1e71674d9
commit 034ede2f68
5 changed files with 117 additions and 110 deletions

View File

@ -512,7 +512,6 @@ begin
OnExecuted := @PathEditBtnExecuted;
end;
OtherUnitsEdit.AnchorToNeighbour(akRight, 0, OtherUnitsPathEditBtn);
OtherUnitsEdit.Hint := lisDelimiterIsSemicolon;
{------------------------------------------------------------}
@ -536,7 +535,6 @@ begin
OnExecuted := @PathEditBtnExecuted;
end;
IncludeFilesEdit.AnchorToNeighbour(akRight, 0, IncludeFilesPathEditBtn);
IncludeFilesEdit.Hint := lisDelimiterIsSemicolon;
{------------------------------------------------------------}
@ -563,7 +561,6 @@ begin
OnExecuted := @PathEditBtnExecuted;
end;
OtherSourcesEdit.AnchorToNeighbour(akRight, 0, OtherSourcesPathEditBtn);
OtherSourcesEdit.Hint := lisDelimiterIsSemicolon;
{------------------------------------------------------------}
@ -587,7 +584,6 @@ begin
OnExecuted := @PathEditBtnExecuted;
end;
LibrariesEdit.AnchorToNeighbour(akRight, 0, LibrariesPathEditBtn);
LibrariesEdit.Hint := lisDelimiterIsSemicolon;
{------------------------------------------------------------}
@ -607,9 +603,6 @@ begin
OnClick := @FileBrowseBtnClick;
end;
UnitOutputDirEdit.AnchorToNeighbour(akRight, 0, btnUnitOutputDir);
UnitOutputDirEdit.Hint := lisDelimiterIsSemicolon;
ProjTargetFileEdit.Hint := lisDelimiterIsSemicolon;
{------------------------------------------------------------}
@ -635,7 +628,6 @@ begin
OnExecuted := @PathEditBtnExecuted;
end;
DebugPathEdit.AnchorToNeighbour(akRight, 0, DebugPathEditBtn);
DebugPathEdit.Hint := lisDelimiterIsSemicolon;
{------------------------------------------------------------}
@ -694,12 +686,12 @@ begin
ProjTargetApplyConventionsCheckBox.Visible:=false;
end;
OtherUnitsEdit.Text := FCompilerOpts.OtherUnitFiles;
IncludeFilesEdit.Text := FCompilerOpts.IncludePath;
LibrariesEdit.Text := FCompilerOpts.Libraries;
OtherSourcesEdit.Text := FCompilerOpts.SrcPath;
SetPathTextAndHint(FCompilerOpts.OtherUnitFiles, OtherUnitsEdit);
SetPathTextAndHint(FCompilerOpts.IncludePath, IncludeFilesEdit);
SetPathTextAndHint(FCompilerOpts.Libraries, LibrariesEdit);
SetPathTextAndHint(FCompilerOpts.SrcPath, OtherSourcesEdit);
UnitOutputDirEdit.Text := FCompilerOpts.UnitOutputDirectory;
DebugPathEdit.Text := FCompilerOpts.DebugPath;
SetPathTextAndHint(FCompilerOpts.DebugPath, DebugPathEdit);
chkUseAsDefault.Visible := FCompilerOpts.CanBeDefaulForProject;
end;

View File

@ -82,7 +82,6 @@ type
FEffectiveBaseDirectory: string;
function GetPath: string;
function GetTemplates: string;
function PathToText(const APath: string): string;
function BaseRelative(const APath: string): String;
function PathAsAbsolute(const APath: string): String;
function PathMayExist(APath: string): TObject;
@ -90,7 +89,6 @@ type
procedure SetBaseDirectory(const AValue: string);
procedure SetPath(const AValue: string);
procedure SetTemplates(const AValue: string);
function TextToPath(const AText: string): string;
procedure UpdateButtons;
procedure WriteHelper(Paths: TStringList);
public
@ -123,6 +121,7 @@ type
end;
function PathEditorDialog: TPathEditorDialog;
procedure SetPathTextAndHint(aPath: String; aEdit: TCustomEdit);
implementation
@ -138,6 +137,71 @@ begin
Result:=PathEditor;
end;
function TextToPath(const AText: string): string;
var
i, j: integer;
begin
Result:=AText;
// convert all line ends to semicolons, remove empty paths and trailing spaces
i:=1;
j:=1;
while i<=length(AText) do begin
if AText[i] in [#10,#13] then begin
// new line -> new path
inc(i);
if (i<=length(AText)) and (AText[i] in [#10,#13])
and (AText[i]<>AText[i-1]) then
inc(i);
// skip spaces at end of path
while (j>1) and (Result[j-1]=' ') do
dec(j);
// skip empty paths
if (j=1) or (Result[j-1]<>';') then begin
Result[j]:=';';
inc(j);
end;
end else if ord(AText[i])<32 then begin
// skip trailing spaces
inc(i)
end else if AText[i]=' ' then begin
// space -> skip spaces at beginning of path
if (j>1) and (Result[j-1]<>';') then begin
Result[j]:=AText[i];
inc(j);
end;
inc(i);
end else begin
// path char -> just copy
Result[j]:=AText[i];
inc(j);
inc(i);
end;
end;
if (j>1) and (Result[j-1]=';') then dec(j);
SetLength(Result,j-1);
end;
function PathToText(const APath: string): string;
var
i: integer;
begin
Result:='';
for i:=1 to length(APath) do
if APath[i]=';' then
Result:=Result+LineEnding
else
Result:=Result+APath[i];
end;
procedure SetPathTextAndHint(aPath: String; aEdit: TCustomEdit);
begin
aEdit.Text := aPath;
if Pos(';', aPath) > 0 then // Zero or one separate paths.
aEdit.Hint := PathToText(aPath)
else
aEdit.Hint := lisDelimiterIsSemicolon;
end;
{ TPathEditorDialog }
function TPathEditorDialog.BaseRelative(const APath: string): String;
@ -494,64 +558,6 @@ begin
TemplateGroupBox.Visible:=TemplatesListBox.Count>0;
end;
function TPathEditorDialog.TextToPath(const AText: string): string;
var
i, j: integer;
PathAsText: string;
begin
PathAsText:=AText;
Result:=PathAsText;
// convert all line ends to semicolons, remove empty paths and trailing spaces
i:=1;
j:=1;
while i<=length(PathAsText) do begin
if PathAsText[i] in [#10,#13] then begin
// new line -> new path
inc(i);
if (i<=length(PathAsText)) and (PathAsText[i] in [#10,#13])
and (PathAsText[i]<>PathAsText[i-1]) then
inc(i);
// skip spaces at end of path
while (j>1) and (Result[j-1]=' ') do
dec(j);
// skip empty paths
if (j=1) or (Result[j-1]<>';') then begin
Result[j]:=';';
inc(j);
end;
end else if ord(PathAsText[i])<32 then begin
// skip trailing spaces
inc(i)
end else if PathAsText[i]=' ' then begin
// space -> skip spaces at beginning of path
if (j>1) and (Result[j-1]<>';') then begin
Result[j]:=PathAsText[i];
inc(j);
end;
inc(i);
end else begin
// path char -> just copy
Result[j]:=PathAsText[i];
inc(j);
inc(i);
end;
end;
if (j>1) and (Result[j-1]=';') then dec(j);
SetLength(Result,j-1);
end;
function TPathEditorDialog.PathToText(const APath: string): string;
var
i: integer;
NewPath: string;
begin
NewPath:=APath;
for i:=1 to length(NewPath) do
if NewPath[i]=';' then
NewPath[i]:=#13;
Result:=NewPath;
end;
procedure TPathEditorDialog.UpdateButtons;
var
i: integer;
@ -614,7 +620,7 @@ begin
Ok := OnExecuted(ContextCaption, NewPath);
// Assign value only if old <> new and OnExecuted allows it.
if Ok then
AssociatedEdit.Text := NewPath;
SetPathTextAndHint(NewPath, AssociatedEdit);
end;
end.

View File

@ -168,7 +168,8 @@ begin
FPDocPackageNameLabel.Caption := lisPckPackage;
FPDocPackageNameEdit.Hint := lisPckClearToUseThePackageName;
FPDocSearchPathsLabel.Caption := lisPathEditSearchPaths;
FPDocSearchPathsEdit.Hint := lisPckSearchPathsForFpdocXmlFilesMultiplePathsMustBeSepa;
// ToDo: remove the resource string later.
//FPDocSearchPathsEdit.Hint := lisPckSearchPathsForFpdocXmlFilesMultiplePathsMustBeSepa;
FPDocPathButton := TPathEditorButton.Create(Self);
with FPDocPathButton do
@ -198,7 +199,7 @@ begin
else
UpdateRadioGroup.ItemIndex := 2;
end;
FPDocSearchPathsEdit.Text:=FLazPackage.FPDocPaths;
SetPathTextAndHint(FLazPackage.FPDocPaths, FPDocSearchPathsEdit);
if FLazPackage.FPDocPackageName='' then
FPDocPackageNameEdit.Text:=lisDefaultPlaceholder
else

View File

@ -14,13 +14,13 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 147
Height = 133
Top = 0
Width = 535
Anchors = [akTop, akLeft, akRight]
AutoSize = True
Caption = 'Add paths to dependent packages/projects'
ClientHeight = 130
ClientHeight = 114
ClientWidth = 531
TabOrder = 0
object UnitPathLabel: TLabel
@ -29,8 +29,8 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 11
Width = 23
Top = 9
Width = 26
BorderSpacing.Left = 6
Caption = 'Unit'
ParentColor = False
@ -41,8 +41,8 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 42
Width = 40
Top = 36
Width = 45
BorderSpacing.Left = 6
Caption = 'Include'
ParentColor = False
@ -53,8 +53,8 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 73
Width = 37
Top = 63
Width = 41
BorderSpacing.Left = 6
Caption = 'Object'
ParentColor = False
@ -65,8 +65,8 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 104
Width = 39
Top = 90
Width = 43
BorderSpacing.Left = 6
Caption = 'Library'
ParentColor = False
@ -77,12 +77,14 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideRight.Control = AddPathsGroupBox
AnchorSideRight.Side = asrBottom
Left = 80
Height = 25
Height = 21
Top = 6
Width = 401
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 50
ParentShowHint = False
ShowHint = True
TabOrder = 0
end
object IncludePathEdit: TEdit
@ -92,12 +94,14 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideRight.Control = AddPathsGroupBox
AnchorSideRight.Side = asrBottom
Left = 80
Height = 25
Top = 37
Height = 21
Top = 33
Width = 401
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 50
ParentShowHint = False
ShowHint = True
TabOrder = 1
end
object ObjectPathEdit: TEdit
@ -107,12 +111,14 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideRight.Control = AddPathsGroupBox
AnchorSideRight.Side = asrBottom
Left = 80
Height = 25
Top = 68
Height = 21
Top = 60
Width = 401
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 50
ParentShowHint = False
ShowHint = True
TabOrder = 2
end
object LibraryPathEdit: TEdit
@ -122,14 +128,16 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideRight.Control = AddPathsGroupBox
AnchorSideRight.Side = asrBottom
Left = 80
Height = 25
Top = 99
Height = 21
Top = 87
Width = 401
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 80
BorderSpacing.Top = 6
BorderSpacing.Right = 50
BorderSpacing.Bottom = 6
ParentShowHint = False
ShowHint = True
TabOrder = 3
end
end
@ -141,12 +149,12 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideRight.Side = asrBottom
Left = 0
Height = 171
Top = 153
Top = 139
Width = 535
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
Caption = 'Add options to dependent packages and projects'
ClientHeight = 154
ClientHeight = 152
ClientWidth = 531
TabOrder = 1
object LinkerOptionsLabel: TLabel
@ -155,7 +163,7 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
Left = 6
Height = 15
Top = 6
Width = 34
Width = 38
BorderSpacing.Left = 6
Caption = 'Linker'
ParentColor = False
@ -166,7 +174,7 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
Left = 6
Height = 15
Top = 74
Width = 41
Width = 46
BorderSpacing.Left = 6
Caption = 'Custom'
ParentColor = False
@ -176,10 +184,10 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideTop.Control = AddOptionsGroupBox
AnchorSideRight.Control = AddOptionsGroupBox
AnchorSideRight.Side = asrBottom
Left = 57
Left = 62
Height = 62
Top = 6
Width = 468
Width = 463
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 6
@ -195,10 +203,10 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = AddOptionsGroupBox
AnchorSideBottom.Side = asrBottom
Left = 57
Height = 74
Left = 62
Height = 72
Top = 74
Width = 468
Width = 463
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 10
BorderSpacing.Top = 6
@ -215,19 +223,19 @@ object PackageUsageOptionsFrame: TPackageUsageOptionsFrame
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 53
Top = 330
Height = 57
Top = 316
Width = 535
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 6
Caption = 'ProjectGroupBox'
ClientHeight = 36
ClientHeight = 38
ClientWidth = 531
TabOrder = 2
object AddPackageUnitToProjectCheckBox: TCheckBox
Left = 6
Height = 24
Height = 20
Top = 6
Width = 519
Align = alTop

View File

@ -184,10 +184,10 @@ begin
FLazPackage := (AOptions as TPackageIDEOptions).Package;
with FLazPackage.UsageOptions do
begin
UnitPathEdit.Text := UnitPath;
IncludePathEdit.Text := IncludePath;
ObjectPathEdit.Text := ObjectPath;
LibraryPathEdit.Text := LibraryPath;
SetPathTextAndHint(UnitPath, UnitPathEdit);
SetPathTextAndHint(IncludePath, IncludePathEdit);
SetPathTextAndHint(ObjectPath, ObjectPathEdit);
SetPathTextAndHint(LibraryPath, LibraryPathEdit);
LinkerOptionsMemo.Text := LinkerOptions;
CustomOptionsMemo.Text := CustomOptions;
end;