编辑器

颜色自定义优化
This commit is contained in:
JianjunLiu 2023-04-11 14:17:07 +08:00
parent 0a4713c591
commit c3e7ddbc9f
4 changed files with 84 additions and 27 deletions

View File

@ -4247,10 +4247,10 @@ type TEditer=class(TCustomcontrol) //
if ifobj(c[0])and ifobj(c[1])then if ifobj(c[0])and ifobj(c[1])then
begin begin
h := CreateObject(c[0],ow);//Fhightercolor; h := CreateObject(c[0],ow);//Fhightercolor;
if n="tsl" then //if n="tsl" then
begin // begin
h.hightercolor := Fhightercolor; h.hightercolor := Fhightercolor;
end //end
return array(h,CreateObject(c[1],ow)); return array(h,CreateObject(c[1],ow));
end end
end end
@ -4545,9 +4545,9 @@ type thighlightercoloredter=class(tvcform)
openfileadlg1:topenfileadlg; openfileadlg1:topenfileadlg;
function Create(AOwner);override; //¹¹Ôì function Create(AOwner);override; //¹¹Ôì
begin begin
fcolorindexname := array("字体","关键字","符号","注释","字符串","数字","系统函数","选中背景","当前行背景"); fcolorindexname := array("字体","关键字","符号","注释","字符串","数字","系统函数","选中背景","当前行背景","行号背景");
ffrontcolordefault := array(0,0x0000ff,0,0x228B22,0x8B008B,0x666666,0xcd0000,0,0); ffrontcolordefault := array(0,0x0000ff,0,0x228B22,0x8B008B,0x666666,0xcd0000,0,0,0);
fbkcolordefalut := zeros(7)+0xfafafa union array(rgb(192,192,192),rgb(232,232,255)); fbkcolordefalut := zeros(7)+0xfafafa union array(rgb(192,192,192),rgb(232,232,255),rgb(228,228,228));
ffrontcolors := ffrontcolordefault; ffrontcolors := ffrontcolordefault;
fbkcols := fbkcolordefalut; fbkcols := fbkcolordefalut;
inherited; inherited;
@ -4592,7 +4592,7 @@ type thighlightercoloredter=class(tvcform)
begin begin
if flistboxchanging then return ; if flistboxchanging then return ;
idx := listbox1.ItemIndex; idx := listbox1.ItemIndex;
if idx in array(0,7,8) then if idx in array(0,7,8,9) then
begin begin
cl := colorcombobox2.getcurrentColor(); cl := colorcombobox2.getcurrentColor();
fbkcols[idx] := cl; fbkcols[idx] := cl;

View File

