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 ord("O"): begin if ssCtrl in e.shiftstate() then begin e.skip := true; openthefile(); end end 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=(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