diff --git a/funcext/tvclib/tslvcl.tsf b/funcext/tvclib/tslvcl.tsf index 28ed44d..60f6568 100644 --- a/funcext/tvclib/tslvcl.tsf +++ b/funcext/tvclib/tslvcl.tsf @@ -1838,7 +1838,7 @@ type thighlighter= class(tcustomsynhighlighter) end function publishs();override; begin - return array("name","keywordcolor","symcolor","stringcolor","annotationcolor"); + return array("name","keywordcolor","symcolor","stringcolor","annotationcolor","ignorecase"); end end diff --git a/funcext/tvclib/utslmemo.tsf b/funcext/tvclib/utslmemo.tsf index eb18f06..d9762c8 100644 --- a/funcext/tvclib/utslmemo.tsf +++ b/funcext/tvclib/utslmemo.tsf @@ -3217,19 +3217,51 @@ type tcustomsynhighlighter = class(TSynHighLighter) property stringcolor:color read fstringcolor write fstringcolor; property annotationcolor:color read fannotationcolor write fannotationcolor; property symcolor:color read fsymcolor write fsymcolor; + property ignorecase:bool read fignorecase write setignorecase; private + function setignorecase(i); + begin + ni := i?true:false; + if ni<>FIgnoreCase then + begin + FIgnoreCase := ni; + for i,v in array(fstrstires , + fkeystires, + fblockstiresa, + fblockstiresb, + frowstires, + fsymstires) do + begin + for j,vj in v do + begin + vj.ignorecase := ni; + end + end + if fswordpairshashdata then + begin + td := fswordpairshashdata; + setpairs(td); + end + end + end function dopair(d,bttk); //处理配对信息 begin - n := fswordpairshash[bttk]; + if FIgnoreCase then + begin + lttk := lowercase(bttk); + end else + begin + lttk := bttk; + end + n := fswordpairshash[lttk]; if n then begin st := fcbgestate[n]; - if fswordpairs[n][1]=bttk then + if fswordpairs[n][1]=lttk then begin st.GetRight(); end else - begin - + begin st.GetLeft(); end d.FMATe := st.GetSate(); @@ -3399,17 +3431,24 @@ type tcustomsynhighlighter = class(TSynHighLighter) begin fswordpairs := array(); fswordpairshash := array(); + fswordpairshashdata := array(); for i,v in d do begin if not ifarray(v) then continue; v0 := v[0]; v1 := v[1]; + if FIgnoreCase then + begin + v0 := lowercase(v0); + v1 := lowercase(v1); + end if ifstring(v0) and ifstring(v1) and v0 and v1 then begin fswordpairs[v1,0]:= v0; fswordpairs[v1,1]:= v1; fswordpairshash[v0]:=v1; fswordpairshash[v1]:=v1; + fswordpairshashdata[i] := v; end end @@ -3505,6 +3544,7 @@ type tcustomsynhighlighter = class(TSynHighLighter) // fswordpairs; fswordpairshash; + fswordpairshashdata; end type TSynCustomMemo = class(TCustomMemo) diff --git a/funcext/tvclib/utslvclauxiliary.tsf b/funcext/tvclib/utslvclauxiliary.tsf index 743936f..21be06e 100644 --- a/funcext/tvclib/utslvclauxiliary.tsf +++ b/funcext/tvclib/utslvclauxiliary.tsf @@ -1637,19 +1637,23 @@ type TTire = class FChar; FSub; FEnd; + Ficase; function Create(v); begin FChar := v; FSub := array(); FEnd := false; + Ficase := false; end function Add(s); begin v0 := s[1]; + if Ficase then v0 := lowercase(v0); vsub := FSub[v0]; if not vsub then begin vsub := new TTireNode(v0); + vsub.Ficase := Ficase; FSub[v0] := vsub; end ls := length(s); @@ -1664,6 +1668,7 @@ type TTire = class begin if idx>slen then return FEnd; v0 := s[idx]; + if Ficase then v0 := lowercase(v0); vsub := FSub[v0]; if vsub then begin @@ -1671,7 +1676,29 @@ type TTire = class return vsub.Find(s,slen,idx); end return FEnd ; - end + end + function seticase(i); + begin + ni := i?true:false; + if ni<>Ficase then + begin + Ficase := ni; + for i,v in mrows(FSub,1) do + begin + vi := FSub[v]; + if ni then //忽略大小写 + begin + reindex(FSub,array(v:nil)); + FSub[lowercase(vi.FChar)] := vi; + end else //区分大小写 + begin + reindex(FSub,array(v:nil)); + FSub[vi.FChar] := vi; + end + vi.seticase(i); + end + end + end end function Add(s); begin @@ -1679,7 +1706,9 @@ type TTire = class end function Create(); begin + fignorecase := false; FRoot := new TTireNode(); + FRoot.Ficase := false; end function Find(s,slen,idx,outidx,ostr); begin @@ -1693,7 +1722,18 @@ type TTire = class idx := tid; return r; end - FRoot; + FRoot; + property ignorecase read fignorecase write setignorecase; + private + function setignorecase(i); + begin + ni := i?true :false; + if ni<>fignorecase then + begin + FRoot.seticase(ni); + end + end + fignorecase; end type tpairstate =class //括号状态 function Create(t);