编辑器
添加js文件语法支持
This commit is contained in:
@@ -638,6 +638,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
|
||||
@explan(说明) 带滚动条的编辑控件 %%
|
||||
**}
|
||||
private
|
||||
FSymchars;
|
||||
[weakref]fongutterclick;//点击
|
||||
ftmemlockv;
|
||||
fundoing; //清空unredo标记
|
||||
@@ -1014,6 +1015,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
|
||||
function Create(AOwner);override;
|
||||
begin
|
||||
inherited;
|
||||
FSymchars := array();
|
||||
ftmemlockv := new tcountkernel();
|
||||
FGutterColor := rgb(228,228,228);
|
||||
fcurrentLineColor := rgb(232,232,255);
|
||||
@@ -1296,6 +1298,26 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
|
||||
IncPaintLock();
|
||||
try
|
||||
case cmd of
|
||||
"symchars":
|
||||
begin
|
||||
if ifstring(data) then
|
||||
begin
|
||||
FSymchars := array();
|
||||
for i := 1 to length(data) do
|
||||
begin
|
||||
vi := data[i];
|
||||
if vi= "\t" or vi="\r" or vi="\n" or vi="\b" then
|
||||
begin
|
||||
continue;
|
||||
end
|
||||
FSymchars[vi] := true;
|
||||
end
|
||||
return ;
|
||||
end
|
||||
r := "";
|
||||
for i,v in FSymchars do r+=i;
|
||||
return r;
|
||||
end
|
||||
"ecruningto":
|
||||
begin
|
||||
if Fecruningto <> data then
|
||||
@@ -1673,12 +1695,13 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
|
||||
begin
|
||||
cx--;
|
||||
vi := s[cx];
|
||||
if FSymchars[vi] then continue;
|
||||
ivi := ord(vi);
|
||||
{if (ivi<=0x2f) or (ivi>122 and ivi<=127) then
|
||||
begin
|
||||
ci++;
|
||||
break;
|
||||
end }
|
||||
end }
|
||||
if(ivi<48)or(ivi>57 and ivi<65)or(ivi>90 and ivi<95)or(ivi>95 and ivi<97)or(ivi>122 and ivi <= 127)then
|
||||
begin
|
||||
ci++;
|
||||
@@ -1702,6 +1725,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
|
||||
while cx <= ls do
|
||||
begin
|
||||
vi := s[cx];
|
||||
if FSymchars[vi] then continue;
|
||||
ivi := ord(vi);
|
||||
//if (ivi<=0x2f) or (ivi>122 and ivi<=127) then break;
|
||||
if(ivi<48)or(ivi>57 and ivi<65)or(ivi>90 and ivi<95)or(ivi>95 and ivi<97)or(ivi>122 and ivi <= 127)then break;
|
||||
@@ -3114,8 +3138,10 @@ type tcustomsynhighlighter = class(TSynHighLighter)
|
||||
fsymcolor := 0xa000a0;
|
||||
fnumbercolor := 0x666666;
|
||||
fkeywordcolor := 0x0000ff;
|
||||
fsysfuncolor := 0xff0000;
|
||||
fstringcolor := 0xff00ff;
|
||||
fannotationcolor := 0xff0000;
|
||||
//fannotationcolor := 0xff0000;
|
||||
fannotationcolor := 0xaa3300;
|
||||
fignorecase := false;//忽略大小写
|
||||
FChangeDeal := true;
|
||||
FTokens := array();
|
||||
@@ -3134,6 +3160,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
|
||||
("[","]"),
|
||||
("{","}"),
|
||||
));
|
||||
setsysfun(array());
|
||||
clean();
|
||||
end
|
||||
function ExecuteCommand(cmd,pm);override;
|
||||
@@ -3164,6 +3191,10 @@ type tcustomsynhighlighter = class(TSynHighLighter)
|
||||
begin
|
||||
return setsyms(pm);
|
||||
end
|
||||
"sysfun":
|
||||
begin
|
||||
return setsysfun(pm);
|
||||
end
|
||||
"pairs":
|
||||
begin
|
||||
return setpairs(pm);
|
||||
@@ -3221,6 +3252,10 @@ type tcustomsynhighlighter = class(TSynHighLighter)
|
||||
if ifkeywords(bttk) then
|
||||
begin
|
||||
d.FFColor := fkeywordcolor;
|
||||
end else
|
||||
if ifsysfun(bttk) then
|
||||
begin
|
||||
d.FFColor := fsysfuncolor ;
|
||||
end
|
||||
dopair(d,bttk);
|
||||
end else
|
||||
@@ -3256,6 +3291,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
|
||||
inherited;
|
||||
end
|
||||
property keywordcolor:color read fkeywordcolor write fkeywordcolor;
|
||||
property sysfuncolor:color read fsysfuncolor write fsysfuncolor;
|
||||
property stringcolor:color read fstringcolor write fstringcolor;
|
||||
property annotationcolor:color read fannotationcolor write fannotationcolor;
|
||||
property symcolor:color read fsymcolor write fsymcolor;
|
||||
@@ -3273,6 +3309,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
|
||||
fblockstiresa,
|
||||
fblockstiresb,
|
||||
frowstires,
|
||||
fsysfuntires,
|
||||
fsymstires) do
|
||||
begin
|
||||
for j,vj in v do
|
||||
@@ -3352,7 +3389,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
|
||||
SetTToken(tokens,ttk,idx-1);
|
||||
bostr := ostr;
|
||||
ncost := array("annote",bostr,fblockstiresb[bostr]);
|
||||
SetTToken(tokens,ostr,oidx-1);
|
||||
SetTToken(tokens,ostr,oidx-1,array("annote"));
|
||||
idx := oidx-1;
|
||||
return ParserTokenLines(s,idx+1,e,ncost,tokens);
|
||||
end else
|
||||
@@ -3470,6 +3507,18 @@ type tcustomsynhighlighter = class(TSynHighLighter)
|
||||
end
|
||||
end
|
||||
end
|
||||
function setsysfun(d);//设置系统函数
|
||||
begin
|
||||
st := new TTire();
|
||||
fsysfuntires := array(st);
|
||||
for i,v in d do
|
||||
begin
|
||||
if ifstring(v) and v then
|
||||
begin
|
||||
st.add(v);
|
||||
end
|
||||
end
|
||||
end
|
||||
function setsyms(d);//设置符号
|
||||
begin
|
||||
st := new TTire();
|
||||
@@ -3543,6 +3592,14 @@ type tcustomsynhighlighter = class(TSynHighLighter)
|
||||
return true;
|
||||
end
|
||||
end
|
||||
function ifsysfun(s);//系统函数判断
|
||||
begin
|
||||
for i,v in fsysfuntires do
|
||||
begin
|
||||
if v.find(s,length(s),1,idx,ostr) and (ostr=s) then
|
||||
return true;
|
||||
end
|
||||
end
|
||||
function ifdefsym(s,l,idx,oidx,ostr,tidx); //符号判断
|
||||
begin
|
||||
return cyclefind(fsymstires,s,l,idx,oidx,ostr,tidx);
|
||||
@@ -3588,11 +3645,13 @@ type tcustomsynhighlighter = class(TSynHighLighter)
|
||||
fstrstires;
|
||||
fstrstires_zy;
|
||||
fsymstires;
|
||||
fsysfuntires;
|
||||
frowstires;
|
||||
fblockstiresa;
|
||||
fblockstiresb;
|
||||
/////
|
||||
fkeywordcolor;
|
||||
fsysfuncolor;
|
||||
fstringcolor;
|
||||
fannotationcolor;
|
||||
fsymcolor;
|
||||
@@ -3762,9 +3821,9 @@ type TSynCustomMemo = class(TCustomMemo)
|
||||
s := s.FStr;
|
||||
for i:= b[1] to e[1]-1 do
|
||||
begin
|
||||
ivi := ord(s[i]);
|
||||
if(ivi<48) or (ivi>57 and ivi<65) or (ivi>90 and ivi<95) or(ivi>95 and ivi<97) or(ivi>122 and ivi<=127) then continue;
|
||||
r+=s[i];
|
||||
ivi := ord(s[i]);
|
||||
if(ivi<48) or (ivi>57 and ivi<65) or (ivi>90 and ivi<95) or(ivi>95 and ivi<97) or(ivi>122 and ivi<=127) then continue;
|
||||
r+=s[i];
|
||||
end
|
||||
except
|
||||
r := "";
|
||||
|
||||
Reference in New Issue
Block a user