mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 15:19:22 +02:00
IDE: Reuse function SplitString from IDEProcs in PathEditorDialog. Replaces function PathToText.
git-svn-id: trunk@56839 -
This commit is contained in:
parent
bed7ec4fc7
commit
44e254517a
@ -1659,6 +1659,12 @@ begin
|
|||||||
//DebugLn('TabsToSpaces ',dbgs(length(Result)));
|
//DebugLn('TabsToSpaces ',dbgs(length(Result)));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SplitString(const s: string; Delimiter: char): TStrings;
|
||||||
|
begin
|
||||||
|
Result:=TStringList.Create;
|
||||||
|
SplitString(s,Delimiter,Result,false);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure SplitString(const s: string; Delimiter: char; AddTo: TStrings;
|
procedure SplitString(const s: string; Delimiter: char; AddTo: TStrings;
|
||||||
ClearList: boolean);
|
ClearList: boolean);
|
||||||
var
|
var
|
||||||
@ -1666,7 +1672,8 @@ var
|
|||||||
StartPos: Integer;
|
StartPos: Integer;
|
||||||
EndPos: Integer;
|
EndPos: Integer;
|
||||||
begin
|
begin
|
||||||
if ClearList then AddTo.Clear;
|
if ClearList then
|
||||||
|
AddTo.Clear;
|
||||||
SLen:=length(s);
|
SLen:=length(s);
|
||||||
StartPos:=1;
|
StartPos:=1;
|
||||||
EndPos:=1;
|
EndPos:=1;
|
||||||
@ -1986,15 +1993,6 @@ begin
|
|||||||
RaiseException('ERROR: BinaryStrToText: '+IntToStr(NewLen)+'<>'+IntToStr(NewPos-1));
|
RaiseException('ERROR: BinaryStrToText: '+IntToStr(NewLen)+'<>'+IntToStr(NewPos-1));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
|
||||||
function SplitString(const s: string; Delimiter: char): TStrings;
|
|
||||||
-------------------------------------------------------------------------------}
|
|
||||||
function SplitString(const s: string; Delimiter: char): TStrings;
|
|
||||||
begin
|
|
||||||
Result:=TStringList.Create;
|
|
||||||
SplitString(s,Delimiter,Result,false);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
ConvertSpecialFileChars
|
ConvertSpecialFileChars
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ uses
|
|||||||
// IdeIntf
|
// IdeIntf
|
||||||
MacroIntf, IDEImagesIntf,
|
MacroIntf, IDEImagesIntf,
|
||||||
// IDE
|
// IDE
|
||||||
TransferMacros, GenericListSelect, LazarusIDEStrConsts;
|
TransferMacros, GenericListSelect, LazarusIDEStrConsts, IDEProcs;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ type
|
|||||||
FTemplateList: TStringList;
|
FTemplateList: TStringList;
|
||||||
procedure AddPath(aPath: String; aObject: TObject);
|
procedure AddPath(aPath: String; aObject: TObject);
|
||||||
function GetPath: string;
|
function GetPath: string;
|
||||||
function GetTemplates: string;
|
//function GetTemplates: string;
|
||||||
function BaseRelative(const APath: string): String;
|
function BaseRelative(const APath: string): String;
|
||||||
function PathAsAbsolute(const APath: string): String;
|
function PathAsAbsolute(const APath: string): String;
|
||||||
function PathMayExist(APath: string): TObject;
|
function PathMayExist(APath: string): TObject;
|
||||||
@ -103,7 +103,7 @@ type
|
|||||||
property BaseDirectory: string read FBaseDirectory write SetBaseDirectory;
|
property BaseDirectory: string read FBaseDirectory write SetBaseDirectory;
|
||||||
property EffectiveBaseDirectory: string read FEffectiveBaseDirectory;
|
property EffectiveBaseDirectory: string read FEffectiveBaseDirectory;
|
||||||
property Path: string read GetPath write SetPath;
|
property Path: string read GetPath write SetPath;
|
||||||
property Templates: string read GetTemplates write SetTemplates;
|
property Templates: string {read GetTemplates} write SetTemplates;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TOnPathEditorExecuted = function (Context: String; var NewPath: String): Boolean of object;
|
TOnPathEditorExecuted = function (Context: String; var NewPath: String): Boolean of object;
|
||||||
@ -189,23 +189,17 @@ begin
|
|||||||
SetLength(Result,j-1);
|
SetLength(Result,j-1);
|
||||||
end;
|
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);
|
procedure SetPathTextAndHint(aPath: String; aEdit: TCustomEdit);
|
||||||
|
var
|
||||||
|
sl: TStrings;
|
||||||
begin
|
begin
|
||||||
aEdit.Text := aPath;
|
aEdit.Text := aPath;
|
||||||
if Pos(';', aPath) > 0 then // Zero or one separate paths.
|
if Pos(';', aPath) > 0 then
|
||||||
aEdit.Hint := PathToText(aPath)
|
begin
|
||||||
|
sl := SplitString(aPath, ';');
|
||||||
|
aEdit.Hint := sl.Text;
|
||||||
|
sl.Free;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
aEdit.Hint := lisDelimiterIsSemicolon;
|
aEdit.Hint := lisDelimiterIsSemicolon;
|
||||||
end;
|
end;
|
||||||
@ -258,12 +252,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPathEditorDialog.ReplaceButtonClick(Sender: TObject);
|
procedure TPathEditorDialog.ReplaceButtonClick(Sender: TObject);
|
||||||
var
|
|
||||||
RelPath: String;
|
|
||||||
begin
|
begin
|
||||||
with PathListBox do begin
|
with PathListBox do begin
|
||||||
RelPath:=BaseRelative(DirectoryEdit.Text);
|
Items[ItemIndex]:=BaseRelative(DirectoryEdit.Text);
|
||||||
Items[ItemIndex]:=RelPath;
|
|
||||||
Items.Objects[ItemIndex]:=PathMayExist(DirectoryEdit.Text);
|
Items.Objects[ItemIndex]:=PathMayExist(DirectoryEdit.Text);
|
||||||
UpdateButtons;
|
UpdateButtons;
|
||||||
end;
|
end;
|
||||||
@ -539,19 +530,19 @@ end;
|
|||||||
|
|
||||||
function TPathEditorDialog.GetPath: string;
|
function TPathEditorDialog.GetPath: string;
|
||||||
begin
|
begin
|
||||||
|
// ToDo: Join PathListBox.Items directly without Text property.
|
||||||
Result:=TextToPath(PathListBox.Items.Text);
|
Result:=TextToPath(PathListBox.Items.Text);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPathEditorDialog.SetPath(const AValue: string);
|
procedure TPathEditorDialog.SetPath(const AValue: string);
|
||||||
var
|
var
|
||||||
sl: TStringList;
|
sl: TStrings;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
DirectoryEdit.Text:='';
|
DirectoryEdit.Text:='';
|
||||||
PathListBox.Items.Clear;
|
PathListBox.Items.Clear;
|
||||||
sl:=TstringList.Create();
|
sl := SplitString(AValue, ';');
|
||||||
try
|
try
|
||||||
sl.Text:=PathToText(AValue);
|
|
||||||
for i:=0 to sl.Count-1 do
|
for i:=0 to sl.Count-1 do
|
||||||
PathListBox.Items.AddObject(sl[i], PathMayExist(sl[i]));
|
PathListBox.Items.AddObject(sl[i], PathMayExist(sl[i]));
|
||||||
PathListBox.ItemIndex:=-1;
|
PathListBox.ItemIndex:=-1;
|
||||||
@ -559,17 +550,16 @@ begin
|
|||||||
sl.Free;
|
sl.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
{
|
||||||
function TPathEditorDialog.GetTemplates: string;
|
function TPathEditorDialog.GetTemplates: string;
|
||||||
begin
|
begin
|
||||||
raise Exception.Create('TPathEditorDialog.GetTemplates is called.');
|
raise Exception.Create('TPathEditorDialog.GetTemplates is called.');
|
||||||
//Result := TextToPath(FTemplateList.Text);
|
//Result := TextToPath(FTemplateList.Text);
|
||||||
end;
|
end;
|
||||||
|
}
|
||||||
procedure TPathEditorDialog.SetTemplates(const AValue: string);
|
procedure TPathEditorDialog.SetTemplates(const AValue: string);
|
||||||
begin
|
begin
|
||||||
// ToDo: Split the path directly to StringList without Text property.
|
SplitString(GetForcedPathDelims(AValue), ';', FTemplateList, True);
|
||||||
FTemplateList.Text := PathToText(GetForcedPathDelims(AValue));
|
|
||||||
AddTemplateButton.Enabled := FTemplateList.Count > 0;
|
AddTemplateButton.Enabled := FTemplateList.Count > 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user