diff --git a/designer/utslcodeeditor.tsf b/designer/utslcodeeditor.tsf index 97cb15c..f869753 100644 --- a/designer/utslcodeeditor.tsf +++ b/designer/utslcodeeditor.tsf @@ -1099,6 +1099,7 @@ type TPageEditerItem=class(TPageItem) FEditer.Align := FEditer.alClient; FEditer.Visible := false; FEditer._Tag := self; + Fscripttype := 0; end function Recycling();override; begin @@ -1125,6 +1126,7 @@ type TPageEditerItem=class(TPageItem) return filenameIsTheSame(v,FScriptPath); end published + property scripttype read Fscripttype write setFscripttype; property ScriptPath read FScriptPath write SetScriptPath; //文件名 property OrigScriptPath read FOrgScriptPath; property TslSynText read FTslSynText write FTslSynText; @@ -1132,6 +1134,7 @@ type TPageEditerItem=class(TPageItem) property EnCode read FEnCode; RepreComple; FISstm; + Fscripttype; ///////////////////设计器相关////////////////////////////////////// public function Addfiled(fld); //添加成员变量 @@ -1538,6 +1541,14 @@ type TPageEditerItem=class(TPageItem) FLastVersion; //脚本 FScriptPath; //路径 FOrgScriptPath; //原始路径 + function setFscripttype(v); + begin + if (v=0 or v=1) and v<>Fscripttype then + begin + Fscripttype := v; + FLastVersion := FEditer.Text; + end + end function SetScriptPath(v); begin sp := ioFileseparator(); @@ -2137,6 +2148,10 @@ type TEditer=class(TCustomcontrol) // except end end + if it.scripttype=1 then + begin + s := replacetext(s,"\r\n","\n"); + end r := ReWriteString(fp,s); it.ReGetLastLoadTime(); dopageitemsaved(it); @@ -2427,11 +2442,27 @@ type TEditer=class(TCustomcontrol) // end function PageEditerMenuClick(o,e); begin - if ("另存为"=o.Caption) then + cp := o.Caption; + if ("转unix(LF)"=cp) then + begin + it := GetCurrentItem(); + it.scripttype := 1; + SavePageItem(it,1); + //it.FEditer.ChangedFlag := true; + return ; + end else + if ("转windows(CR LF)"=cp) then + begin + it := GetCurrentItem(); + it.scripttype := 0; + SavePageItem(it,1); + return ; + end else + if ("另存为"=cp) then begin return PageMenuClick(o,e); end else - if pos("复制",o.caption)=1 then + if pos("复制",cp)=1 then begin it := GetCurrentItem(); if it then @@ -2445,7 +2476,7 @@ type TEditer=class(TCustomcontrol) // end return; end else - if pos("粘贴",o.caption)=1 then + if pos("粘贴",cp)=1 then begin it := GetCurrentItem(); if it then @@ -2459,7 +2490,7 @@ type TEditer=class(TCustomcontrol) // end return; end else - if pos("剪切",o.caption)=1 then + if pos("剪切",cp)=1 then begin it := GetCurrentItem(); if it then @@ -2473,13 +2504,13 @@ type TEditer=class(TCustomcontrol) // end return; end else - if pos("定位",o.caption)=1 then + if pos("定位",cp)=1 then begin InitShowWndPos(FGotoLineWnd,"g",200,200); FGotoLineWnd.ShowGoto(); return; end else - if pos("查看",o.caption)=1 then + if pos("查看",cp)=1 then begin cs := o.Caption; if length(cs)<6 then return; @@ -2487,7 +2518,7 @@ type TEditer=class(TCustomcontrol) // GetCurrentEditer().Tryjump(s); return; end else - if pos("只读",o.caption)=1 then + if pos("只读",cp)=1 then begin it := GetCurrentItem(); if it then @@ -2496,26 +2527,26 @@ type TEditer=class(TCustomcontrol) // end return; end else - if pos("执行",o.Caption)=1 then + if pos("执行",cp)=1 then begin it := GetCurrentItem(); ExecutePageItem(it); return; end else - if pos("停止",o.Caption)=1 then + if pos("停止",cp)=1 then begin if FEchoWnd.Exeing()then FEchoWnd.EndExe(); return; end else - if o.Caption = "转换为大写" then + if cp = "转换为大写" then begin upperorlowercase(1); end else - if o.Caption = "转换为小写" then + if cp = "转换为小写" then begin upperorlowercase(0); end else - if o.Caption = "删除尾空白" then + if cp = "删除尾空白" then begin seltrimright(); end @@ -2527,15 +2558,31 @@ type TEditer=class(TCustomcontrol) // begin FPageEditerMenu := new TPopUpMenu(self); FPageEditerMenus := array(); - for i,v in array("查看","复制(C)","粘贴(V)","剪切(X)","定位(G)","只读","转换为大写","转换为小写","删除尾空白","执行(F9)","停止执行","另存为") do + for i,v in array("查看","复制(C)","粘贴(V)","剪切(X)","定位(G)","只读","转换为大写","转换为小写","删除尾空白","文档格式","执行(F9)","停止执行","另存为") do begin it := new TMenu(self); it.Caption := v; + it.parent := FPageEditerMenu; + if "文档格式"=v then + begin + for j,vj in array("转unix(LF)","转windows(CR LF)") do + begin + subit := new TMenu(self); + FPageEditerMenus[vj]:= subit; + subit.Caption := vj ; + subit.Parent := it; + subit.OnClick := thisfunction(PageEditerMenuClick); + end + continue; + end FPageEditerMenus[v]:= it; it.OnClick := thisfunction(PageEditerMenuClick); end end + iflx := GetCurrentItem().scripttype = 1; + FPageEditerMenus["转unix(LF)"].Enabled := not iflx; + FPageEditerMenus["转windows(CR LF)"].Enabled := iflx; rd := FPageEditerMenus["只读"]; if rd then begin @@ -4148,6 +4195,23 @@ type TEditer=class(TCustomcontrol) // edt := it.FEditer; tl := edt.TopLine; cxy := edt.CaretXY; + {$ifdef linux} + it.scripttype := 1; + {$else} + it.scripttype := 0; + {$endif} + if pos("\r\n",s) then + begin + it.scripttype := 0; + end else + if pos("\n",s) then + begin + it.scripttype := 1; + end + if it.scripttype<>0 and length(p)>3 and (lowercase(p[length(p)-3:length(p)]) in array(".tsl",".tsf")) then + begin + it.scripttype := 0; + end it.SetLoadScript(s); if ifinit then begin