mirror of https://gitlab.com/basile.b/dexed.git
libman, persists the package list and faster get
This commit is contained in:
parent
160383d26e
commit
be91856958
|
|
@ -15,11 +15,14 @@ type
|
||||||
|
|
||||||
TDubPackageQueryForm = class(TForm)
|
TDubPackageQueryForm = class(TForm)
|
||||||
private
|
private
|
||||||
|
class var fList: TStringList;
|
||||||
cbb: TComboBox;
|
cbb: TComboBox;
|
||||||
function getText: string;
|
function getText: string;
|
||||||
procedure getList(sender: TObject);
|
procedure getList(sender: TObject);
|
||||||
public
|
public
|
||||||
class function showAndWait(out value: string): TModalResult; static;
|
class function showAndWait(out value: string): TModalResult; static;
|
||||||
|
class procedure classCtor;
|
||||||
|
class procedure classDtor;
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
property text: string read getText;
|
property text: string read getText;
|
||||||
end;
|
end;
|
||||||
|
|
@ -177,6 +180,16 @@ begin
|
||||||
itm.Selected := True;
|
itm.Selected := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TDubPackageQueryForm.classCtor;
|
||||||
|
begin
|
||||||
|
fList := TStringList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TDubPackageQueryForm.classDtor;
|
||||||
|
begin
|
||||||
|
fList.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TDubPackageQueryForm.Create(TheOwner: TComponent);
|
constructor TDubPackageQueryForm.Create(TheOwner: TComponent);
|
||||||
var
|
var
|
||||||
bok: TBitBtn;
|
bok: TBitBtn;
|
||||||
|
|
@ -196,6 +209,7 @@ begin
|
||||||
cbb.AutoComplete := true;
|
cbb.AutoComplete := true;
|
||||||
cbb.Align := alClient;
|
cbb.Align := alClient;
|
||||||
cbb.BorderSpacing.Around := 6;
|
cbb.BorderSpacing.Around := 6;
|
||||||
|
cbb.Items.AddStrings(fList);
|
||||||
cbb.Sorted:= true;
|
cbb.Sorted:= true;
|
||||||
|
|
||||||
bww := TBitBtn.Create(self);
|
bww := TBitBtn.Create(self);
|
||||||
|
|
@ -240,28 +254,26 @@ var
|
||||||
pge: string;
|
pge: string;
|
||||||
cli: TFPHTTPClient;
|
cli: TFPHTTPClient;
|
||||||
begin
|
begin
|
||||||
cbb.Items.Clear;
|
fList.Clear;
|
||||||
cli := TFPHTTPClient.Create(nil);
|
cli := TFPHTTPClient.Create(nil);
|
||||||
try
|
try
|
||||||
try
|
try
|
||||||
pge := cli.Get('https://code.dlang.org/');
|
pge := cli.Get('https://code.dlang.org/packages/index.json');
|
||||||
except
|
except
|
||||||
pge := '';
|
pge := '';
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
cli.Free;
|
cli.Free;
|
||||||
end;
|
end;
|
||||||
// note, also works with regex \"packages\/[a-zA-Z0-9_-]+\"
|
|
||||||
with TStringRange.create(pge) do while not empty do
|
with TStringRange.create(pge) do while not empty do
|
||||||
begin
|
begin
|
||||||
if popUntil('"')^.startsWith('"packages/') then
|
popUntil('"');
|
||||||
begin
|
popFront;
|
||||||
popUntil('/')^.popFront;
|
fList.Add(takeUntil('"').yield);
|
||||||
cbb.Items.Add(takeUntil('"').yield);
|
popFront;
|
||||||
popUntil('"')^.popFront;
|
|
||||||
end
|
|
||||||
else popFront;
|
|
||||||
end;
|
end;
|
||||||
|
cbb.Items.clear;
|
||||||
|
cbb.Items.AddStrings(fList);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDubPackageQueryForm.getText: string;
|
function TDubPackageQueryForm.getText: string;
|
||||||
|
|
@ -785,4 +797,8 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
TDubPackageQueryForm.classCtor;
|
||||||
|
finalization
|
||||||
|
TDubPackageQueryForm.classDtor;
|
||||||
end.
|
end.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue