编辑器

css支持
This commit is contained in:
JianjunLiu 2023-03-08 09:30:52 +08:00
parent 029ead93cd
commit c924bcd2a0
4 changed files with 99 additions and 29 deletions

View File

@ -1832,6 +1832,7 @@ type TEditer=class(TCustomcontrol) //
FSynClasses["tsl"]:= array(class(TTslSynHighLighter),class(TTslCompletion),";tsl;tsf;pas;stm;"); FSynClasses["tsl"]:= array(class(TTslSynHighLighter),class(TTslCompletion),";tsl;tsf;pas;stm;");
FSynClasses["json"]:= array(class(TJsonSynHighLighter),class(TSynCompletion),";json;"); FSynClasses["json"]:= array(class(TJsonSynHighLighter),class(TSynCompletion),";json;");
FSynClasses["js"]:= array(class(TJsSynHighLighter),class(tjssyncompletion),";js;"); FSynClasses["js"]:= array(class(TJsSynHighLighter),class(tjssyncompletion),";js;");
FSynClasses["css"]:= array(class(TcssSynHighLighter),class(tcsssyncompletion),";css;");
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["tfm"]:= array(class(ttfmhighlighter),class(TSynCompletion),";tfm;");
@ -3634,9 +3635,9 @@ type TEditer=class(TCustomcontrol) //
function FindInCurrent(data,fo,it,rep); function FindInCurrent(data,fo,it,rep);
begin begin
if not it then it := GetCurrentItem(); if not it then it := GetCurrentItem();
if not it then return-2; if not it then return -2;
ed := it.FEditer; ed := it.FEditer;
if not ed then return-2; if not ed then return -2;
cy := ed.CaretY; cy := ed.CaretY;
cx := ed.CaretX; cx := ed.CaretX;
wordwrap := data["c_wrap"]; wordwrap := data["c_wrap"];
@ -3644,7 +3645,7 @@ type TEditer=class(TCustomcontrol) //
if not(fs and ifstring(fs))then if not(fs and ifstring(fs))then
begin begin
fo.SetStatusText("查找内容为空!"); fo.SetStatusText("查找内容为空!");
return-2; return -2;
end end
stringiswrapword := isCaseWords(fs); stringiswrapword := isCaseWords(fs);
if data["c_case"]then fs := lowercase(fs); if data["c_case"]then fs := lowercase(fs);
@ -3664,7 +3665,7 @@ type TEditer=class(TCustomcontrol) //
if ridx<0 then if ridx<0 then
begin begin
fo.SetStatusText("到达顶部"); fo.SetStatusText("到达顶部");
return-2; return -2;
end end
s := L.GetStringByIndex(ridx); s := L.GetStringByIndex(ridx);
ls := length(s); ls := length(s);
@ -3704,7 +3705,7 @@ type TEditer=class(TCustomcontrol) //
cx := length(s)+1; cx := length(s)+1;
end end
fo.SetStatusText("到达顶部"); fo.SetStatusText("到达顶部");
return-2; return -2;
end end
for i := 0 to ct do for i := 0 to ct do
begin begin
@ -5468,7 +5469,6 @@ function gettslexe();
begin begin
return static gettslexefullpath(); return static gettslexefullpath();
end end
{$ifdef linux} {$ifdef linux}
function HtmlHelpA() function HtmlHelpA()
begin begin

View File