@ -10,6 +10,10 @@ type thighlitcolor = class(tcomponent)
inherited; inherited;
intitcolors(); intitcolors();
end end
function gutterbkcolor();
begin
return FColors["行号背景"];
end
function selbkcolor(); function selbkcolor();
begin begin
return FColors["选中背景"]; return FColors["选中背景"];
@ -62,7 +66,8 @@ type thighlitcolor = class(tcomponent)
array("字体": array("字体":
("font":0,"back":16448250),"关键字": ("font":0,"back":16448250),"关键字":
("font":255,"back":16448250),"符号": ("font":255,"back":16448250),"符号":
("font":0,"back":16448250),"注释": ("font":255,"back":16448250),"行号背景":
("font":0,"back":15000804),"注释":
("font":2263842,"back":16448250),"字符串": ("font":2263842,"back":16448250),"字符串":
("font":9109643,"back":16448250),"数字": ("font":9109643,"back":16448250),"数字":
("font":6710886,"back":16448250),"系统函数": ("font":6710886,"back":16448250),"系统函数":
@ -74,7 +79,7 @@ type thighlitcolor = class(tcomponent)
begin begin
FColors["back"] := new tcolor(v["back"]); FColors["back"] := new tcolor(v["back"]);
end end
if i in array("选中背景","当前行背景") then if i in array("选中背景","当前行背景","行号背景") then
begin begin
FColors[i] := new tcolor(v["back"]); FColors[i] := new tcolor(v["back"]);
end else end else
@ -103,7 +108,7 @@ type thighlitcolor = class(tcomponent)
end else end else
begin begin
v.changed := false; v.changed := false;
if i in array("选中背景","当前行背景") then if i in array("选中背景","当前行背景","行号背景") then
begin begin
v.color := transblk(cls[i]["back"]); v.color := transblk(cls[i]["back"]);
end else end else
@ -121,6 +126,10 @@ type thighlitcolor = class(tcomponent)
if i= "当前行背景" then if i= "当前行背景" then
begin begin
cgd .|= 16; cgd .|= 16;
end else
if i="行号背景" then
begin
cgd .|= 32;
end else end else
cgd .|= 1; cgd .|= 1;
end end
@ -362,7 +371,6 @@ type TTslSynHighLighter = class(TSynHighLighter)
private private
fpairbegin; fpairbegin;
public public
hightercolor;
fforcehtml; fforcehtml;
function forcehtml(h); function forcehtml(h);
begin begin
@ -470,11 +478,14 @@ type TTslSynHighLighter = class(TSynHighLighter)
case tp of case tp of
'//','/*': '//','/*':
begin begin
d.FFColor := 0x8D9600; if hightercolor then d.FFcolor := hightercolor.commentcolor() ;
else
d.FFColor := 0x8D9600;
end end
'"',"'": '"',"'":
begin begin
d.FFColor := 0x968080; if hightercolor then d.FFcolor := hightercolor.strcolor() ;
else d.FFcolor := 0x968080;
end end
"{": "{":
begin begin
@ -516,23 +527,33 @@ type TTslSynHighLighter = class(TSynHighLighter)
begin begin
if FJsWindows[bttk] then // if FJsWindows[bttk] then //
begin begin
d.FFColor := 0xFF0000; if hightercolor then d.FFcolor := hightercolor.sysfunccolor() ;
else
d.FFColor := 0xFF0000;
end else end else
if FJsKeyWords[bttk] then // FE0064 if FJsKeyWords[bttk] then // FE0064
begin begin
d.FFColor := 0xFF0000; if hightercolor then d.FFcolor := hightercolor.keycolor() ;
else
d.FFColor := 0xFF0000;
end else end else
if FJsSysClass[bttk] then // if FJsSysClass[bttk] then //
begin begin
d.FFColor := 0xFF0000; if hightercolor then d.FFcolor := hightercolor.keycolor() ;
else
d.FFcolor := 0xcd0000;
end else end else
if FJsHtmlEvent[bttk] then // if FJsHtmlEvent[bttk] then //
begin begin
d.FFColor := 0xFF0000; if hightercolor then d.FFcolor := hightercolor.sysfunccolor() ;
else
d.FFColor := 0xFF0000;
end else end else
if FCssPropertys[bttk] then if FCssPropertys[bttk] then
begin begin
d.FFColor := 0x0000FF; if hightercolor then d.FFcolor := hightercolor.keycolor() ;
else
d.FFColor := 0x0000FF;
end end
end end
@ -1440,16 +1461,24 @@ type TxmlSynHighLighter = class(tcustomsynhighlighter)
if st1=1 and st.state=1 then if st1=1 and st.state=1 then
begin begin
st.subitemadd(); st.subitemadd();
if st.subitemcount()>1 then
begin
end else
begin
end
case d.FFColor of case d.FFColor of
stringcolor,symcolor: stringcolor,symcolor:
begin begin
end else end else
begin begin
if st.subitemcount()>1 then if st.subitemcount()>1 then
begin begin
d.FFColor := 0x0000ff; d.FFColor := keywordcolor;// 0x0000ff;
end else end else
d.FFColor := 0xff0000; d.FFColor := sysfuncolor;
end end
end end

View File

@ -23,7 +23,8 @@ type TFTSLScriptcustomMemo=class(TSYNmemoNorm)
setbkc(hc.bkcolor().color); setbkc(hc.bkcolor().color);
setfc(hc.fontcolor().color); setfc(hc.fontcolor().color);
setselbc(hc.selbkcolor().color); setselbc(hc.selbkcolor().color);
curbc(hc.curbkcolor().color); curbc(hc.curbkcolor().color);
setgutter(hc.gutterbkcolor().color);
end end
end end
function setselbc(bc); function setselbc(bc);
@ -31,6 +32,12 @@ type TFTSLScriptcustomMemo=class(TSYNmemoNorm)
if bc>0 then selectbkcolor := bc; if bc>0 then selectbkcolor := bc;
else selectbkcolor := rgb(192,192,192); else selectbkcolor := rgb(192,192,192);
end end
function setgutter(bc);
begin
if bc>0 then guttercolor := bc;
else guttercolor := rgb(228,228,288);
end
function curbc(bc); function curbc(bc);
begin begin
if bc>0 then currentLineColor := bc; if bc>0 then currentLineColor := bc;
@ -256,6 +263,10 @@ type TFTSLScriptcustomMemo=class(TSYNmemoNorm)
begin begin
curbc(a.curbkcolor().color); curbc(a.curbkcolor().color);
end end
if op["value"] .& 32 then
begin
setgutter(a.gutterbkcolor().color);
end
return ; return ;
end end
inherited; inherited;

View File

@ -779,7 +779,13 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
function PaintGutter(rcDraw,nL1,nL2); function PaintGutter(rcDraw,nL1,nL2);
begin begin
dc := Canvas; dc := Canvas;
dc.brush.Color :=FGutterColor ;//rgb(228,228,228); if ifnumber(FGutterColor) then
begin
c := FGutterColor;
end else
if ifobj(FGutterColor) then c := FGutterColor.color;
else c := rgb(228,228,228);
dc.brush.Color :=c ;//rgb(228,228,228);
rc := rcDraw; rc := rcDraw;
rc[2]-= 6; rc[2]-= 6;
dc.FillRect(rc); dc.FillRect(rc);
@ -1783,7 +1789,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
end end
function setguttercolor(c); function setguttercolor(c);
begin begin
if ifnumber(c) and c<>fguttercolor then if ifnumber(c) and c<>fguttercolor then
begin begin
fguttercolor := c; fguttercolor := c;
InvalidateRect(nil,false); InvalidateRect(nil,false);
@ -1791,7 +1797,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
end end
function setselectbkcolor(c); function setselectbkcolor(c);
begin begin
if ifnumber(c) and c<>fselectbkcolor then if c<>fselectbkcolor then
begin begin
fselectbkcolor := c; fselectbkcolor := c;
b1 := BlockBegin; b1 := BlockBegin;
@ -2993,7 +2999,9 @@ type TSynCompletion = class(TSynCompletionList)
end end
end end
end end
type TSynHighLighter = class(TComponent) //语法高亮类型 type TSynHighLighter = class(TComponent) //Óï·¨¸ßÁÁÀàÐÍ
public
hightercolor;
type thtcolor = class() type thtcolor = class()
function create(cl); function create(cl);
begin begin
@ -3262,6 +3270,15 @@ type tcustomsynhighlighter = class(TSynHighLighter)
FChangeDeal := true; FChangeDeal := true;
if fdolastline>=LastLine then return ; if fdolastline>=LastLine then return ;
fdolastline := LastLine; fdolastline := LastLine;
if hightercolor then
begin
fsymcolor := hightercolor.symcolor();
fnumbercolor := hightercolor.numcolor();
fkeywordcolor := hightercolor.keycolor();
fsysfuncolor := hightercolor.sysfunccolor();
fstringcolor := hightercolor.strcolor();
fannotationcolor := hightercolor.commentcolor();
end
for i := FSatesCount-1 to LastLine do for i := FSatesCount-1 to LastLine do
begin begin
if i<0 then continue; if i<0 then continue;