编辑器

添加xml语法高亮
This commit is contained in:
JianjunLiu
2023-03-21 15:21:34 +08:00
parent 4a7e770bf9
commit c8d44c6756
4 changed files with 87 additions and 17 deletions
+34 -15
View File
@@ -3149,20 +3149,20 @@ type tcustomsynhighlighter = class(TSynHighLighter)
fregs := array();
setkeyword(array("null","true","false","goto","break","for","to","while","do"));
setblockannote(array(
("/*","*/"),
));
("/*","*/"),
));
setrowannote(array("//"));
setsyms(array("+","-","*","/",";","(",")","{","}",":"));
setstring(array(
("'","\\"),
('"',"\\"),
));
("'","\\"),
('"',"\\"),
));
setpairs(array(
("(",")"),
("[","]"),
("{","}"),
));
setsysfun(array());
("(",")"),
("[","]"),
("{","}"),
));
setsysfun(array());
clean();
end
function ExecuteCommand(cmd,pm);override;
@@ -3205,6 +3205,14 @@ type tcustomsynhighlighter = class(TSynHighLighter)
begin
return setregs(pm);
end
"getcurrentpairstate":
begin
if fcbgestate then
begin
return fcbgestate[pm];
end
return nil;
end
end ;
return inherited;
end
@@ -3243,7 +3251,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
FSatesCount := i+1;
FTokens[i]:= tks;
end
end
end
function GetLineTokens(idx);override;
begin
if idx<FSatesCount then return FTokens[idx];
@@ -3377,7 +3385,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
end
end
d.FMATe := st.GetSate();
end
end
end
function ParserTokenLines(s,b,e,cst,tokens); //解析字符
begin
@@ -3439,8 +3447,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
if b>e then return cst;
if ifarray(cst) and (cst[0]="str" or cst[0]="annote") then
begin
cst1 := cst[1];
cstL := length(cst1);
r := FindRightChar(cst[2],s,b,e,cst[3]);
if r=0 then //没找到
begin
@@ -3453,6 +3460,15 @@ type tcustomsynhighlighter = class(TSynHighLighter)
begin
Setttoken(tokens,s[b:r-1],r-1,cst);
end
if cst[0]="annote" then
begin
cstL := fblockstiresc[cst[1]];
end else
begin
cst1 := cst[1];
cstL := length(cst1);
end
Setttoken(tokens,s[r:(r-1+cstL)],(r-1+cstL),cst);
if r<e then
begin
@@ -3498,6 +3514,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
begin
fblockstiresa := array();
fblockstiresb := array();
fblockstiresc := array();
for i,v in d do
begin
if not ifarray(d) then continue ;
@@ -3510,7 +3527,8 @@ type tcustomsynhighlighter = class(TSynHighLighter)
fblockstiresa[v0] := st;
st := new TTire();
st.add(v1);
fblockstiresb[v0] := st;
fblockstiresb[v0] := st;
fblockstiresc[v0] := length(v1);
end
end
end
@@ -3680,6 +3698,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
frowstires;
fblockstiresa;
fblockstiresb;
fblockstiresc;
fregs;
/////
fkeywordcolor;
+13 -2
View File
@@ -1827,6 +1827,15 @@ type tpairstate =class //
FIndexs := array(0);
FIndex := 0;
FCstate := false;
FSubcount := array(0);
end
function subitemadd();
begin
FSubcount[FIndex]++;
end
function subitemcount();
begin
return FSubcount[FIndex];
end
function GetLeft();
begin
@@ -1837,9 +1846,9 @@ type tpairstate =class //
FIndex++;
FIndexs[FIndex]:=0;
end else //上一个非左括号
begin
begin
FIndexs[FIndex]++;
FSubcount[FIndex]:=0;
end
FState := true;
end
@@ -1886,6 +1895,7 @@ type tpairstate =class //
r.FCJ := FCJ;
r.FIndexs := FIndexs;
r.FIndex := FIndex;
r.FSubcount := FSubcount;
return r;
end
protected
@@ -1893,6 +1903,7 @@ type tpairstate =class //
FState;
FCJ;
FIndexs;
FSubcount;
FIndex;
FType;