@ -129,6 +129,53 @@ type thighlitcolor = class(tcomponent)
end end
FColors; FColors;
end end
type tcsssyncompletion = class(TSynCompletion)
function Create(AOwner);
begin
inherited;
IgnoreCase := false;
end
function PrepareCompletion(m);override;
begin
//½âÎö
if not Memo then return ;
sd := static getcsswordsa();
d := gettextwords(Memo.Text);
if d then sd union=d;
SetCompData(sd);
end
function getcsswordsa();
begin
getcsskeywords(r);
return r;
end
function gettextwords(s);
begin
parseregexpr("[A-Zaz0-9_\\-]+",s,"mi",mched,mchpos,mathlen);
r := array();
for ri,v in mched do
begin
v0 := v[0];
lv := lowercase(v0);
if r[lv] then continue;
r[lv] := v0;
end
d := array();
i := 0;
for lv,v in r do
begin
d[i,"caption"] := v;
d[i,"value"] := v;
d[i,"lvalue"] := lv;
cl := length(v);
d[i,"clen"] := cl;
d[i,"vlen"] := cl;
i++;
end
return d;
end
end
type tjssyncompletion = class(TSynCompletion) type tjssyncompletion = class(TSynCompletion)
function Create(AOwner); function Create(AOwner);
begin begin
@ -343,20 +390,17 @@ type TTslSynHighLighter = class(TSynHighLighter)
FJsSysClass[v]:=true; FJsSysClass[v]:=true;
end end
FJsWindows := array(); FJsWindows := array();
for i,v in array("$","alert","all","anchor","anchors","area","assign","blur","button","checkbox","clearInterval","clearTimeout","clientInformation","close","closed","confirm","constructor","crypto","decodeURI","decodeURIComponent","defaultStatus","document","element","elements","embed","embeds","encodeURI","encodeURIComponent","escape","event","fileUpload","focus","form","forms","frame","innerHeight","innerWidth","layer","layers","link","location","mimeTypes","navigate","navigator","frames","frameRate","hidden","history","image","images","offscreenBuffering","open","opener","option","outerHeight","outerWidth","packages","pageXOffset","pageYOffset","parent","parseFloat","parseInt","password","pkcs11","plugin","prompt","propertyIsEnum","radio","reset","screenX","screenY","scroll","secure","select","self","setInterval","setTimeout","status","submit","taint","text","textarea","top","unescape","untaint","window") for i,v in getjsfunwords() do
do
begin begin
FJsWindows[v]:=true; FJsWindows[v]:=true;
end end
FJsHtmlEvent := array(); FJsHtmlEvent := array();
for i,v in array("onblur","onclick","onerror","onfocus","onkeydown","onkeypress","onkeyup","onmouseover","onload","onmouseup","onmousedown","onsubmit") for i,v in getdomeventwords() do
do
begin begin
FJsHtmlEvent[v]:=true; FJsHtmlEvent[v]:=true;
end end
FCssPropertys := array(); FCssPropertys := array();
for i,v in array("align-content","align-items","align-self","all","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","caption-side","clear","clip","color","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","cursor","direction","display","empty-cells","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","font","font-face","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","grid-columns","grid-rows","hanging-punctuation","height","icon","justify-content","keyframes","left","letter-spacing","line-height","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","max-height","max-width","media","min-height","min-width","mix-blend-mode","object-fit","object-position","nav-down","nav-index","nav-left","nav-right","nav-up","opacity","order","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page-break-after","page-break-before","page-break-inside","perspective","perspective-origin","position","punctuation-trim","quotes","resize","right","rotation","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-transform","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","white-space","width","word-break","word-spacing","word-wrap","z-index","writing-mode") for i,v in getcsswords() do
do
begin begin
FCssPropertys[v]:=true; FCssPropertys[v]:=true;
end end
@ -1370,6 +1414,23 @@ type TJsSynHighLighter = class(tcustomsynhighlighter)
end end
end end
type TcssSynHighLighter = class(tcustomsynhighlighter)
function create(AOwner);
begin
inherited;
keywordcolor := 0xff0000;
stringcolor := 0x968080;
annotationcolor := 0x8D9600;
ExecuteCommand("string",array(('"',"\\")));
ExecuteCommand("keywords",getcsswords());
ExecuteCommand("rowannotes",array());
ExecuteCommand("blockannotes",array(("/*","*/")));
ExecuteCommand("syms",array("{","}","[","]","<",">","(",")",";",":",",","=","?","+","*","/",".","#"));
ExecuteCommand("pairs",array(("{","}"),("[","]"),("(",")")));
ExecuteCommand("sysfun",array());
end
end
type ttfmhighlighter = class(tcustomsynhighlighter) type ttfmhighlighter = class(tcustomsynhighlighter)
function create(AOwner); function create(AOwner);
@ -1386,11 +1447,9 @@ type ttfmhighlighter = class(tcustomsynhighlighter)
end end
implementation implementation
function getcsskeywords(r); function getcsswords();
begin begin
if not ifarray(r) then r := array(); return array("align-content","align-items","align-self","all","animation","animation-delay",
idx := length(r);
for i,v in array("align-content","align-items","align-self","all","animation","animation-delay",
"animation-direction","animation-duration","animation-fill-mode","animation-iteration-count", "animation-direction","animation-duration","animation-fill-mode","animation-iteration-count",
"animation-name","animation-play-state","animation-timing-function","appearance","backface-visibility", "animation-name","animation-play-state","animation-timing-function","appearance","backface-visibility",
"background","background-attachment","background-blend-mode","background-clip","background-color", "background","background-attachment","background-blend-mode","background-clip","background-color",
@ -1417,8 +1476,13 @@ begin
"text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-indent","text-justify", "text-decoration","text-decoration-color","text-decoration-line","text-decoration-style","text-indent","text-justify",
"text-outline","text-overflow","text-shadow","text-transform","text-wrap","top","transform","transform-origin","transform-style", "text-outline","text-overflow","text-shadow","text-transform","text-wrap","top","transform","transform-origin","transform-style",
"transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align", "transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align",
"visibility","white-space","width","word-break","word-spacing","word-wrap","z-index","writing-mode") "visibility","white-space","width","word-break","word-spacing","word-wrap","z-index","writing-mode");
do end
function getcsskeywords(r);
begin
if not ifarray(r) then r := array();
idx := length(r);
for i,v in getcsswords()do
begin begin
c := v+" <css pro>"; c := v+" <css pro>";
r[idx]["caption"] := c; r[idx]["caption"] := c;

