diff --git a/designer/tediterform.tsf b/designer/tediterform.tsf index f4e5780..75b9c4c 100644 --- a/designer/tediterform.tsf +++ b/designer/tediterform.tsf @@ -65,6 +65,7 @@ type TEditerForm = class(TVCform) // Fremotepath := basepath+"editer"+sp; CreateDirWithFileName(basepath+"editer"+sp+"1.txt"); CreateDirWithFileName(basepath+"editer"+sp+"cmpCaches"+sp+"1.txt"); + fdirspath := basepath+"editer"+sp+"tsldirpath.tsm"; //TBlockManager //echo "\r\n",FCache; //////////////////////////////////////// @@ -80,7 +81,17 @@ type TEditerForm = class(TVCform) // fmglobsearch.OnClick := function(o,e) begin FEDter.SwitchLogWnd(); - end + end + fmglobdir := new TMenu(self); + fmglobdir.caption := "目录"; + fmglobdir.onclick := function(o,e) + begin + v := not(Fdirview.Visible); + Fdirview.Visible := v; + fdirspliter.Visible := v; + + end + /////////////////////////////////////////////////////// FEnCodeMenu := new TMenu(self); FEnCodeMenu.Caption := "编码"; @@ -242,6 +253,7 @@ type TEditerForm = class(TVCform) // FEnCodeMenu.parent := m; fmglobsearch.parent := FmTool; + fmglobdir.parent := FmTool; FSearchDir := new TSearchDir(self); FSearchDir.onsaveclick := function(o,e)begin return o.EndModal(1); @@ -262,6 +274,21 @@ type TEditerForm = class(TVCform) // FCloseMenu.Checked := not(FCloseMenu.Checked); end FEdter := New TEditer(self); + + Fdirview := new tdirviewer(FEdter); + Fdirview.fcbtn.OnClick := function(o,e)begin + Fdirview.Visible := false; + fdirspliter.Visible := false; + end + Fdirview.Visible := false; + Fdirview.align := alLeft; + fdirspliter := new tsplitter(self); + fdirspliter.Visible := false; + fdirspliter.align := alLeft; + Fdirview.Parent := self; + fdirspliter.Parent := self; + + FEdter.Visible := false; //语言按钮 @@ -322,6 +349,11 @@ type TEditerForm = class(TVCform) // FEdter.OnPageEditerChanged := thisfunction(PageEditerChanged); FEdter.TslExe := tslexefile; FEdter.align := alClient; + + if importfile(ftstream(),"",fdirspath,dirs)=1 then + begin + Fdirview.addrootdirs(dirs); + end FEdter.FHistoryDir:= Fremotepath; if importfile(ftstream(),"",FPathDirPath,dirs)=1 then begin @@ -568,7 +600,11 @@ type TEditerForm = class(TVCform) // break; end end - + d := Fdirview.getrootdirs(); + if d and ifarray(d) then + begin + exportfile(ftstream(),"",fdirspath,d); + end d := FEdter.FExecuteEditer.GetData(); if d and ifarray(d) then begin @@ -1490,6 +1526,8 @@ BD141CA912494F502D48D224F45050274A21E03806FF2C7CA7516022D7D000000 return ico; end private + Fdirview; + fdirspliter; FLoger; FFormatInfoWnd; fBlockManager; @@ -1507,6 +1545,7 @@ end FFindhistroypath; FFormatpath; Fremotepath; + fdirspath; Fhighlightpath; FEdter; FSearchDir; @@ -1518,3 +1557,525 @@ end FExeaction; end + +type tdirviewer = class(tcustomcontrol) + uses tslvcl; + function create(AOwner); + begin + inherited; + fnodes := array(); + FEdit := new tedit(self); + imglst := new tcontrolimagelist(self); + bmp := new TBitmap(); + bmp.readvcon(HexFormatStrToTsl(folderbmp())); + imglst.addbmp(bmp); + bmp.readvcon(HexFormatStrToTsl(filebmp())); + imglst.addbmp(bmp); + bmp.readvcon(HexFormatStrToTsl(dllbmp())); + imglst.addbmp(bmp); + bmp.readvcon(HexFormatStrToTsl(searchbmp())); + + Width := 300; + FTree := new TTreeView(self); + FTree.Align := alClient; + FTree.parent := self; + ftree.ImageList := imglst; + FRootdirs := array(); + FTree.onEmptyNodeExapanding:= thisfunction(emptyexpanding); + Fnodeinfos := array(); + fdircrc := array(); + FEdit.parent := self; + FEdit.onkeyup := function(o,e)begin + if e.CharCode=13 then + begin + e.skip := true; + dofind(); + end + end + fcbtn := new tbtn(self); + fcbtn.caption := ""; + fcbtn.Parent := self; + fbtn := new tbtn(self); + fbtn.caption := ""; + fbtn.BKBitmap := bmp; + fbtn.parent := self; + fbtn.onclick := thisfunction(dofind); + mus := new TPopupmenu(self); + fms := array(); + for i,v in array("添加工作目录","移除工作目录","刷新","打开") do + begin + mi := new TMenu(self); + mi.caption := v; + mi.onclick := thisfunction(muclick); + mi.parent := mus; + fms[i] := mi; + end + ftree.onrclick :=function(o,e)begin + nd := o.CurrentNode; + if nd then + begin + if (nd.parent = o.rootnode) then //根目录 + begin + fms[0].Enabled := 0; + fms[1].Enabled := true; + fms[2].Enabled := true; + fms[3].Enabled := true; + end else + begin + fms[0].Enabled := 0; + fms[1].Enabled := 0; + fms[2].Enabled := true; + fms[3].Enabled := true; + end + end else + begin + fms[0].Enabled := true; + fms[1].Enabled := 0; + fms[2].Enabled := true; + fms[3].Enabled := 0; + end + end + FTree.PopupMenu := mus; + s := "0502000000060400000074797065000203000000696D670006040000006461746 +100023F01000089504E470D0A1A0A0000000D4948445200000012000000120806 +00000056CE8E57000000017352474200AECE1CE90000000467414D410000B18F0 +BFC6105000000097048597300000EC300000EC301C76FA864000000D449444154 +384F63F84F2530920CFAB465CDFF4FDBD6417998E0757F3394850AB01A745395E +FFF9783BBA12208F0BC22EBFFD3CC48280F1560F5DAE7EDEBFFDF3696FDFFFDEC +71A8087E43400067187D39B0EBFF3D47DDFF3FAE5F26680808E00DEC6FE74EFE7 +FE06F4BD01010C06B10C8250FFCACFFDF54E1FDFF79F716A8287680D32090218F +22DCC0EC4F5BD7FEBFA527F1FFDBF183603E3680D52090218F9302A13C08F87AE +CC0FFBB16CAFFBF5F3C031541051806BD01A6135C61F2FDC2E9FFF79CF4A03C54 +80378C4801A3061102FFFF03001C3CE074AD27DED70000000049454E44AE42608 +200"; + bmp := new TBitmap(); + bmp.readvcon(HexFormatStrToTsl(s)); + fcbtn.BKBitmap := bmp; + end + fcbtn; + fms; + ffolder; + function muclick(o,e); + begin + case o.caption of + "添加工作目录": + begin + if not ffolder then ffolder := new TFolderChooseADlg(self); + if ffolder.OpenDlg() then + begin + return addrootdir(ffolder.Folder); + end + end + "移除工作目录": + begin + nd := FTree.CurrentNode; + delrootdir(nd); + end + "刷新": + begin + refreshdir(); + end + "打开": + begin + nd := ftree.CurrentNode; + if not nd then return ; + ins := Fnodeinfos[nd.handle]; + ed := Owner; + if ins then + begin + if ins.isfile then + begin + Owner.OpenAndGotoFileByName(ins.fullname); + end else + _wapi.openresourcemanager(ins.fullname); + end + end + end ; + end + function dofind(o,e); + begin + s := lowercase(trim(FEdit.text)); + if not s then return ; + it := ftree.CurrentNode; + getallnodes(); + return finds(it,s); + end + function finds(it,s) + begin + bit := it; + flag := false; + ct := length(fnodes); + firstx := 0; + for i,v in fnodes do + begin + if v=it then + begin + firstx := i+1; + break; + end + end + for i := 0 to ct -1 do + begin + idx := (firstx+i) mod ct; + it := fnodes[idx]; + if pos(s,lowercase(it.caption)) then + begin + FTree.SetSel(it); + return 1; + end + end + return 0; + end + function doControlALign();override; + begin + if FEdit and FTree and fbtn and fcbtn then + begin + rc := ClientRect; + rc1 := array(rc[0]+20,rc[1],rc[2]-30,rc[0]+24); + rc3 := array(rc[2]-26,rc[1],rc[2]-2,rc[0]+24); + rc4 := array(rc[0]+1,rc[1]+2,rc[0]+19,rc[1]+20); + rc2 := array(rc[0],rc[1]+25,rc[2],rc[3]); + FEdit.SetBoundsRect(rc1); + FTree.SetBoundsRect(rc2); + fbtn.SetBoundsRect(rc3); + fcbtn.SetBoundsRect(rc4); + end + end + function loadall(nd,ct,mct); + begin + if not nd then + begin + nd := FTree.rootnode; + end + if nd.ItemCount<1 and nd.dirtype then lazyload(nd,0); + ct+= nd.ItemCount; + for i:= 0 to nd.ItemCount-1 do + begin + if ct>=mct then return ; + loadall(nd.GetNodeByIndex(i),ct,mct); + end + end + function countfile(dir,n,ct); + begin + n++; + if ct<=n then return ; + iof := static iofileseparator(); + fs := filelist("",dir); + if not fs then return n; + for i,v in filelist("",dir+iof+"*") do + begin + fn := v["FileName"]; + if pos("H",v["Attr"]) then continue; + if fn="." or fn=".." then continue; + if pos("D",v["Attr"]) then + begin + countfile(dir+iof+fn,n,ct); + end else n++; + end + end + function lazyload(it,ex); + begin + ins := Fnodeinfos[it.handle]; + iof := iofileseparator(); + if ins then + begin + dir := ins.fullname(); + ct := 0; + dirs := array(); + files := array(); + subs := filelist("",dir+iof+"*"); + crc := getmsgd_crc32(tostn(subs)); + if fdircrc[crc] then return it.dirtype := false ; + fdircrc[crc] := true; + for i,v in subs do + begin + fn := v["FileName"]; + if fn="." or fn=".." then continue; + if pos("H",v["Attr"]) then continue; + if pos("D",v["Attr"]) then + begin + dirs[i] := array(dir+iof+fn,it); + end else + begin + nd := FTree.CreateTreeNode(); + iid := 1; + if pos(".dll",lowercase(fn)) or pos(".exe",lowercase(fn)) or pos(".lib",lowercase(fn)) then iid := 2; + files[i] := array(fn,dir,iid,nd); + end + end + for j,v in files do + begin + iid := v[2]; + fn := v[0]; + dir := v[1]; + nd := v[3]; + nd.ImgId := iid; + nd.SelImgId := iid; + nd.Caption := fn; + nd.parent := it; + ndinfo := new tdirnodeinfo(); + Fnodeinfos[nd.handle] := ndinfo; + ndinfo.isfile := true; + ndinfo.fname :=fn; + ndinfo.Folder := dir ; + ct++; + end + for j,v in dirs do + begin + adddir(v[0],v[1]); + ct++; + end + if ct then + begin + if ex then it.expand(); + end + begin + it.dirtype := false; + end + end + end + function emptyexpanding(o,e); + begin + it := e.item; + lazyload(it,1); + end + function addrootdir(dir); + begin + adddir(dir,nil); + end + function delrootdir(nd); + begin + if nd.parent = ftree.rootnode then + begin + h := nd.handle; + fi := Fnodeinfos[h]; + Fnodeinfos[h] := 0; + FRootdirs::begin + if mcell=nd then mcell := 0; + end + nd.Recycling(); + fnodes := array(); + end + end + function getrootdirs(); + begin + r := array(); + for i,v in FRootdirs do + begin + if v then r[length(r)] := i; + end + return r; + end + function addrootdirs(r); + begin + for i,v in r do + begin + addrootdir(v); + end + end + function adddir(dir,pnode); + begin + if not(pnode) and FRootdirs[dir] then return 0; + dirinfo := filelist("",dir); + if not dirinfo then return 0; + if not pos("D",dirinfo[0]["Attr"]) then return 0; + if pos("H",dirinfo[0]["Attr"]) then return 0; + nd := FTree.CreateTreeNode(); + fnodes := array(); + nd.dirtype := true; + nd.ImgId := 0; + nd.SelImgId := 0; + ndinfo := new tdirnodeinfo(); + Fnodeinfos[nd.handle] := ndinfo; + if pnode then + begin + nd.parent := pnode; + end else + begin + nd.parent := FTree.rootnode; + FRootdirs[dir] := nd; + ndinfo.rootnode := true; + end + getname(dir,n,ph); + ndinfo.isfile := 0; + ndinfo.fname := n; + ndinfo.Folder := ph; + nd.Caption := n; + fnodes := array(); + return 1; + end + function refreshdir(); + begin + fbackrootdirs := array(); + for i,v in FRootdirs do + begin + if v then + begin + v.Recycling(); + fbackrootdirs[i] := 1; + end + end + fnodes := array(); + FRootdirs := array(); + Fnodeinfos := array(); + for i,v in fbackrootdirs do + begin + addrootdir(i); + end + fbackrootdirs := array(); + fdircrc := array(); + end + private + function getname(fname,n,dir); + begin + fi := iofileseparator(); + n := ""; + for i:= length(fname) downto 1 do + begin + vi := fname[i]; + if vi=fi then + begin + dir := fname[1:i-1]; + break; + end + n := vi+n; + end + return n; + end + function getallnodes(); + begin + if not fnodes then + begin + ct := 0; + nd := nil; + loadall(nd,ct,3000); + fnodes := array(); + FTree.rootnode.caption := ""; + nodes(FTree.rootnode,fnodes); + end + end + function nodes(nd,nds); + begin + nds[length(nds)] := nd; + for i := 0 to nd.ItemCount-1 do + begin + nodes(nd.GetNodeByIndex(i),nds); + end + end + function searchbmp(); +begin + return "0502000000060400000074797065000203000000696D670006040000006461746 +100020502000089504E470D0A1A0A0000000D4948445200000018000000180806 +000000E0773DF8000000017352474200AECE1CE90000000467414D410000B18F0 +BFC6105000000097048597300000EC300000EC301C76FA8640000019A49444154 +484BED942FABC2601487170D1A440D62D0E0D2D06214C14FB02698449BF82564C +92018FC0676510441B098B681268320220836A36098E97739F3782FF2BEF35DF0 +A67B1F58F89DFD79DEEDECBC1A7E993F24389FCF58AFD7B8DD6E5C098752D0E97 +490CBE5A069DAF7512C16311C0EF98AF7040AB6DB2D32990C9ACD26369B0D2E97 +0B3CCFC3E170C0783C46229180699A381E8F7C871CA9E07EBFFB2B9D4C265C915 +32E97D1683438C9910AEAF53A2CCBE214CCF57A453299C462B1E08A8820389D4E +88C5629CD4F4FB7DB45A2D4E2282603E9F43D7754E6A6CDB462A95E2242208BAD +D2EAAD52AA77050BF56AB15A75704C16C36433E9FE7A4861EFCEE930A82FD7E8F +6834CA490DF5A056AB7112110444A552C16030E014CCF32F1A8D465C11910AE8B +5C3CE41BBDDE624472A20A8D9F178DC9FE4DD6EC7D5C7AA9F936C18C6CB391981 +0282FA417B113D2C9D4EA3542AF96F562814D0EBF5FC4564B359B8AECB7788BC1 +53CA1AD83E683FAE2380E571F908416B05C2EB9F24A28810A924422114CA753AE +FCF011011134A01F1304F12F50007C017768621EE3E529620000000049454E44A +E42608200"; +end +function filebmp(); +begin + return "0502000000060400000074797065000203000000696D670006040000006461746 +10002D002000089504E470D0A1A0A0000000D4948445200000018000000180806 +000000E0773DF8000000017352474200AECE1CE90000000467414D410000B18F0 +BFC6105000000097048597300000EC300000EC301C76FA8640000026549444154 +484BA596316BF26010C7FD0A4A45E820EAE0AAE22055870E2E4E7E00371571717 +311119DDB8A5014717110071144544429942E56A1ED262E4E2ED6ADA2A0EBBDDE +E51293D4B7BEE9FB8323FC2F77CFFF497289EA40C5D3D313148B45C8E57267239 +FCFFF351E1F1FE1E3E3835712501884C361D0E974FF1D6EB71BAAD52AAD2919BC +BDBDD149DCE57C3EA723EAC964C21597D96C36D0EFF7C1E3F150EF6030381994C +B654AE2E22206830152A914AB7FE7F3F313AEAFAFC1EFF79F0C1E1E1EC860BFDF +73066827C16090953662B1189948068D46830C96CB2567002C160BDCDEDEFE3A7 +03DC9E0F9F99912EFEFEFA45F5F5FCF36FD14D8FF2D47AB1DC17B8F05C3E19033 +DAC0F1C4FEC3E1C01901C9E0EBEB8B0AEAF53A67B4810F16FB67B319670424030 +40B0A85022BED188D46E8743AAC041406269309D2E9342B819797978B21E27038 +E0FEFE9E9580C2C0E974D278C9C1ABFA29E40638D28944829580C2000B42A1102 +BED44A351080402AC0414069148047C3E1F2BED64B359B05AADAC041406994C06 +EC763B2B01F55CAB437E8B2A950ADD36390A552A9540AFD7B312907FAA31D49F6 +8B941B7DB25031C59118541BBDDA6027C277E037E05B07F3C1E73E66820EE44DC +21162C160B3EAD8DD56A45FDF297F5A8BF8F9E96DF0035D88F1B15D15D5D5D413 +29924319D4EA9A0D7EB91D60A6E0CFB47A311678E0638962E978BC47ABDA6D7BD +56AB91D60A4E95CD6683ED76CB99A381F8158DC7E334115EAF17EEEEEEF8F4657 +6BB1D3D547CC9709D66B3C96704688A7061B3D94C05780578D41A373737D06AB5 +685139D298E265E1BD93CFB83CC42953C7B9BF2A2700FE001125FC161DCF24BC0 +000000049454E44AE42608200"; +end +function folderbmp(); +begin + return "0502000000060400000074797065000203000000696D670006040000006461746 +10002C301000089504E470D0A1A0A0000000D4948445200000018000000180806 +000000E0773DF8000000017352474200AECE1CE90000000467414D410000B18F0 +BFC6105000000097048597300000EC300000EC301C76FA8640000015849444154 +484BDD94318A8340144025571052A7509BF429839590CE464825DA0662E301CC0 +1C42282E00162E1016C0541888585827D7A4B0FF037F377D4C8EEC2B23369F6C1 +C7FF3F3A6F661C468037F30F04AAAA8220085F62BBDD42D775F4B5BFF31CEBFB4 +55C2E172E921F0504CFF316ABFA4DC4714CBFFEE4D9E3F71B4EA7134EEA9585A0 +2CCBC56C58C3300CF29C05B66D431004B462878A66812CCB70BFDF69C5469665A +069DA2CA8AA0AD6EB35E63C389FCFE0FBFE2C20C5F178C49C07922441DBB6B340 +D77508C31073561E8F076C361BCC2781288A50D735E6AC5CAF57B02C0B731490F +D5714051B3C381C0E70BBDD304701B9164CD3C4060FC8987DDF8FB900FBFD1EA2 +28C2062B455100B9404750B05AADA0691ADA62C3755DDC911114EC763B5AB2438 +E679EE7B4A202C77168C9C6300CD3F11C4141922468658D344DA7E33922902345 +7E0AAF20A257E69BEE4DBC5900F00106E8BE867C71B1300000000049454E44AE4 +2608200"; +end +function dllbmp(); +begin + return "0502000000060400000074797065000203000000696D670006040000006461746 +10002DB01000089504E470D0A1A0A0000000D4948445200000018000000180806 +000000E0773DF8000000017352474200AECE1CE90000000467414D410000B18F0 +BFC6105000000097048597300000EC300000EC301C76FA8640000017049444154 +484B63F84F638061C1D7EFDFFFBF79FF9E285CD53105AA0B37C0B0E0D5BB77FF5 +FBE7D4B142E6F9DF4BFA8A117AA133BC0B000E4326C8661C3200B4C3C62F05A42 +9105156D100BF059429105D76EDF055B02F20908638B138A2C40C720BDE880240 +B662D5D0BC4EBB0CA8130D91680BC9F5BD3F53F34AD1C8C41EC8AB6C918EAC8B2 +E0DEE327FFBD62F2FE1F3F77090583C490D581305916F4CD5A0276F59E2327E13 +E80B14172C86AC9B220B1B0E1FFD2F5DBA0E18FC02031901CB25AB22CB874E336 +38384041054B8EB06003C921AB25CB029861A08885B91EC4A65A1C803072C4823 +08C8FAE8E6C0B88C523C0823317AFC14B4750120C482C82F389C5203390014E0B +402EBA71F73E980659366FE546B038321B1B26C902180D3274D1DAAD603E321B1 +B26C98285AB37C32D58BD65F7FF82FA1E1436B2C1308CD702108029049533F53D +33FEC7E4D6FC0F4A2EF9DFD03B132C86CC768BC842311C84D1018605200072053 +91813FCFF0F007C3FE0AC714133290000000049454E44AE42608200"; +end + fbackrootdirs; + FTree; + FEdit; + fbtn; + + FRootdirs; + fnodes; + Fnodeinfos; + fdircrc; + type tdirnodeinfo = class() + function create(); + begin + isfile := true; + Folder := ""; + fname := ""; + iof := iofileseparator(); + end + function fullname(); + begin + return Folder+iof+fname; + end + isfile; + Folder; + fname; + caption; + rootnode; + private + iof; + end + +end diff --git a/designer/udesignerproject.tsf b/designer/udesignerproject.tsf index 14339b7..c154ab2 100644 --- a/designer/udesignerproject.tsf +++ b/designer/udesignerproject.tsf @@ -135,7 +135,7 @@ type TProjectManagerForm = class(TVCForm) // if FileExists("",f)then return "工程已经存在"; p := GetPathFromFullName(f,n,t); fio := ioFileseparator(); - if length(FileList("",p+fio+"*.*"))>2 then + if length(FileList("",p+fio+"*"))>2 then begin if IDOK <> Messageboxa("文件夹非空,点击确定继续\r\n点击取消退出","文件夹非空",1)then return false; end