diff --git a/designer/tslvcldesigner.tsf b/designer/tslvcldesigner.tsf index 080d8a8..b1e9b4f 100644 --- a/designer/tslvcldesigner.tsf +++ b/designer/tslvcldesigner.tsf @@ -494,10 +494,10 @@ type TVclDesigner = class(tvcform) if FTree.Loading then return ; FProjectManager.adduses(lbs); end - function EditerCodeChanged(); //代码改变 + function EditerCodeChanged(nd); //代码改变 begin if FTree.Loading then return ; - classinfo := FProjectManager.GetFormClassInfo(); + classinfo := FProjectManager.GetFormClassInfo(nd); if classinfo and ifarray(classinfo) then begin class(TDComponent).TemporaryNotName := classinfo["members"]; diff --git a/designer/udesignerproject.tsf b/designer/udesignerproject.tsf index d7d4294..67239c5 100644 --- a/designer/udesignerproject.tsf +++ b/designer/udesignerproject.tsf @@ -228,15 +228,20 @@ type TProjectView = class(TVCForm) // begin if not FFilterList.visible then begin - xy := FFilter.clienttoscreen(FFilter.left,FFilter.height); - rec := xy; - rec[2] := xy[0]+FFilter.width; - rec[3] := xy[1]+200; - FFilterList.SetBoundsRect(rec); - FFilterList.Show(SW_SHOWNOACTIVATE); + xy := FFilter.clienttoscreen(FFilter.left,FFilter.height); + rec := xy; + rec[2] := xy[0]+FFilter.width; + rec[3] := xy[1]+200; + FFilterList.SetBoundsRect(rec); + FFilterList.Show(SW_SHOWNOACTIVATE); end FFilterList.SetData(d); end + function saveformcode(); //保存当前class + begin + it := FTslEditer.GetCurrentItem(); + FTslEditer.SavePageItem(it); + end public function FilterKillFocus(o,e); begin @@ -292,7 +297,7 @@ type TProjectView = class(TVCForm) // if cc=VK_UP then begin e.skip := true; - if FFilterList.visible then + if FFilterList.visible then begin idx := FFilterList.getCurrentSelection(); ct := length(FFilterNodes); @@ -359,9 +364,10 @@ type TProjectView = class(TVCForm) // begin FTslEditer.SetCodeFormatInfo(FMTDATA); end - FTslEditer.OnFormCodeSave := function(o,e) + FTslEditer.OnFormCodeSave := function(o,e) ;//TFTSLScriptcustomMemo begin - if FCurrentOpend and (FCurrentOpend["type"] in array("panel","form")) then FDesigner.EditerCodeChanged(); + nd := FTree.CurrentNode; + if nd and (nd["type"] in array("panel","form")) then FDesigner.EditerCodeChanged(nd); end //FTslEditer.Parent := AOwner; FTmfParser := new TTmfParser(); @@ -469,7 +475,6 @@ type TProjectView = class(TVCForm) // FTree.OnSelChanged := thisfunction(TreeNodeChanged); FTree.OnDblClick := function(o,e) begin - //echo "dbclick\r\n"; OpenTreeNode(); end FWrapFolder := new TFolderChooseADlg(self); @@ -505,11 +510,18 @@ type TProjectView = class(TVCForm) // begin if it.FType="dir" then begin - FDelMenu.Enabled := true; + if (it=FTree.ProjectNode) then + begin + FDelMenu.Enabled := false; + end else + FDelMenu.Enabled := true; FAddMenu.Enabled := true; end else begin - FDelMenu.Enabled := true; + if ((lowercase(it["name"]+".tsf")=lowercase(FMainForm+".tsf")) or (lowercase(it["name"]+".tsl")=lowercase(FExecEntry+".tsl"))) then + begin + FDelMenu.Enabled := false; + end else FDelMenu.Enabled := true; FAddMenu.Enabled := false; end if((it.FType="form")and(it.FName <> FMainForm)and(it.FPath()=""))then @@ -528,7 +540,7 @@ type TProjectView = class(TVCForm) // if((it.FType="form")and(it.FName <> FMainForm))or(it.FType="tsl")and(it.FName <> FExecEntry)or(it.FType="tsf")or(it.FType="panel") {or((it.FType = "dir") and it.parent<>FTree.RootNode)}then begin FRenameMenu.parent := FTreePopUpMenu; - if CreateMoveDirMenus()then FMoveMenu.parent := FTreePopUpMenu; + if CreateMoveDirMenus(it)then FMoveMenu.parent := FTreePopUpMenu; else FMoveMenu.parent := nil; end else begin @@ -554,7 +566,7 @@ type TProjectView = class(TVCForm) // if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self); if FInput.ShowModal()then begin - RenameCurrentDir(FInput.GetEditV()); + RenameCurrentDir(FInput.GetEditV(1)); end end function Add_form(); @@ -640,8 +652,15 @@ type TProjectView = class(TVCForm) // end end end - function GetFormClassInfo(); //获得编辑器中类的变量信息 + function GetFormClassInfo(nd); //获得编辑器中类的变量信息 begin + if nd then + begin + f1 := nd.gettsfname(); + it := FTslEditer.GetCurrentItem(); + f2 := it.ScriptPath; + if f1<>f2 then return ; + end return FTslEditer.GetClassInfo(); end function ShowEditor(); //显示函数编辑 @@ -655,12 +674,14 @@ type TProjectView = class(TVCForm) // if r then FTslEditer.OpenAndGotoFileByName(r); ShowEditor(); end + function AddAFiled(n); //添加成员 begin if ifstring(n)and FCurrentOpend and(FCurrentOpend["type"] in array("form","panel"))then begin r := FCurrentOpend.gettsfname(); FTslEditer.Addfiled(r,n); + saveformcode(); end end function adduses(lbs); //添加成员 @@ -669,6 +690,7 @@ type TProjectView = class(TVCForm) // begin r := FCurrentOpend.gettsfname(); FTslEditer.adduses(r,lbs); + saveformcode(); end end @@ -678,6 +700,7 @@ type TProjectView = class(TVCForm) // begin r := FCurrentOpend.gettsfname(); FTslEditer.Delfiled(r,n,nn); + saveformcode(); end end function AddAFunction(ff); //添加函数 @@ -687,20 +710,22 @@ type TProjectView = class(TVCForm) // s := createtslfunction(ff); fn := FCurrentOpend.gettsfname(); r := FTslEditer.AddFunction(fn,ff["name"],s); - ShowEditor(); + saveformcode(); + ShowEditor(); return r; end end function GoToAFunction(n); //跳转到函数 begin r := FTslEditer.GoToFunction(FCurrentOpend.gettsfname(),n); + saveformcode(); ShowEditor(); return r; end function OpenFileByName(n); //打开文件 begin fio := ioFileseparator(); - if not(n and ifstring(n)) then return 0; + if not(n and ifstring(n)) then return FDesigner.ExecuteCommand("hiddrennode",nil);; nopend := FTree.NameInTree(n,nil,true); if not nopend then begin @@ -709,12 +734,6 @@ type TProjectView = class(TVCForm) // end if nopend=FCurrentOpend then begin - {if FCurrentOpend["type"]in array("tsf","tsl","form","panel")then - begin - fn := FCurrentOpend.geteditfilename(); - FTslEditer.OpenAndGotoFileByName(fn); - ShowEditor(); //FTslEditer.Show(); - end} return 0; end FCurrentOpend := nopend; @@ -770,7 +789,9 @@ type TProjectView = class(TVCForm) // end function OpenMainForm(); //打开主函数 begin - OpenFileByName(FMainForm); + nd := FTree.NameInTree(FMainForm,nil,true); + FTree.SetSel(nd); + //OpenFileByName(FMainForm); end function SetProjectInfo(F); //设置信息 %% begin @@ -818,35 +839,29 @@ type TProjectView = class(TVCForm) // FExecEntry := d["entryscript"]; end FTslEditer.setExecuteEditerSetcmdline(d["commandline"]); - OpenMainForm(); //打开主窗口2 - //设置选中节点 20210413 添加 - mnode := FTree.NameInTree((FMainForm),nil,true); - if FTree.CurrentNode <> mnode then - begin - FTree.SetSel(mnode); - end + OpenMainForm(); //打开主窗口 end - function SetAsMainWind(o,e); + function SetAsMainWind(o,e); //设置主窗口 begin if o.caption = "设置为主窗口" then begin - cn := FTree.CurrentNode; - fn := cn.FName ; - FMainForm := fn; - SaveProjInfo(); - o.parent := nil; + cn := FTree.CurrentNode; + fn := cn.FName ; + FMainForm := fn; + SaveProjInfo(); + o.parent := nil; end else if o.caption = "设置为入口脚本" then begin - cn := FTree.CurrentNode; - fn := cn.FName ; - FExecEntry := fn; - SaveProjInfo(); - o.parent := nil; + cn := FTree.CurrentNode; + fn := cn.FName ; + FExecEntry := fn; + SaveProjInfo(); + o.parent := nil; end end - function DeletCTNode(); + function DeletCTNode(); //删除当前节点 begin cn := FTree.CurrentNode; if cn.FType="dir" then DeleteCurrentDir(); @@ -855,20 +870,30 @@ type TProjectView = class(TVCForm) // end function DeleteCurrentDir(); //删除当前目录; begin - cn := FTree.CurrentNode; + cn := FTree.CurrentNode; if not cn then return; if cn=FTree.ProjectNode then return Messageboxa("工程目录不能删除","提示",0,self); if IDOK=Messageboxa("即将从工程中移除文件夹:"+cn.Caption,"提示",1,self)then begin - if FCurrentOpend and FTree.FileNameInCurrentNode(FCurrentOpend["name"])then - begin - CloseCurrentEdit(nil,true); - end if IDOK=Messageboxa("是否删除文件夹及其类容:"+cn.Caption,"提示",1,self)then begin + dcns := array(); + ftree.GetNodeLeafs(cn,dcns); + for i,v in dcns do + begin + if v.FType = "dir" then continue; + FTslEditer.CloseScriptByFileName(v.geteditfilename()); + if v.FType in array("form","panel") then + begin + tn := v.gettmfname(); + FTslEditer.CloseScriptByFileName(tn); + FileDelete("",tn); + end + end dp := cn.FPath; DeleteAllFiles(FCProjectPath+dp); end + FCurrentOpend := nil; FTree.DeleteCurrentNode(); SaveProjInfo(); end @@ -883,27 +908,15 @@ type TProjectView = class(TVCForm) // if IDOK=Messageboxa("即将从工程中移除:"+d["name"],"提示",1,self)then begin CloseCurrentEdit(nd,true); - ml := d["dir"]; - if ifstring(ml)and ml then ml := ml+fio; - else ml := ""; - ft := "tsl"; - if d["type"]in array("panel","form","tsf")then ft := "tsf"; - FTslEditer.CloseScriptByFileName(FCProjectPath+ml+d["name"]+"."+ft); + fn := nd.geteditfilename(); + FTslEditer.CloseScriptByFileName(fn); if IDOK=Messageboxa("是否删除文件","提示",1,self)then //移除文件 begin + FileDelete("",fn); case d["type"]of "form","panel": begin - FileDelete("",FCProjectPath+ml+d["name"]+".tsf"); - FileDelete("",FCProjectPath+"resource.tfm"+fio+d["name"]+".tfm"); - end - "tsl": - begin - FileDelete("",FCProjectPath+ml+d["name"]+".tsl"); - end - "tsf": - begin - FileDelete("",FCProjectPath+ml+d["name"]+"."+d["type"]); + FileDelete("",nd.gettmfname()); end end; end @@ -1023,31 +1036,24 @@ type TProjectView = class(TVCForm) // function RenameCurrentDir(n); //修改目录名 begin if not LegalVariableName(n)then return MessageboxA("名字不合法,请重试","提示",0,self); - if FTree.NameInTree(lowercase(n),nil,false)then return MessageboxA("重复的文件名","提示",0,self); + if FTree.NameInTree(n,nil,false)then return MessageboxA("重复的文件名","提示",0,self); //CloseCurrentEdit(); cn := FTree.CurrentNode; if cn.FType="dir" then return; fio := ioFileseparator(); - ph := FTree.CurrentNode.FPath; - if ph then ph += fio; - else ph := ""; fullsouce := 0; + fllname := cn.geteditfilename(); + fllnname := cn.geteditfilename(n); case cn.FType of - "tsf","panel","form": + "panel","form": begin - fllname := FCProjectPath+ph+cn.caption+".tsf"; - fllnname := FCProjectPath+ph+n+".tsf"; - if cn.FType in array("panel","form")then - begin - fullsouce := FCProjectPath+"resource.tfm"+fio+cn.caption+".tfm"; - fullnsouce := FCProjectPath+"resource.tfm"+fio+n+".tfm"; - end - end else - begin - fllname := FCProjectPath+ph+cn.caption+".tsl"; - fllnname := FCProjectPath+ph+n+".tsl"; - end + fullsouce := cn.gettmfname() ; + fullnsouce := cn.gettmfname(n); + FTslEditer.SaveFileByName(fullsouce); + FTslEditer.CloseScriptByFileName(fullsouce); + end end + FTslEditer.SaveFileByName(fllname); FTslEditer.CloseScriptByFileName(fllname); if cn.FType in array("tsf","panel","form")then begin @@ -1086,11 +1092,11 @@ type TProjectView = class(TVCForm) // filerename("",fullsouce,fullnsouce); end cnifno := cn.FFileInfo; - cnifno["name"]:= lowercase(n); + cnifno["name"]:= n; cn.FFileInfo := cnifno; cn.caption := n; SaveProjInfo(); - FDesigner.ExecuteCommand("renamefile",lowercase(n)); + FDesigner.ExecuteCommand("renamefile",n); end else return MessageboxA("更名错误","提示",0,self); end @@ -1099,13 +1105,8 @@ type TProjectView = class(TVCForm) // if not LegalVariableName(n)then return MessageboxA("名字不合法,请重试","提示",0,self); if FTree.NameInTree(lowercase(n),nil,true)then return MessageboxA("重复的文件名","提示",0,self); fn := array("name":n,"type":t,"dir":FTree.CurrentNode.FPath); - ph := FTree.CurrentNode.FPath; - fio := ioFileseparator(); - if ph then ph += fio; - else ph := ""; - FTree.SetFileToNode(fn); - cprojpath := FCProjectPath; - ph := cprojpath+ph+n+"."+t; + nnd := FTree.SetFileToNode(fn); + ph := nnd.geteditfilename(); if not FileExists("",ph)then begin if t="tsf" then r := CreateATsf(n); @@ -1114,7 +1115,7 @@ type TProjectView = class(TVCForm) // end SaveProjInfo(); end - function ShowExeEditer(); + function ShowExeEditer(); //显示调试窗口 begin if not FMainForm then begin @@ -1140,7 +1141,7 @@ type TProjectView = class(TVCForm) // return; end - function debugproject(); + function debugproject(); //调试运行 begin if not FMainForm then begin @@ -1351,7 +1352,7 @@ type TProjectView = class(TVCForm) // end end - function GetDirNodes(nd,r); + function GetDirNodes(nd,r,nt); begin if not ifarray(r) then r := array(); if not nd then return ; @@ -1360,21 +1361,24 @@ type TProjectView = class(TVCForm) // tnd := nd.GetNodeByIndex(i); if tnd.FType="dir" then begin - r[length(r)] := array(tnd.FPath(),tnd); - GetDirNodes(tnd,r); + if nt<>tnd then + r[length(r)] := array(tnd.FPath(),tnd); + GetDirNodes(tnd,r,nt); end end end - function CreateMoveDirMenus(); + function CreateMoveDirMenus(it); begin ds := array(); rnd := FTree.RootNode.GetNodeByIndex(0); - GetDirNodes(rnd,ds); - if not ifarray(FMoveMnus) then FMoveMnus := array(); - + pit := it.parent; + if rnd<>pit then + ds[length(ds)] := array("<主目录>",rnd); + GetDirNodes(rnd,ds,pit); + if not ifarray(FMoveMnus) then FMoveMnus := array(); if ds then begin - ds[length(ds)] := array("<主目录>",rnd); + lends := length(ds); lengthMenus := length(FMoveMnus); for i:= length(FMoveMnus) to lends-1 do @@ -1612,7 +1616,7 @@ BD141CA912494F502D48D224F45050274A21E03806FF2C7CA7516022D7D000000 it := OpenAndGotoFileByName(n); if it then return it.AddFunction(fn,finfo); end - function Addfiled(fn,n); + function Addfiled(fn,n); //添加变量 begin it := OpenAndGotoFileByName(fn); if it then @@ -1620,7 +1624,7 @@ BD141CA912494F502D48D224F45050274A21E03806FF2C7CA7516022D7D000000 it.AddFiled(n); end end - function Adduses(fn,lbs); + function Adduses(fn,lbs); //添加uses begin it := OpenAndGotoFileByName(fn); if it then @@ -1633,27 +1637,30 @@ BD141CA912494F502D48D224F45050274A21E03806FF2C7CA7516022D7D000000 it := OpenAndGotoFileByName(n); if it then return it.Delfiled(fld,nn); end - function GetClassInfo(n); + function GetClassInfo(n); //获得信息 begin if n and ifstring(n)then it := OpenAndGotoFileByName(n); else it := GetCurrentItem(); - if it then return it.GetClassInfo(); + if it then + begin + return it.GetClassInfo(); + end return nil; end + function dopageitemsaved(it);override; //保存 + begin + calldatafunction(fSetOnFormCodeSave,it,nil); + end function createparams(p);override; begin inherited; p.style .|= WS_MAXIMIZEBOX .| WS_MINIMIZEBOX; //p.cstyle := CS_HREDRAW .| CS_VREDRAW .| CS_OWNDC .| CS_DBLCLKS ; end - property OnFormCodeSave write SetOnFormCodeSave; + property OnFormCodeSave write fSetOnFormCodeSave; private + fSetOnFormCodeSave; FDefaultcmdline; - function SetOnFormCodeSave(v); - begin - OnPageEditerChanged := v; - //OnScriptChanged := v; - end end //************************************ @@ -2016,16 +2023,15 @@ type TFileTree = class(TTreeCtl) end function AddDirToNode(n,nd); //在节点上面添加目录 begin - if not ifstring(n)then return nil; + if not(ifstring(n) and n)then return nil; if not nd then return nil; if nd.FType <> "dir" then return nil; - lv := lowercase(n); - ci := DirInNode(lv,nd); + ci := DirInNode(n,nd); if ci then return ci; ci := CreateTreeNode(); ci.FType := "dir"; ci.caption := n; - ci.FName := lv; + ci.FName := n; ci.parent := nd; return ci; end @@ -2036,9 +2042,6 @@ type TFileTree = class(TTreeCtl) property RootDir read FRootDir write SetRootDir; //根目录名称 property FileCanSel read FFileCanSel write SetFileCanSel; //文件是否可以选择 property ProjectNode read FPNode; - private - FImageIdName; - FFileCanSel; function GetNodeLeafs(nd,fs); //获得叶子节点 begin if nd.ItemCount<1 then @@ -2051,16 +2054,21 @@ type TFileTree = class(TTreeCtl) GetNodeLeafs(nd.GetNodeByIndex(i),fs); end end + private + FImageIdName; + FFileCanSel; + function SetFileCanSel(v); begin FFileCanSel := v; end function DirInNode(d,nd); //文件夹是否在节点上面 begin + ld := lowercase(d); for i := 0 to nd.ItemCount-1 do begin ci := nd.GetNodeByIndex(i); - if(ci.FName=d)then + if(lowercase(ci.FName)=ld)then begin return ci; end; diff --git a/designer/utslcodeeditor.tsf b/designer/utslcodeeditor.tsf index bdc381e..4c70d5c 100644 --- a/designer/utslcodeeditor.tsf +++ b/designer/utslcodeeditor.tsf @@ -2105,16 +2105,22 @@ type TEditer=class(TCustomcontrol) // //s := tostm(v); r := exportfile(ftstream(),"",fp,v); it.ReGetLastLoadTime(); + dopageitemsaved(it); return r; except end end r := ReWriteString(fp,s); it.ReGetLastLoadTime(); + dopageitemsaved(it); return r; end return 1; end + function dopageitemsaved(it);virtual; + begin + + end function ShowFindWnd(); begin FInfoShowWnd.ShowByTag(FFindListWnd);