View File

@ -141,7 +141,7 @@ type TCustomTimer = class(tcomponent)//
tm.stop();//停止 tm.stop();//停止
**} **}
private private
static _STIMERS; //TIMER对象 [weakref] static _STIMERS; //TIMER对象
static FSIDC; //id 构造器 static FSIDC; //id 构造器
class function Sgettimer(id); class function Sgettimer(id);
begin begin

View File

@ -99,7 +99,14 @@ type TCustomThreadworker = class()
for idx,i in mrows( FThreaders,1) do for idx,i in mrows( FThreaders,1) do
begin begin
o := FThreaders[i]; o := FThreaders[i];
if uifeachthreadworkerdata(o.handle,msg,data) then try
oh := o.handle;
except
echo ">>>>>>>>>>>>>";
DeleteWorker(i);
uideleteworkerdata(oh); //删除数据
end
if uifeachthreadworkerdata(oh,msg,data) then
begin begin
case msg of case msg of
0x30: //构成成功 0x30: //构成成功
@ -112,7 +119,7 @@ type TCustomThreadworker = class()
end end
0x12: //成功关闭 0x12: //成功关闭
begin begin
uideleteworkerdata(o.handle); //删除数据 uideleteworkerdata(oh); //删除数据
o.ClientReady(0); o.ClientReady(0);
DeleteWorker(i); DeleteWorker(i);
o.destroy(); o.destroy();
@ -204,7 +211,7 @@ type TCustomThreadworker = class()
function SetOnStart(e)begin function SetOnStart(e)begin
FThreader.OnStart := e ; FThreader.OnStart := e ;
end end
static FThreaders; [weakref]static FThreaders;
FScript; //脚本 FScript; //脚本
FThreader;//host对象 FThreader;//host对象
end end
@ -295,7 +302,6 @@ type tworkerHost = class(TArray)
begin begin
try try
call(FOnStart,self); call(FOnStart,self);
except except
end; end;