diff --git a/designer/utslcodeeditor.tsf b/designer/utslcodeeditor.tsf index 8b6af93..294e34f 100644 --- a/designer/utslcodeeditor.tsf +++ b/designer/utslcodeeditor.tsf @@ -4903,7 +4903,6 @@ type tfincodemap = class(tcustomcontrol) if e.charcode=13 then begin et := geteditor(); - echo ">>>enter\r\n"; if et then et.SetFocus(); end end diff --git a/funcext/tvclib/utslmemo.tsf b/funcext/tvclib/utslmemo.tsf index 5751369..1235027 100644 --- a/funcext/tvclib/utslmemo.tsf +++ b/funcext/tvclib/utslmemo.tsf @@ -70,6 +70,7 @@ TYPE TMemoLineList=class(tnumindexarray) // begin if(Flock)then begin + //echo "+++\r\n"; FEdit.UpDateScroll(); end end @@ -650,8 +651,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // FSetPostioned; //位置改变 FIsCaretShow; //光标可见 fcaretcreated; //光标已经构造成功 - fForceCaret; - fcaretcout; //列选择时候的caret count + fForceCaret; FCharsInWindow; // fTextHeight; //行高 fLinesInWindow; //能显示的行数 @@ -839,7 +839,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // r[1]:= RC[1]+fTextHeight * iy; iy++; r[3]:= r[1]+fTextHeight; - if i+1=fCaretY then //当前行 + if i+1=fCaretY then begin if Color<>fcurrentLineColor then begin @@ -856,19 +856,6 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // if FSelectionMode=smLine then begin end else - if FSelectionMode=smColumn then - begin - a1 := min(bb[1],ee[1]); - a2 := max(bb[1],ee[1]); - if a1=e2 then - begin - src := array(0,0,0,0); - end else - begin - src[0]+= fCharWidth *(a1-1); - src[2]:= src[0]+fCharWidth *(a2-a1); - end - end else begin if bb[0]=ee[0]then //同一行 begin @@ -1255,8 +1242,8 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // end if not s then return; bb := array(fCaretY,fCaretX); - r := buffer_InsertChars(bb,ee,s,FSelectionMode); - fUndoList.AddChange(crInsert,bb,r,s,FSelectionMode); + r := buffer_InsertChars(bb,s); + fUndoList.AddChange(crInsert,bb,r,s,0); SetCaretXY(r); UpdateCaret(); memtextchanged(bb); @@ -1453,19 +1440,22 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // begin nx := 1; //////////////20230323 回到非空白行首///////////////////////////////// - s := fLines.GetStringByIndex(fCaretY-1); //[fCaretY-1]; - if ifstring(s) and s then - begin - for i := 1 to length(s) do + if FSelectionMode=smNormal then + begin + s := fLines.GetStringByIndex(fCaretY-1); //[fCaretY-1]; + if ifstring(s) and s then begin - vi := s[i]; - if vi<>" " or vi="\t" then + for i := 1 to length(s) do begin - nx := i; - if fCaretX = nx then nx := 1; - break; - end - end + vi := s[i]; + if vi<>" " or vi="\t" then + begin + nx := i; + if fCaretX = nx then nx := 1; + break; + end + end + end end ////////////////////////////// MoveCaretAndSelection(array(fCaretY,fCaretX),array(fCaretY,nx),ecSelLineStart=cmd); @@ -1594,9 +1584,8 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // end function MoveCaretAndSelection(p1,p2,sel);//移动选择 begin - if not(ifarray(p2)and ifarray(p1)and p2[0]>= 1 and p2[1]>= 1)then return; + if not(ifarray(p2)and ifarray(p1)and p2[0]>= 1 and p2[1]>= 1)then return; SetCaretXY(p2); - IncPaintLock(); if Sel then begin @@ -1615,21 +1604,10 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // ed := GetBlockEnd()[0]; InvalidateLines(bg,ed); end - if FSelectionMode=smColumn then - begin - if fBlockBegin then fBlockBegin[1] := caretxy[1]; - fBlockEnd := CaretXY; - end else - begin - fBlockBegin := CaretXY; - fBlockEnd := CaretXY; - end + fBlockBegin := CaretXY; + fBlockEnd := CaretXY; end - if FSelectionMode=smColumn and P2[0]<>P1[0] then - begin - ReCreateCaret(); - end else - UpDateCaret(); + UpDateCaret(); DecPaintLock(); end published @@ -1677,7 +1655,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // begin if fCaretX >= fLeftChar and(fCaretX FSelectionMode)and(v in array(smNormal,smLine,smColumn))then FSelectionMode := v; + if(v <> FSelectionMode)and(v in array(smNormal,smLine))then FSelectionMode := v; end function MoveCaretHorz(stp,sel); begin @@ -2022,15 +2000,9 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // crDelete: begin //插入 - if item.FSelMode = smColumn then - begin - - end - else - begin - SetCaretXY(item.FStartPos); - InsertChars(item.FStr); - end + SetCaretXY(item.FStartPos); + InsertChars(item.FStr); + //echo tostn(item); end end end @@ -2250,7 +2222,42 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // if not GetSelAvail()then return r; bb := GetBlockBegin(); ee := GetBlockEnd(); - r := buffer_getchars(bb,ee,FSelectionMode); + if FSelectionMode=smLine then + begin + len := ee[0]; + for i := bb[0]to ee[0] do + begin + r += fLines[i-1].FStr; + if ibb[1]and ee[1]>1 then + try + r := s[bb[1]:ee[1]-1]; //可能出错,添加try + except + r := ""; + end; + end else + begin + //第一行 + s := fLines[bb[0]-1].FStr; + if bb[1]<= length(s)then r += s[bb[1]:]; + r += "\r\n"; + //中间 + for i := bb[0]to ee[0]-2 do + begin + r += fLines[i].FStr; + r += "\r\n"; + end + //最后一行 + s := fLines[ee[0]-1].FStr; + if s and ee[1]>1 then r += s[1:ee[1]-1]; + end + end return r; end function SetCaretX(cx); @@ -2285,9 +2292,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // end function GetSelAvail(); begin - r := fBlockBegin <> fBlockEnd and fBlockBegin and fBlockEnd; - if FSelectionMode=smColumn then return fBlockBegin[1]<>fBlockEnd[1]; - return r; + return fBlockBegin <> fBlockEnd and fBlockBegin and fBlockEnd; end function SelectNextChar(); //选取后一个字符 begin @@ -2325,7 +2330,6 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // end else if fCaretY>1 then begin - //if FSelectionMode=smColumn then return ; s := fLines.GetStringByIndex(fCaretY-2); fBlockEnd := array(CaretY-1,length(s)+1); end @@ -2338,15 +2342,27 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // IncPaintLock(); ee := GetBlockEnd(); bb := DeleteSel(); + up := false; + if bb[0]=ee[0]then + begin + //InvalidateLines(bb[0],bb[0]); + end else + begin + up := true; + end if v then begin - bb2 := buffer_InsertChars(bb,ee,v,FSelectionMode); - fUndoList.AddChange(crInsert,bb,bb2,v,FSelectionMode); + bb2 := buffer_InsertChars(bb,v); + fUndoList.AddChange(crInsert,bb,bb2,v,0); fUndoList.MergeReplaceItem(); fBlockEnd := bb2; + if bb2[0]<> bb[0]then up := true; end else - bb2 := bb; + bb2 := bb; ExecuteCommand(ecGotoXY,bb2); + //SetCaretXY(bb2); + //if up then UpDateScroll(); + //UpDateCaret(); DecPaintLock(); memtextchanged(bb); end @@ -2357,13 +2373,13 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // if not GetSelAvail()then return 0; bb := GetBlockBegin(); ee := GetBlockEnd(); - if FSelectionMode= smLine then + if FSelectionMode=smLine then begin bb[1]:= 1; ee[1]:= fLines[ee[0]-1].StrLength()+1; - end - fUndoList.AddChange(crDelete,bb,ee,GetSelText(),FSelectionMode); - buffer_DeleteChars(bb,ee,FSelectionMode); + end + fUndoList.AddChange(crDelete,bb,ee,GetSelText(),0); + buffer_DeleteChars(bb,ee); fBlockBegin := fBlockEnd := bb; return bb; end @@ -2407,16 +2423,8 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // function CreateCaret(); //构造光标 begin if FReadOnly then return; - if fcaretcreated then return; + if fcaretcreated then return; h := Font.Height; - if FSelectionMode=smColumn then - begin - if fBlockBegin and fBlockEnd then - begin - fcaretcout := max(abs(fBlockBegin[0]-fBlockEnd[0])+1,1); - if fcaretcout>1 then h := fTextHeight*fcaretcout; - end - end hd := Handle; _wapi.CreateCaret(hd,nil,1,h); _wapi.ShowCaret(hd); @@ -2432,144 +2440,30 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) // fcaretcreated := false; FIsCaretShow := false; end - FHasFocus; + FHasFocus; //buffer 处理 - function buffer_getchars(bb,ee,sm);//获得 - begin - r := ""; - case FSelectionMode of - smLine: - begin - for i := bb[0] to ee[0] do - begin - r += fLines[i-1].FStr; - r += "\r\n"; - end - end - smColumn: - begin - len := ee[0]; - a1 := min(bb[1],ee[1]); - a2 := max(bb[1],ee[1]); - if a1=a2 then return r; - for i := bb[0] to ee[0] do - begin - ri := fLines[i-1].FStr; - lri := length(ri); - a22 := min(a2-1,lri); - if lri then - begin - if bytetype(ri,a1)=2 then - begin - a11 := a1+1; - end else - begin - a11 := a1; - end - if bytetype(ri,a22)=1 then - begin - a22-=1; - end - if a11<=a22 then r+=ri[a11:a22]; - end - if ibb[1]and ee[1]>1 then - try - r := s[bb[1]:ee[1]-1]; //可能出错,添加try - except - r := ""; - end; - end else - begin - //第一行 - s := fLines[bb[0]-1].FStr; - if bb[1]<= length(s)then r += s[bb[1]:]; - r += "\r\n"; - //中间 - for i := bb[0]to ee[0]-2 do - begin - r += fLines[i].FStr; - r += "\r\n"; - end - //最后一行 - s := fLines[ee[0]-1].FStr; - if s and ee[1]>1 then r += s[1:ee[1]-1]; - end - end - - end - return r; - end - function buffer_DeleteChars(bb,ee,sm); //删除选择 + function buffer_DeleteChars(bb,ee); //删除选择 begin if bb=ee then return; - case sm of - smLine: - begin - fLines.splices(bb[0]-1,max(1,ee[0]-bb[0]+1),array()); - end - smColumn: - begin - a1 := min(bb[1],ee[1]); - a2 := max(bb[1],ee[1]); - if a1=a2 then return r; - for i := bb[0] to ee[0] do - begin - ri := fLines.GetStringByIndex(i-1); - lri := length(ri); - a22 := min(a2-1,lri); - if lri then - begin - if bytetype(ri,a1)=2 then - begin - a11 := a1+1; - end else - begin - a11 := a1; - end - if bytetype(ri,a22)=1 then - begin - a22-=1; - end - if a11<=a22 then - begin - ri[a11:a22]:=""; - fLines.SetValueByIndex(i-1,ri); - end - end - end - - end - smNormal: - begin - if bb[0]=ee[0]then //删除一行中的 - begin - str := fLines.GetStringByIndex(bb[0]-1); - str[bb[1]:ee[1]-1]:= ""; - fLines.SetValueByIndex(bb[0]-1,str); - end else //多行 - begin - //删除后半 - str := fLines.GetStringByIndex(bb[0]-1); - if str and length(str)>= bb[1]then str[bb[1]:]:= ""; - //删除前半 - str2 := fLines.GetStringByIndex(ee[0]-1); - if ee[1]>1 and str2 then str2[1:ee[1]-1]:= ""; - fLines.SetValueByIndex(bb[0]-1,str+str2); - //删除中间 - fLines.splices(bb[0],ee[0]-bb[0],array()); - end - end - end + if bb[0]=ee[0]then //删除一行中的 + begin + str := fLines.GetStringByIndex(bb[0]-1); + str[bb[1]:ee[1]-1]:= ""; + fLines.SetValueByIndex(bb[0]-1,str); + end else //多行 + begin + //删除后半 + str := fLines.GetStringByIndex(bb[0]-1); + if str and length(str)>= bb[1]then str[bb[1]:]:= ""; + //删除前半 + str2 := fLines.GetStringByIndex(ee[0]-1); + if ee[1]>1 and str2 then str2[1:ee[1]-1]:= ""; + fLines.SetValueByIndex(bb[0]-1,str+str2); + //删除中间 + fLines.splices(bb[0],ee[0]-bb[0],array()); + end end - function buffer_InsertChars(cxy,ee,str,sm); //插入 + function buffer_InsertChars(cxy,str); //插入 begin if not(ifstring(str)and str)then return; ss := str2array(str,"\n"); diff --git a/funcext/tvclib/utslvclcef.tsf b/funcext/tvclib/utslvclcef.tsf index 4703520..4a60f7b 100644 --- a/funcext/tvclib/utslvclcef.tsf +++ b/funcext/tvclib/utslvclcef.tsf @@ -2405,9 +2405,7 @@ type cef_life_span_handler_t=class(cef_contain_base) no_javascript_access := no_javascript_accessi; return r; end - end - - + end /// /// Called on the UI thread before a new popup browser is created. The @@ -3743,6 +3741,35 @@ type cef_request_context_t=class(cef_contain_base) //property get_extension index "get_extension" read _getvalue_ write _setvalue_; //property get_media_router index "get_media_router" read _getvalue_ write _setvalue_; end +type cef_domvisitor_t=class(cef_contain_base) + private + function structdescribe();override; + begin + return array( + ("base","user",getbasestruct()), + ("visit","intptr",0)); + end + public + function create(ptr) + begin + inherited ; + end + /// + /// Method executed for visiting the DOM. The document object passed to this + /// function represents a snapshot of the DOM at the time this function is + /// executed. DOM objects are only valid for the scope of this function. Do + /// not keep references to or attempt to access any DOM objects outside the + /// scope of this function. + property visit read getcallpropertybyindex write setcallpropertybyindex; + procedure visit_i(sf:pointer;dom:pointer);stdcall; + begin + c := getcallback(functionname()); + if c then + begin + call(c,self(true),cef_object_get( dom,class(cef_domdocument_t))); + end + end +end type cef_cookie_visitor_t=class(cef_contain_base) private function structdescribe();override; @@ -3902,6 +3929,7 @@ type cef_delete_cookies_callback_t=class(cef_set_cookie_callback_t) if c then call(c,self(true),success); end end + type cef_cookie_t=class(cef_contain_base) private function structdescribe();override; @@ -5395,7 +5423,7 @@ begin end procedure cef_run_message_loop();external "libcef.dll" name "cef_run_message_loop"; procedure cef_do_message_loop_work();external "libcef.dll" name "cef_do_message_loop_work"; -function cef_execute_process(arg:pointer;app:pointer;dow:pointer):integer;cdecl;external "libcef.dll" name "cef_execute_process"; +function cef_execute_process(arg:pointer;app:pointer;dow:pointer):integer;cdecl;external "libcef.dll" name "cef_execute_process"; function getcefboundsstruct();