parent
2265e8fe3d
commit
023c4eb967
|
|
@ -1811,6 +1811,7 @@ type TEditer=class(TCustomcontrol) //
|
||||||
FSynClasses["json"]:= array(class(TJsonSynHighLighter),class(TSynCompletion),";json;");
|
FSynClasses["json"]:= array(class(TJsonSynHighLighter),class(TSynCompletion),";json;");
|
||||||
FSynClasses["ini"]:= array(class(TINISynHigLighter),class(TSynCompletion),";ini;");
|
FSynClasses["ini"]:= array(class(TINISynHigLighter),class(TSynCompletion),";ini;");
|
||||||
FSynClasses["bat"]:= array(class(TBatSynHigLighter),class(TSynCompletion),";bat;cmd;");
|
FSynClasses["bat"]:= array(class(TBatSynHigLighter),class(TSynCompletion),";bat;cmd;");
|
||||||
|
FSynClasses["tfm"]:= array(class(ttfmhighlighter),class(TSynCompletion),";tfm;");
|
||||||
FSynClasses["None"]:= array(nil,nil,"");
|
FSynClasses["None"]:= array(nil,nil,"");
|
||||||
//FSynClasses["tsf"] := FSynClasses["tsl"];
|
//FSynClasses["tsf"] := FSynClasses["tsl"];
|
||||||
FTslChmHelp := new TTslChmHelp();
|
FTslChmHelp := new TTslChmHelp();
|
||||||
|
|
|
||||||
|
|
@ -1467,6 +1467,281 @@ label L_XCDG;
|
||||||
FBEStates;
|
FBEStates;
|
||||||
FMBStates ;
|
FMBStates ;
|
||||||
end
|
end
|
||||||
|
type ttfmhighlighter = class(TSynHighLighter)
|
||||||
|
function Create(AOwner);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
Clean();
|
||||||
|
FChangeDeal := true;
|
||||||
|
end
|
||||||
|
function Clean();override;
|
||||||
|
begin
|
||||||
|
// { "
|
||||||
|
FTokens := array();
|
||||||
|
FSates := array(0); //状态
|
||||||
|
FBBStates := array(new TBBState(")"));
|
||||||
|
FBEStates := array(new TBBState("}"));
|
||||||
|
FMBStates := array(new TBBState("]"));
|
||||||
|
FbgedStates := array(new TBBState("end"));
|
||||||
|
FjkhStates := array(new TBBState(">"));
|
||||||
|
FSatesCount := 1; //改变的行
|
||||||
|
end
|
||||||
|
function Recycling();override;
|
||||||
|
begin
|
||||||
|
|
||||||
|
inherited;
|
||||||
|
Clean();
|
||||||
|
end
|
||||||
|
function SetInValidateIndex(idx); override; //当前改变的行
|
||||||
|
begin
|
||||||
|
idx := max(1,idx);
|
||||||
|
if not(FChangeDeal) and idx>FSatesCount then return ;
|
||||||
|
if length(FSates)>=idx then
|
||||||
|
FSatesCount := idx;
|
||||||
|
else FSatesCount := length(FSates)-1;
|
||||||
|
if FSatesCount = 1 then Clean();
|
||||||
|
FChangeDeal := false;
|
||||||
|
end
|
||||||
|
function ParserTokenLines(s,b,e,cst,tokens);
|
||||||
|
begin
|
||||||
|
label L_XCDG;
|
||||||
|
if cst=0 then
|
||||||
|
begin
|
||||||
|
idx := b;
|
||||||
|
ttk := "";
|
||||||
|
while idx<=e do
|
||||||
|
begin
|
||||||
|
vi := s[idx];
|
||||||
|
case vi of
|
||||||
|
" ","\t":
|
||||||
|
begin
|
||||||
|
SetTToken(tokens,ttk,idx-1);
|
||||||
|
end
|
||||||
|
"(",")":
|
||||||
|
begin
|
||||||
|
SetTToken(tokens,ttk,idx-1);
|
||||||
|
SetTToken(tokens,vi,idx,")");
|
||||||
|
end
|
||||||
|
"{","}":
|
||||||
|
begin
|
||||||
|
SetTToken(tokens,ttk,idx-1);
|
||||||
|
SetTToken(tokens,vi,idx,"}");
|
||||||
|
end
|
||||||
|
"[","]":
|
||||||
|
begin
|
||||||
|
SetTToken(tokens,ttk,idx-1);
|
||||||
|
SetTToken(tokens,vi,idx,"]");
|
||||||
|
end
|
||||||
|
"<",">":
|
||||||
|
begin
|
||||||
|
SetTToken(tokens,ttk,idx-1);
|
||||||
|
SetTToken(tokens,vi,idx,">");
|
||||||
|
end
|
||||||
|
":",",":
|
||||||
|
begin
|
||||||
|
SetTToken(tokens,ttk,idx-1);
|
||||||
|
SetTToken(tokens,vi,idx,vi);
|
||||||
|
end
|
||||||
|
'"':
|
||||||
|
begin
|
||||||
|
SetTToken(tokens,ttk,idx-1);
|
||||||
|
SetTToken(tokens,vi,idx,'"');
|
||||||
|
return ParserTokenLines(s,idx+1,e,'"',tokens);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
ttk+=vi;
|
||||||
|
end
|
||||||
|
|
||||||
|
end ;
|
||||||
|
idx++;
|
||||||
|
end
|
||||||
|
SetTToken(tokens,ttk,idx-1);
|
||||||
|
end else //查找
|
||||||
|
begin
|
||||||
|
if b>e then return cst;
|
||||||
|
r := FindRightChar(cst,s,b,e,"\\");
|
||||||
|
if r=0 then //没找到
|
||||||
|
begin
|
||||||
|
Setttoken(tokens,s[b:],e,cst);
|
||||||
|
return cst;
|
||||||
|
end else //找到
|
||||||
|
if r<=e then
|
||||||
|
begin
|
||||||
|
if b<r then
|
||||||
|
begin
|
||||||
|
Setttoken(tokens,s[b:r-1],r-1,cst);
|
||||||
|
end
|
||||||
|
Setttoken(tokens,s[r:r],r,cst);
|
||||||
|
if r<e then
|
||||||
|
begin
|
||||||
|
//消除递归
|
||||||
|
b := r+1;
|
||||||
|
cst := 0;
|
||||||
|
goto L_XCDG;
|
||||||
|
//return ParserTokenLines(s,r+1,e,0,tokens); //递归方式
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function InsureTokenParserd(LastLine);override; //解析
|
||||||
|
begin
|
||||||
|
ls := Lines;
|
||||||
|
FChangeDeal := true;
|
||||||
|
for i:= FSatesCount-1 to LastLine do
|
||||||
|
begin
|
||||||
|
if i<0 then continue;
|
||||||
|
s := ls.GetStringByIndex(i);
|
||||||
|
cst := FSates[i];
|
||||||
|
tks := array();
|
||||||
|
FCBBState := FBBStates[i].Clone;
|
||||||
|
FCBEState := FBEStates[i].Clone;
|
||||||
|
FCMBState := FMBStates[i].Clone;
|
||||||
|
fcbgesate := FbgedStates[i].Clone;
|
||||||
|
fcjkhState := FjkhStates[i].Clone;
|
||||||
|
FSates[i+1] := ParserTokenLines(s,1,length(s),cst,tks);
|
||||||
|
FBBStates[i+1] :=FCBBState;//.Clone;
|
||||||
|
FBEStates[i+1] := FCBEState;//.Clone;
|
||||||
|
FMBStates[i+1] := FCMBState;
|
||||||
|
FbgedStates[i+1] := fcbgesate;
|
||||||
|
FjkhStates[i+1] := fcjkhState;
|
||||||
|
FSatesCount := i+1;
|
||||||
|
FTokens[i] := tks;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function GetLineTokens(idx);override;
|
||||||
|
begin
|
||||||
|
if idx<FSatesCount then
|
||||||
|
return FTokens[idx];
|
||||||
|
end
|
||||||
|
protected
|
||||||
|
function SetTToken(tokens,ttk,idx,ext);virtual; //设置token
|
||||||
|
begin
|
||||||
|
d := inherited;
|
||||||
|
if not d then return ;
|
||||||
|
tk := d.FValue;
|
||||||
|
if ext in array(")","]","}",">") then d.FFColor := 0xFF0000;
|
||||||
|
if ext=">" and tk="<" then
|
||||||
|
begin
|
||||||
|
fcjkhState.GetLeft();
|
||||||
|
d.FMATe := fcjkhState.GetSate();
|
||||||
|
end else
|
||||||
|
if ext=">" and tk=">" then
|
||||||
|
begin
|
||||||
|
fcjkhState.GetRight();
|
||||||
|
d.FMATe := fcjkhState.GetSate();
|
||||||
|
end else
|
||||||
|
if ext="}" and tk="{" then
|
||||||
|
begin
|
||||||
|
FCBEState.GetLeft();
|
||||||
|
d.FMATe := FCBEState.GetSate();
|
||||||
|
end else
|
||||||
|
if ext="}" and tk="}" then
|
||||||
|
begin
|
||||||
|
FCBEState.GetRight();
|
||||||
|
d.FMATe := FCBEState.GetSate();
|
||||||
|
end else
|
||||||
|
if ext="]" and tk="[" then
|
||||||
|
begin
|
||||||
|
FCMBState.GetLeft();
|
||||||
|
d.FMATe := FCMBState.GetSate();
|
||||||
|
|
||||||
|
end else
|
||||||
|
if ext="]" and tk="]" then
|
||||||
|
begin
|
||||||
|
FCMBState.GetRight();
|
||||||
|
d.FMATe := FCMBState.GetSate();
|
||||||
|
end else
|
||||||
|
if ext=")" and tk="(" then
|
||||||
|
begin
|
||||||
|
FCBBState.GetLeft();
|
||||||
|
d.FMATe := FCBBState.GetSate();
|
||||||
|
|
||||||
|
end else
|
||||||
|
if ext=")" and tk=")" then
|
||||||
|
begin
|
||||||
|
FCBBState.GetRight();
|
||||||
|
d.FMATe := FCBBState.GetSate();
|
||||||
|
end else
|
||||||
|
if ext='"' then
|
||||||
|
begin
|
||||||
|
D.FFColor := 0x8B008B;
|
||||||
|
end else
|
||||||
|
if tk in array("true","false","null") then
|
||||||
|
begin
|
||||||
|
d.FFColor := 0x0000FF;
|
||||||
|
end else
|
||||||
|
if tk ="object" then
|
||||||
|
begin
|
||||||
|
d.FFColor := 0x0000FF;
|
||||||
|
fcbgesate.GetLeft();
|
||||||
|
d.FMATe := fcbgesate.GetSate();
|
||||||
|
end else
|
||||||
|
if tk="end" then
|
||||||
|
begin
|
||||||
|
d.FFColor := 0x0000FF;
|
||||||
|
fcbgesate.GetRight();
|
||||||
|
d.FMATe := fcbgesate.GetSate();
|
||||||
|
end else
|
||||||
|
if tk in array(":",",") then
|
||||||
|
begin
|
||||||
|
d.FFColor := 0x0000FF;
|
||||||
|
end else
|
||||||
|
if StrIsANumber(tk) then d.FFColor := 0x666666;
|
||||||
|
return d;
|
||||||
|
|
||||||
|
end
|
||||||
|
private
|
||||||
|
function StrIsANumber(s);
|
||||||
|
begin
|
||||||
|
if not s then return 0;
|
||||||
|
r := (1=ParseRegExpr("^[+-]?[\\d]+",s,"",result,MPos,Mlen)) ;
|
||||||
|
return r;
|
||||||
|
end
|
||||||
|
function FindRightChar(c,s,b,e,zy); //查找封闭的字符
|
||||||
|
begin
|
||||||
|
i := b;
|
||||||
|
while i<=e do
|
||||||
|
begin
|
||||||
|
si := s[i];
|
||||||
|
if si=zy then
|
||||||
|
begin
|
||||||
|
i+=2;
|
||||||
|
if i>e then return 0;
|
||||||
|
continue;
|
||||||
|
end
|
||||||
|
if s[i]=c then //找到了
|
||||||
|
begin
|
||||||
|
return i;
|
||||||
|
end
|
||||||
|
i++;
|
||||||
|
end
|
||||||
|
return 0; //没找到
|
||||||
|
for i := b to e do
|
||||||
|
begin
|
||||||
|
if s[i]=c then //找到了
|
||||||
|
begin
|
||||||
|
return i;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
FTokens;
|
||||||
|
FSates;
|
||||||
|
FSatesCount;
|
||||||
|
|
||||||
|
FCBBState;
|
||||||
|
FCBEState;
|
||||||
|
FCMBState;
|
||||||
|
FBBStates;
|
||||||
|
FBEStates;
|
||||||
|
FMBStates ;
|
||||||
|
FbgedStates;
|
||||||
|
FjkhStates;
|
||||||
|
fcbgesate;
|
||||||
|
fcjkhState;
|
||||||
|
end
|
||||||
implementation
|
implementation
|
||||||
type TBBState =class //À¨ºÅ״̬
|
type TBBState =class //À¨ºÅ״̬
|
||||||
function Create(t);
|
function Create(t);
|
||||||
|
|
|
||||||
|
|
@ -2108,13 +2108,13 @@ type TWinControl = class(tcontrol)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end else
|
end else
|
||||||
if message=WM_MOVE then
|
{if message=WM_MOVE then
|
||||||
begin
|
begin
|
||||||
x := e.lolparamsigned();
|
x := e.lolparamsigned();
|
||||||
if FClientLeft <> x then FClientLeft := x;
|
if FClientLeft <> x then FClientLeft := x;
|
||||||
y := e.hilparamsigned();
|
y := e.hilparamsigned();
|
||||||
if FClientTop <> y then FClientTop := y;
|
if FClientTop <> y then FClientTop := y;
|
||||||
end else
|
end else}
|
||||||
//if message = WM_MOUSEMOVE then
|
//if message = WM_MOUSEMOVE then
|
||||||
if message=WM_NCHITTEST then //
|
if message=WM_NCHITTEST then //
|
||||||
begin
|
begin
|
||||||
|
|
|
||||||
|
|
@ -176,11 +176,11 @@ type tcustomcoolbar=class(tcustomcontrol)
|
||||||
rc := ClientRect;
|
rc := ClientRect;
|
||||||
nh := sum(rhs);
|
nh := sum(rhs);
|
||||||
h := rc[3]-rc[1];
|
h := rc[3]-rc[1];
|
||||||
|
bw := Height-h;
|
||||||
dh := h-nh;
|
dh := h-nh;
|
||||||
if abs(dh)>4 then
|
if abs(dh)>4 then
|
||||||
begin
|
begin
|
||||||
Align := alNone;
|
Align := alNone;
|
||||||
if WSSizebox or WsDlgModalFrame or Border then bw := 2;
|
|
||||||
Height := bw+nh;
|
Height := bw+nh;
|
||||||
Align := alTop;
|
Align := alTop;
|
||||||
return ;
|
return ;
|
||||||
|
|
@ -314,9 +314,9 @@ type tcustomcoolbar=class(tcustomcontrol)
|
||||||
ar+= inttostr(ctls.indexof(v.fctl));
|
ar+= inttostr(ctls.indexof(v.fctl));
|
||||||
ar+=",";
|
ar+=",";
|
||||||
end
|
end
|
||||||
ar[length(ar)] := ";";
|
ar[length(ar)] := ";";
|
||||||
end
|
end
|
||||||
if ar then ar[length(ar):] := "";
|
if ar then ar[length(ar):] := "";
|
||||||
return ar;
|
return ar;
|
||||||
end
|
end
|
||||||
function setarrange(ar);
|
function setarrange(ar);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue