界面库

修正coolbar自动大小的细节
This commit is contained in:
JianjunLiu 2022-09-13 14:31:56 +08:00
parent 2265e8fe3d
commit 023c4eb967
4 changed files with 281 additions and 5 deletions

View File

@ -1811,6 +1811,7 @@ type TEditer=class(TCustomcontrol) //
FSynClasses["json"]:= array(class(TJsonSynHighLighter),class(TSynCompletion),";json;");
FSynClasses["ini"]:= array(class(TINISynHigLighter),class(TSynCompletion),";ini;");
FSynClasses["bat"]:= array(class(TBatSynHigLighter),class(TSynCompletion),";bat;cmd;");
FSynClasses["tfm"]:= array(class(ttfmhighlighter),class(TSynCompletion),";tfm;");
FSynClasses["None"]:= array(nil,nil,"");
//FSynClasses["tsf"] := FSynClasses["tsl"];
FTslChmHelp := new TTslChmHelp();

View File

@ -1467,6 +1467,281 @@ label L_XCDG;
FBEStates;
FMBStates ;
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
type TBBState =class //À¨ºÅ״̬
function Create(t);

View File

@ -2108,13 +2108,13 @@ type TWinControl = class(tcontrol)
end
end
end else
if message=WM_MOVE then
{if message=WM_MOVE then
begin
x := e.lolparamsigned();
if FClientLeft <> x then FClientLeft := x;
y := e.hilparamsigned();
if FClientTop <> y then FClientTop := y;
end else
end else}
//if message = WM_MOUSEMOVE then
if message=WM_NCHITTEST then //
begin

View File

@ -176,11 +176,11 @@ type tcustomcoolbar=class(tcustomcontrol)
rc := ClientRect;
nh := sum(rhs);
h := rc[3]-rc[1];
bw := Height-h;
dh := h-nh;
if abs(dh)>4 then
begin
Align := alNone;
if WSSizebox or WsDlgModalFrame or Border then bw := 2;
Height := bw+nh;
Align := alTop;
return ;