From 03d73ebec9f57c00ef1b9a4f875bdb7a753b6264 Mon Sep 17 00:00:00 2001 From: JianjunLiu Date: Fri, 24 Mar 2023 17:15:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将tsl代码树嵌入编辑器左侧 --- designer/tediterform.tsf | 3 +- designer/utslcodeeditor.tsf | 368 +++++++++++++++++++++++++--- funcext/tvclib/ugtkinterface.tsf | 10 +- funcext/tvclib/utslvclauxiliary.tsf | 2 +- 4 files changed, 337 insertions(+), 46 deletions(-) diff --git a/designer/tediterform.tsf b/designer/tediterform.tsf index 51e6028..771d2f7 100644 --- a/designer/tediterform.tsf +++ b/designer/tediterform.tsf @@ -1579,6 +1579,7 @@ type tdirviewer = class(tcustomcontrol) FEdit.parent := self; FEdit.Align := alTop; FTree := new TTreeView(self); + FTree.Border := false; FTree.Align := alClient; FTree.parent := self; ftree.ImageList := fimgs; @@ -1692,7 +1693,7 @@ type tdirviewer = class(tcustomcontrol) fimgs.addbmp(bmp); bt.ImageId := fimgs.ImageCount-1; bt.parent := ftb; - if i in array("ӹĿ¼","ƳĿ¼","","ˢ") then ftbns[i] := bt; + if i in array("ƳĿ¼","","ˢ") then ftbns[i] := bt; if i in array("","") then fsbtns[i] := bt; bt.onclick := thisfunction(toolclick); end diff --git a/designer/utslcodeeditor.tsf b/designer/utslcodeeditor.tsf index b25deb3..5f31501 100644 --- a/designer/utslcodeeditor.tsf +++ b/designer/utslcodeeditor.tsf @@ -613,6 +613,7 @@ F47AC96526C21CCB26FD326A2180CC21F5CAC302CA5C842B865FD9D7003D1F17B begin end end + type TEditerAuxiliary=class(TPage) // function Create(AOwner); begin @@ -1753,7 +1754,7 @@ type TEditer=class(TCustomcontrol) // "charset":0,"outprecision":0,"clipprecision":0,"quality":1,"pitchandfamily":1,"facename":"Courier New","color":0); FTslDebug := new TTslDebug(self); FFindListWnd := new TFindListWnd(self); - FCodeMap := new TTslCodeMap(self); + //FCodeMap := new TTslCodeMap(self); FFileopen := new TOpenFileADlg(self); FFileSave := new TSavefileADlg(self); FFileopen.WndOwner := self; @@ -1768,7 +1769,7 @@ type TEditer=class(TCustomcontrol) // FFindListWnd.OnDblClick := thisfunction(FindListChoosed); FGotoLineWnd.Visible := false; ///////////////////////// - FCodeMap.visible := false; + //FCodeMap.visible := false; FFindWnd.Visible := false; FFileSave.Filter := array("any":"*.*","tslļ":"*.tsl;*.tsf"); FFileSave.Caption := "Ϊ"; @@ -1850,12 +1851,17 @@ type TEditer=class(TCustomcontrol) // //FInfoShowWnd.Caption := "Ϣ:"; ////ڵ//////////////////////////////////////////////////// //FToolBar.Parent := self; + + FinCodemap := new tfincodemap(self); + FinCodemap.WsSizeBox := true; fcoolbar.arrange := "0,1"; - fcoolbar.Parent := self; + FStatus.Parent := self; FInfoShowWnd.Parent := self; + FinCodemap.Parent := self; + fcoolbar.Parent := self; FPageEditer.Parent := self; - FCodeMap.parent := self; + //FCodeMap.parent := self; FGotoLineWnd.Parent := self; FFindWnd.parent := self; FFileopen.parent := self; @@ -1885,6 +1891,7 @@ type TEditer=class(TCustomcontrol) // begin CreateAFile(); end + end function PopUpAuxiliary(); begin @@ -2318,6 +2325,7 @@ type TEditer=class(TCustomcontrol) // cp.PrePareCompletion(it.Caption); end EditerCaretChanged(it.FEditer,nil); + if FinCodemap then FinCodemap.ontimerdo(); end function docloseapageitem(it); begin @@ -2708,11 +2716,13 @@ type TEditer=class(TCustomcontrol) // if it.ScriptPathIs(n)then return it; end end - function EditerCaretChanged(o,e); + function EditerCaretChanged(o,e); //caret λøı begin if GetCurrentEditer()=o then begin FStatus.setitemtext(format("col:%d | %s",o.CaretX,o.PageItem.EnCode),1); + if FinCodemap and FinCodemap.Visible then + FinCodemap.caretchanged(o.CaretY); end end function OpenScriptByFileName(n); @@ -3095,8 +3105,13 @@ type TEditer=class(TCustomcontrol) // end "ͼ(alt+m)": begin - InitShowWndPos(FCodeMap,"cm",250,100); - FCodeMap.ShowMap(); + //InitShowWndPos(FCodeMap,"cm",250,100); + //FCodeMap.ShowMap(); + if FinCodemap and not(FinCodemap.Visible) then + begin + FinCodemap.doshow(true); + end + end end end @@ -3111,23 +3126,26 @@ type TEditer=class(TCustomcontrol) // end function DoControlAlign();override; // begin - if not(FPageEditer and FPageEditer.parent=self)then return; + if not(FPageEditer and FPageEditer.parent=self) then return; + rr := ClientRect; r := rr; + codemapin := false; + if FinCodemap and not(FinCodemap.WSpOPUp)and FinCodemap.Visible and FinCodemap.Parent=self then + begin + codemapin := min(FinCodemap.Width,integer(r[2] * 0.5)); + //FinCodemap.SetBoundsRect(r); + end if fcoolbar.Parent = self then begin htoolbar := true; end if htoolbar then - begin - //th := FToolbar.CalcHeightFixWidth(rr[2]-rr[0]); - //r[3]:= r[0]+th; - //FToolBar.SetBoundsRect(r); - - fcoolbar.DoControlAlign(); - - r[3]:= r[0]+fcoolbar.Height; - fcoolbar.SetBoundsRect(r); + begin + fcoolbar.DoControlAlign(); + r[3]:= r[0]+fcoolbar.Height; + r[0]+=codemapin+2; + fcoolbar.SetBoundsRect(r); end r := rr; r[1]:= r[3]-FStatus.Height; @@ -3135,29 +3153,24 @@ type TEditer=class(TCustomcontrol) // rr := rr; if htoolbar then begin - rr[1]:= fcoolbar.Height+1; + rr[1]:= fcoolbar.Height+1; end rr[3]:= rr[3]-FStatus.Height-1; - {if ffolderdlg and ffolderdlg.Visible then - begin - r := rr; - fwd := min(ffolderdlg.Width,integer(r[2] * 0.6)); - r[2] := r[0]+fwd; - rr[0] := r[2]+1; - ffolderdlg.SetBoundsRect(r); - end } if FInfoShowWnd.Visible and not(FInfoShowWnd.WSpOPUp)then begin - r := rr; - + r := rr; r[1]:= r[3]-min(FInfoShowWnd.Height,integer(r[3] * 0.8)); //0.6 0.8 rr[3]:= r[1]-1; - - {fwd := min(FInfoShowWnd.Width,integer(r[2] * 0.6)); //Ҳ - r[0] := r[2]-fwd; - rr[2] := r[0]-1;} FInfoShowWnd.SetBoundsRect(r); end + if codemapin then + begin + r := rr; + r[1] := 1; + r[2] := codemapin; + rr[0] := codemapin+2; + FinCodemap.SetBoundsRect(r); + end FPageEditer.SetBoundsRect(rr); end function CreateAFile(); //ļ @@ -3337,8 +3350,12 @@ type TEditer=class(TCustomcontrol) // end ord("M"): begin - InitShowWndPos(FCodeMap,"cm",250,100); - FCodeMap.ShowMap(); + //InitShowWndPos(FCodeMap,"cm",250,100); + //FCodeMap.ShowMap(); + if FinCodemap and not(FinCodemap.Visible) then + begin + FinCodemap.doshow(1); + end e.skip := true; return true; end @@ -3422,6 +3439,7 @@ type TEditer=class(TCustomcontrol) // begin it.FEditer.ChangedFlag := true; end + if FinCodemap then FinCodemap.ontimerdo(); return true; end end @@ -3561,7 +3579,7 @@ type TEditer=class(TCustomcontrol) // FOnPageEditerChanged := nil; fOnPageItemSelChanged := nil; FListPages := nil; - FCodeMap := nil; + FinCodemap := nil; FEchoWnd := nil; FFindListWnd := nil; FTempPageItem := nil; @@ -4095,7 +4113,8 @@ type TEditer=class(TCustomcontrol) // FToolbar; FStatus; FInfoShowWnd; - FCodeMap; + //FCodeMap; + FinCodemap; FListPages; FFindWnd; FFindListWnd; @@ -4833,7 +4852,278 @@ type TEditerEchoWnd=class(TSynMemoNorm) // FDoLockTime; F_Highlighter; end - +type tfincodemap = class(tcustomcontrol) + function create(AOwner); + begin + inherited; + Visible := false; + FTempNodes := array(); + Width := 230; + Ftimer := new TTimer(self); + Ftimer.Interval := 200; + Ftimer.Ontimer := thisfunction(BdownTimeOut); + Ftimer.Enabled := false; + + FList := new TCombobox(self); + flist.Width := 180; + ar := array("Class","Function","Statements","If","Else","SubCase","Goto","Try","Empty_Begin_End","NeedSql","Unit","property","Member"); + flist.Multisel := true; + FList.AppendItems(ar); + flist.ItemIndex := 0->(length(ar)-1); + FList.Parent := self; + initbtn(); + FTree := new TTreeView(self); + FTree.OnSelChanged := thisfunction(SynNodeSelected); + FTree.Parent := self; + end + function caretchanged(y); + begin + if fisloading then return ; + fissetnode := true; + GoToTheNode(y); + fissetnode := false; + end + function DoControlAlign();override; + begin + if FList and fcbtn and FTree and ffbtn then + begin + rr := ClientRect; + ffbtn.left := 1; + r := rr; + r[0] := 25; + r[2] := min(200,r[2]-55); + r[3] := 25; + FList.SetBoundsRect(r); + fcbtn.left := rr[2]-25; + r := rr; + r[1]:= 27; + r[0]:=1; + r[2]:=r[2]-3; + FTree.SetBoundsRect(r); + end + end + function doshow(f); //ʾ + begin + st := f?true:false; + Visible := st; + BdownTimeOut(); + if st then + begin + ontimerdo(); + //FTree.SetFocus(); + end + end + function SynNodeSelected(o,e); + begin + if fisloading then return ; + if fissetnode then return ; + edt := geteditor(); + if not edt then return; + nd := FTree.CurrentNode; + if not nd then return ; + line := nd._tag; + if line>0 then + begin + edt.ExecuteCommand(edt.ecGoToXY,array(line,1)); + end + end + function hasFocus();override; + begin + return true; + end + function ontimerdo(o,e); + begin + { + #define Block_TypeClass 1 + #define Block_Function 2 + #define Block_Statements 4 + #define Block_If 8 + #define Block_Else 16 + #define Block_SubCase 32 + #define Block_Goto_Label 64 + #define Block_Empty_Begin_End 128 + #define Block_Try 256 + #define Block_NeedSql 512 + #define Block_UnitStruct 1024 + } + // ߼ + //ʱڵ,ı,λڵ㵽ǰλ + //λñ仯,=== λڵ + //ڵѡжλ ༭ + //if Parent then o.Enabled := false; + if not Visible then return ; + if not FTree then return ; + edt := geteditor(); + nd := FTree.RootNode; + if not edt then return nd.RecyclingChildren(); + y := edt.CaretY; + s := edt.Text; + if FString = s then //ıû + begin + if flistv=getblocktypes() then //û + begin + return ; + end + end else + FString := s; + flistv := getblocktypes(); + if s then r := tsl_tokenizeex_2_(s,flistv); + else r := array(); + fisloading := true; + nd.RecyclingChildren(); + FTempNodes := array(); + ScriptDelBlocks(r["blcks"],str2array(s,"\r\n"),nd,0); + GoToTheNode(y); + fisloading := false; + end + function WMNCLBUTTONDOWN(o,e):WM_NCLBUTTONDOWN;override; + begin + FIgnoreSize := true; + Ftimer.Enabled := true; + end + function BdownTimeOut(o,e); //ʱ + begin + if(_wapi.GetAsyncKeyState(VK_LBUTTON).& 0xFF00)>0 then + begin + end else + begin + FIgnoreSize := false; + Ftimer.Enabled := false; + p := Parent; + if p then p.DoControlAlign(); + end + end + + private + function GoToTheNode(line); + begin + nd := FTempNodes[0]; + for i,v in FTempNodes do + begin + if v._tag <= line then + begin + nd := v; + end else + if v._tag >= Line then + begin + FTree.SetSel(nd); + break; + end + end + end + function ScriptDelBlocks(blcks,strs,Node,ct); + begin + if not blcks then return; + for i,v in blcks do + begin + if v["mtype"]<> 1 then + begin + cnd := FTree.CreateTreeNode(); + cnd.Caption := trim(strs[v["mbeg"]-1]); + cnd._tag := v["mbeg"]; + FTempNodes[length(FTempNodes)]:= cnd; + cnd.parent := node; + end + if not cnd then cnd := node; + ScriptDelBlocks(v["msub"],strs,cnd,ct+1); + end + end + function getblocktypes(); + begin + r := 0; + for i,v in FList.itemindex do + begin + r += 2^v; + end + return r; + end + function initbtn(); + begin + fcbtn := new TBtn(self); + fcbtn.OnClick := function(o,e) + begin + doshow(0); + end + fcbtn.Caption := ""; + fcbtn.top := 3; + fcbtn.Width := 20; + fcbtn.Height := 20; + fcbtn.Parent := self; + s := "0502000000060400000074797065000203000000696D670006040000006461746 +10002C401000089504E470D0A1A0A0000000D4948445200000014000000140806 +0000008D891D0D000000017352474200AECE1CE90000000467414D410000B18F0 +BFC6105000000097048597300000EC300000EC301C76FA8640000015949444154 +384F9D9431CA83401085F7625E21E015BC8156D639809D95AD36C142248568ED0 +93C8277B0B0D99F4F32B2EB8EE1270F1EAC3B6FBE85901963156DDB66C771B455 +55D93CCF6D1CC7873973478D8CA600B82C8B4D92C44651F4D564C85EE501BBAE5 +39BBF991E5727709E67B5E13FA6577400D775F502455178DF9AAF19180770DF77 +9BA6A917444DD3780DAEA921170A03961986C10B636968DB36A87187B4076199B +22C830296C6F7FB7DDE7146DA431896C9B24C2D6201F0BFC3C87DE06A58E6F178 +A845B18010672D2386659800AD289EA6E983B3C759CB886119C6492BE2BEEF4F9 +080B9D3B218966136B5E2EBF50A00F20035372B8665B4DFA5AEEBDB467988CCB5 +06CBB035DC65F07C3E6F1BC4F22059B98301EB183DB686DBE006EF7CCDC8E6399 +7C32F9B46EC6E1C6F7DFDB271DC4D833C20626BB8CBE2CE6464C3B80A8088ADC1 +A0339B8C1313803973478D4C286BFF00D135DFBA6F19E4A90000000049454E44A +E42608200"; + bmp := new TBitmap(); + bmp.ReadVcon(HexformatStrToTsl(s)); + fcbtn.BKBitmap := bmp; + ffbtn := new TBtn(self); + ffbtn.OnClick := function(o,e) + begin + //doshow(1); + ontimerdo(); + end + ffbtn.Caption := ""; + ffbtn.top := 3; + ffbtn.Width := 20; + ffbtn.Height := 20; + ffbtn.Parent := self; + s := "0502000000060400000074797065000203000000696D670006040000006461746 +100029C01000089504E470D0A1A0A0000000D4948445200000014000000140806 +0000008D891D0D000000017352474200AECE1CE90000000467414D410000B18F0 +BFC6105000000097048597300000EC300000EC301C76FA8640000013149444154 +384FBD940D8D834010464F10064000064000180001200004A0000318000128C00 +0063030CD9B63B62D85CB5ED3F42513C8EEEC373F3BF0231FE67B82EBBA4ADBB6 +92A6A90441A0C67B5DD732CFF3EEF5CAA960DFF72A1086A15455255DD7A9F11EC +7B1EE956529DBB6ED27EE3C099215360C83DAD9012020C1C8F8E8A382E338BAD2 +78FAB02C8B8AE679BEAFFCA2824551489224AE5764E90355E0FFD85357323D222 +23DC2D117FC49C87082599669D3C9EEAA7767344DA3591A4E9045B2FC2F9CF98E +209742D9BE585B6C360D2768BDF0BD6184B88C63654E102136F9027CB091C1984 +51375826059F2BDFAC098E14FAB18747812044AB1A8D334EDAB7758638FE00CF4 +B1452F8240FA163D8A221578FCEBB07735FCA782C02D7288C653920D3E6B7F0DF +EA5E0BB7C5850E4063EDA83420076B5E10000000049454E44AE42608200"; + bmp := new TBitmap(); + bmp.ReadVcon(HexformatStrToTsl(s)); + ffbtn.BKBitmap := bmp; + end + function geteditor(); + begin + if not owner then return 0; + it := Owner.GetCurrentItem(); + edit := it.FEditer; + if not edit then return 0; + m := edit.HighLighter ; + if not(m is class(TTslSynHighLighter)) then + begin + return 0; + end + return edit; + + end + fissetnode; + fisloading; + ffbtn; + FTempNodes; //ڵ + FTree; + fcbtn; + FList; + flistv; + Ftimer; + Ftimer2; + FString; +end +(* type TTslCodeMap=class(TTreeView) //tslͼ function Create(AOwner); begin @@ -4971,7 +5261,7 @@ type TTslCodeMap=class(TTreeView) //tsl FTempNodes; //ڵ FString; //ַ FTreeEditer; //༭ -end +end *) type TListPages=class(TListBox) function Create(AOwner);override; begin @@ -5026,7 +5316,7 @@ type TListPages=class(TListBox) SetYpos(1+GetYPos()+(rc[3]-c[3]+1)/GetYScrollDelta()); end end - function GetSelFileName; + function GetSelFileName(); begin r := GetItem(getCurrentSelection()); if pos("*",r)then diff --git a/funcext/tvclib/ugtkinterface.tsf b/funcext/tvclib/ugtkinterface.tsf index 59dd38a..488be6e 100644 --- a/funcext/tvclib/ugtkinterface.tsf +++ b/funcext/tvclib/ugtkinterface.tsf @@ -6164,12 +6164,12 @@ type tgtk_ctl_scroll_window = class(tgtk_ctl_object) scrlsize := 12; if (fbarshow .& 1)=1 then //v begin - _wapi.gtk_widget_set_size_request(FHscrollbar,w-scrlsize,scrlsize); - end else _wapi.gtk_widget_set_size_request(FHscrollbar,w,scrlsize); + _wapi.gtk_widget_set_size_request(FHscrollbar,max(0,w-scrlsize),scrlsize); + end else _wapi.gtk_widget_set_size_request(FHscrollbar,max(0,w),scrlsize); if (fbarshow .& 2)=2 then //h begin - _wapi.gtk_widget_set_size_request(Fvscrollbar,scrlsize,h-scrlsize); - end else _wapi.gtk_widget_set_size_request(Fvscrollbar,scrlsize,h); + _wapi.gtk_widget_set_size_request(Fvscrollbar,scrlsize,max(0,h-scrlsize)); + end else _wapi.gtk_widget_set_size_request(Fvscrollbar,scrlsize,max(0,h)); _wapi.gtk_layout_move( FLayouter,FHscrollbar,0,h-scrlsize); _wapi.gtk_layout_move( FLayouter,Fvscrollbar,w-scrlsize,0); if FClientWideget then @@ -6182,7 +6182,7 @@ type tgtk_ctl_scroll_window = class(tgtk_ctl_object) begin w-=11; end - _wapi.gtk_widget_set_size_request(FClientWideget,w,h); + _wapi.gtk_widget_set_size_request(FClientWideget,max(0,w),max(0,h)); //inherited widgetsizechanged(h,w); end //else inherited widgetsizechanged(h,w); inherited widgetsizechanged(h,w); //clientrect diff --git a/funcext/tvclib/utslvclauxiliary.tsf b/funcext/tvclib/utslvclauxiliary.tsf index 612f600..b68d2df 100644 --- a/funcext/tvclib/utslvclauxiliary.tsf +++ b/funcext/tvclib/utslvclauxiliary.tsf @@ -2265,7 +2265,7 @@ implementation function iffuncptr(fn); begin //return datatype(fn)=7; - return ifobj(fn); + return fn and ifobj(fn); end function includestate(u,s); begin