tslediter/designer/ctl_mgr/t_function_finder.tsf

151 lines
3.9 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

type t_function_finder=class(tdcreateform)
uses tslvcl;
findpal:tpanel;
edfind:tedit;
btfind:tbtn;
listfunc:tlistview;
popupmenu1:tpopupmenu;
mufind:tmenu;
sbfind:tstatusbar;
ck_prev:tcheckbtn;
function Create(AOwner);override; //¹¹Ôì
begin
fformatdata := array();
inherited;
ActiveControl := edfind;
p := AOwner;
parent := p;
d := p.GetFreeSynObjectByName("tsl");
if d then ffcomp := d[1];
end
function listfunc_ondblclick(o;e);
begin
openthefile();
end
function functionfinder_close(o;e);
begin
e.skip := true;
o.Visible := false;
end
function mufind_clk(o;e); //´ò¿ªÎļþ¼Ð
begin
openthefile();
//echo dak
end
function openthefile();
begin
d := listfunc.SelectedValue;
if not d then return ;
f := ffcomp.GetFileFullPath(d[1]);
Owner.OpenAndGotoFileByName(f,d[3]);
Visible := false;
end
function show_finder();
begin
if Visible then return ;
if ffcomp then setdata(ffcomp.getjumpinfo());
show();
end
function btfind_clk(o;e);
begin
dofind();
end
function edfind_keydown(o;e);
begin
ec := e.charcode;
case ec of
13:
begin
return dofind();
end
VK_UP:
begin
sid := listfunc.SelectedId;
if sid>0 then listfunc.SelectedId := sid-1;
else return ;
end
VK_DOWN:
begin
sid := listfunc.SelectedId;
if sid<listfunc.ItemCount-1 then listfunc.SelectedId := sid+1;
else return ;
end
end ;
n := listfunc.Height/listfunc.ItemHeight;
idx := listfunc.SelectedId ;
tidx := listfunc.topline;
if idx<tidx or idx>=(n+tidx-3) then
begin
listfunc.topline := integer(idx-(n/2)-3);
end
end
function dofind();
begin
s := lowercase(trim(edfind.text));
if not s then return setlists(fformatdata);
r := array();
cp := ck_prev.Checked;
for i,v in fformatdata do
begin
if cp then
begin
if 1=pos(s,v[2]) then r[idx++]:= v;
end else
begin
if pos(s,v[2]) then r[idx++]:= v;
end
end
setlists(r);
end
function setdata(d);
begin
if ifarray(d) and (ffuncdata<>d) then //ÉèÖÃÊý¾Ý
begin
ffuncdata := d;
formatdata(d);
setlists(fformatdata);
end
end
function setlists(d);
begin
if fcurrentdata=d then return ;
listfunc.DeleteAllItems();
listfunc.AppendItems(d);
fcurrentdata := d;
listfunc.SelectedId := 0;
sbfind.SetItemText(("×ܹ²£º"$length(d)$" ´¦"),0);
end
function Recycling();override; //»ØÊÕ±äÁ¿
begin
inherited;
ci := self.classinfo(); //½«³ÉÔ±±äÁ¿¸³ÖµÎªnil±ÜÃâÑ­»·ÒýÓÃ
for i,v in ci["members"] do
begin
if v["const"] then continue;
if v["static"] then continue;
invoke(self,v["name"],nil);
end
end
private
function formatdata(d);
begin
fformatdata := array();
idx := 0;
for i,v in d do
begin
if not ifarray(d) then continue;
if not v["file"] then continue;
fformatdata[idx,0] := v["caption"];
fformatdata[idx,1] := v["file"];
fformatdata[idx,2] := v["lvalue"];
fformatdata[idx,3] := v["line"];
idx++;
end
end
[weakref]ffcomp;
fformatdata;
ffuncdata;
fcurrentdata;
end