更新编辑器

This commit is contained in:
2025-03-25 16:20:53 +08:00
parent 254dc0b2cd
commit ab8b5bb6a5
16 changed files with 444 additions and 210 deletions
@@ -1,122 +0,0 @@
object codeformateditor:t_code_format_mgr
autosize=true
caption="tsl代码格式化参数"
childsizing=<
layout=1
controlsperline=2
horizontalspacing=10
verticalspacing=10
leftrightspacing=20
topbottomspacing=10
>
font=<
height=19
width=9
escapement=0
orientation=0
weight=400
italic=0
underline=0
strikeout=0
charset=134
outprecision=3
clipprecision=2
quality=1
pitchandfamily=49
facename="新宋体"
color=0
>
height=90
left=547
minmaxbox=false
onclose=tformatinfownd1_close
parentfont=false
top=277
width=449
wssizebox=false
object label1:tlabel
left=20
top=10
width=128
height=22
autosize=true
caption="多行注释对齐"
end
object faligncmt:tcheckbtn
autosize=false
caption=""
height=22
left=158
parentcolor=true
top=10
width=110
end
object label3:tlabel
left=20
top=42
width=128
height=22
autosize=true
caption="array格式化"
end
object farraytype:tcombobox
autosize=true
height=22
itemindex=1
items=["默认" "普通" "宽松" ]
left=158
top=42
width=110
end
object label4:tlabel
left=20
top=74
width=128
height=22
autosize=true
caption="语法检查"
end
object fsyncheck:tcheckbtn
caption=""
checked=true
height=22
left=158
parentcolor=true
top=74
width=110
end
object label5:tlabel
left=20
top=106
width=128
height=22
autosize=true
caption="格式化选择区域"
end
object fselectcheck:tcheckbtn
caption=""
height=22
left=158
parentcolor=true
top=106
width=110
end
object label2:tlabel
left=20
top=138
width=128
height=22
caption=""
end
object btn1:tbtn
autosize=true
caption="确定"
height=22
left=158
onclick=dookclick
top=138
width=110
end
end
@@ -0,0 +1,224 @@
object editor_config:t_editor_config
autosize=true
caption="编辑器配置"
childsizing=<
layout=1
controlsperline=1
horizontalspacing=10
verticalspacing=10
leftrightspacing=10
topbottomspacing=10
>
height=401
left=851
minmaxbox=false
onclose=editor_config_close
top=574
width=321
wssizebox=false
object gb_format:tgroupbox
autosize=true
caption="代码格式"
childsizing=<
layout=1
controlsperline=2
horizontalspacing=10
verticalspacing=10
leftrightspacing=10
topbottomspacing=10
>
height=157
left=10
parentcolor=true
top=10
width=285
object lb_align:tlabel
left=14
top=29
width=100
height=21
autosize=true
caption="多行注释对齐"
end
object ck_align:tcheckbtn
autosize=true
caption=""
height=21
left=124
parentcolor=true
top=29
width=100
end
object lb_array:tlabel
left=14
top=60
width=100
height=21
autosize=true
caption="array格式化"
end
object cb_array:tcombobox
autosize=true
caption="combobox1"
height=21
itemindex=1
items=["默认" "普通" "宽松" ]
left=124
top=60
width=100
end
object lb_syn:tlabel
left=14
top=91
width=100
height=21
autosize=true
caption="语法检查"
end
object ck_syn:tcheckbtn
autosize=true
caption=""
height=21
left=124
parentcolor=true
top=91
width=100
end
object lb_select:tlabel
left=14
top=122
width=100
height=21
autosize=true
caption="格式化选择区域"
end
object ck_sel:tcheckbtn
autosize=true
caption=""
height=21
left=124
parentcolor=true
top=122
width=100
end
end
object gb_tips:tgroupbox
autosize=true
caption="自动完成"
childsizing=<
layout=1
controlsperline=3
horizontalspacing=10
verticalspacing=10
leftrightspacing=10
topbottomspacing=10
>
height=126
left=10
parentcolor=true
top=177
width=285
object lb1:tlabel
left=14
top=29
width=30
height=19
autosize=true
caption="从第"
end
object sp_i:tspinedit
autosize=true
caption="spinedit1"
height=19
left=54
maxvalue=8
minvalue=1
top=29
value=1
width=41
end
object lb2:tlabel
left=105
top=29
width=105
height=19
autosize=true
caption="字符开始匹配"
textalign=al9_default
end
object lb3:tlabel
left=14
top=58
width=30
height=21
autosize=true
caption=""
end
object lb4:tlabel
left=54
top=58
width=41
height=21
autosize=true
caption=""
end
object ck_case:tcheckbtn
autosize=true
caption="区分大小写"
height=21
left=105
textpos=al9_default
top=58
width=105
end
object label1:tlabel
left=14
top=89
width=30
height=23
autosize=true
caption=""
end
object label2:tlabel
left=54
top=89
width=41
height=23
autosize=true
caption=""
end
object ck_first:tcheckbtn
autosize=true
caption="从头匹配"
checked=true
height=23
left=105
top=89
width=105
end
end
object panel1:tpanel
caption="panel1"
height=39
left=10
top=313
width=285
wsdlgmodalframe=false
object bt_ok:tbtn
caption="保存"
height=31
left=59
onclick=bt_ok_clk
top=8
width=94
end
object bt_cancel:tbtn
caption="取消"
height=31
left=191
top=8
width=94
end
end
end
@@ -30,14 +30,14 @@ object shortcut_keys_view:t_shortcut_keys_view
align=albottom
autosize=true
caption="panel1"
height=34
height=37
left=0
top=611
top=608
width=574
object fokbtn:tbtn
autosize=true
caption="횅땍"
height=22
height=25
left=242
onclick=fokbtn_clk
top=6
@@ -56,7 +56,7 @@ object shortcut_keys_view:t_shortcut_keys_view
text="綱츠"
>
]
height=611
height=608
left=0
parentfont=true
top=0
-62
View File
@@ -1,62 +0,0 @@
type t_code_format_mgr=class(tdcreateform)
uses tslvcl;
label1:tlabel;
label2:tlabel;
label3:tlabel;
label4:tlabel;
label5:tlabel;
faligncmt:tcombobox;
fcharct:tcombobox;
farraytype:tcombobox;
fsyncheck:tcheckbtn;
fselectcheck:tcheckbtn;
btn1:tbtn;
function Create(AOwner);override;//构造
begin
inherited;
end
function DoOKClick(o;e);virtual;
begin
calldatafunction(FOnOkClick,self,e);
end
function tformatinfownd1_close(o;e);virtual;
begin
e.skip := true;
o.Visible := false;
end
function Recycling();override;//回收变量
begin
inherited;
ci := self.classinfo();
//将成员变量赋值为nil避免循环引用
for i,v in ci["members"]do
begin
invoke(self,v["name"],nil);
end
end
function GetData();
begin
r := array();
r["cmt"]:= faligncmt.Checked;
r["arraytype"]:= array("普通":1,"默认":0,"宽松":3)[farraytype.getCurrentItemText()];
r["syn"]:= fsyncheck.checked;
r["sel"]:= fselectcheck.checked;
return r;
end
function SetData(d);
begin
//"50" "80" "100" "130"
// "50" "100" "130" "150" "200" "250" "300"
//"默认" "普通" "宽松"
if ifarray(d) then
begin
faligncmt.Checked := (d["cmt"]=1);
farraytype.ItemIndex := (array(0:0,1:1,3:2))[d["arraytype"]];
fsyncheck.Checked := d["syn"];
fselectcheck.Checked := d["sel"];
end
end
property OnOkClicked read FOnOkClick write FOnOkClick;
private
[weakref] FOnOkClick;
end
+88
View File
@@ -0,0 +1,88 @@
type t_editor_config=class(tdcreateform)
uses tslvcl;
gb_format:tgroupbox;
lb_align:tlabel;
ck_align:tcheckbtn;
lb_array:tlabel;
cb_array:tcombobox;
lb_syn:tlabel;
ck_syn:tcheckbtn;
lb_select:tlabel;
ck_sel:tcheckbtn;
gb_tips:tgroupbox;
lb1:tlabel;
sp_i:tspinedit;
lb2:tlabel;
ck_case:tcheckbtn;
lb3:tlabel;
lb4:tlabel;
panel1:tpanel;
bt_ok:tbtn;
bt_cancel:tbtn;
label1:tlabel;
label2:tlabel;
ck_first:tcheckbtn;
function Create(AOwner);override; //构造
begin
inherited;
end
function editor_config_close(o;e);
begin
e.skip := true;
o.Visible := false;
end
function bt_cancel_clk(o;e);
begin
o.Visible := false;
//calldatafunction(foncancel_clk,self,e);
end
function bt_ok_clk(o;e);
begin
calldatafunction(OnOkClicked,self,e);
end
function getdata();
begin
r := array();
r["cmt"]:= ck_align.Checked;
r["arraytype"]:= array("普通":1,"默认":0,"宽松":3)[cb_array.getCurrentItemText()];
r["syn"]:= ck_syn.checked;
r["sel"]:= ck_sel.checked;
r["matchidx"] := sp_i.value;
r["matchfirst"] := ck_first.Checked;
r["case"] := ck_case.Checked;
return r;
end
function setdata(d);
begin
if ifarray(d) then
begin
ck_align.Checked := (d["cmt"]=1);
cb_array.ItemIndex := (array(0:0,1:1,3:2))[d["arraytype"]];
ck_syn.Checked := d["syn"];
ck_sel.Checked := d["sel"];
sp_i.value := d["matchidx"];
ck_case.Checked := (d["case"]=1);
ck_first.Checked := (d["matchfirst"]=1);
end
end
function DoControlAlign();override;//对齐子控件
begin
//当窗口大小改变时,该函数会被调用,
//可以通过 clientrect 获取客户区大小,设置子控件的位置以及大小
//如果自己处理了子控件的对齐,就可以去掉 inherited
inherited;
end
function Recycling();override; //回收变量
begin
inherited;
ci := self.classinfo(); //将成员变量赋值为nil避免循环引用
for i,v in ci["members"] do
begin
if v["const"] then continue;
if v["static"] then continue;
invoke(self,v["name"],nil);
end
end
[weakref]OnOkClicked;
end
+2 -2
View File
@@ -59,8 +59,8 @@ array(
"type":"form",
"dir":""
),
"t_code_format_mgr":(
"name":"t_code_format_mgr",
"t_editor_config":(
"name":"t_editor_config",
"type":"form",
"dir":""
)
+1 -1
View File
@@ -509,7 +509,7 @@ type teditorform = class(TVCform) //
formIcon := GetIcon();
FEdter.Visible := true;
FFormatInfoWnd := NEW t_code_format_mgr(self);
FFormatInfoWnd := NEW t_editor_config(self);//t_code_format_mgr(self);
FFormatInfoWnd.Visible := false;
FFormatInfoWnd.WsDlgModalFrame := true;
FFormatInfoWnd.Parent := self;
+36 -7
View File
@@ -169,11 +169,12 @@ type TPage=class(TCustomControl) //
begin
if FItemIndex=i then //选中
begin
dc.Brush.Color := 0xFa901E;
bc:= 0xFa901E;
end else
begin
dc.Brush.Color := 0xe4eeee;//rgb(228,228,228);//
bc := 0xe4eeee;//rgb(228,228,228);//
end
dc.brush.color := bc;
dc.draw("roundrect",array(rc[0:1],rc[2:3],array(5,5)));
ny := integer(rc[1]+(rc[3]-rc[1]-16)/2);
if it.BitmapB then
@@ -2023,7 +2024,7 @@ type TEditer=class(TCustomcontrol) //
FSynClasses["tfm"]:= array(class(ttfmhighlighter),class(TSynCompletion),";tfm;");
FSynClasses["None"]:= array(nil,nil,"");
FTslChmHelp := new TTslChmHelp(_wapi);
FCodeFormatInfo := array("wordct":80,"charct":200,"syn":true,"sel":false,"arraytype":0);
FCodeFormatInfo := array("wordct":80,"charct":200,"syn":true,"sel":false,"arraytype":0,"matchfirst":1,"matchidx":1,"case":false);
FPageEditer.OnDblClick := function(o,e)
begin
CreateAFile();
@@ -3311,6 +3312,7 @@ type TEditer=class(TCustomcontrol) //
end
"查找":
begin
center_popup_wnd(FFindWnd,true);
FFindWnd.Show();
end
"前进":
@@ -3612,7 +3614,7 @@ type TEditer=class(TCustomcontrol) //
end
ord("R"):
begin
InitShowWndPos(FFindWnd,"fr",200,150);
center_popup_wnd(FFindWnd,true);//InitShowWndPos(FFindWnd,"fr",200,150);
FFindWnd.oPENreplace();
FFindWnd.Show();
return true;
@@ -3627,7 +3629,7 @@ type TEditer=class(TCustomcontrol) //
end
ord("F"):
begin
InitShowWndPos(FFindWnd,"fr",200,150);
center_popup_wnd(FFindWnd,true);//InitShowWndPos(FFindWnd,"fr",200,150);
FFindWnd.OpenFind();
FFindWnd.Show();
return true;
@@ -3814,7 +3816,11 @@ type TEditer=class(TCustomcontrol) //
end
function SetCodeFormatInfo(d);
begin
if ifarray(d)then FCodeFormatInfo := d;
if ifarray(d)then
begin
FCodeFormatInfo := d;
settslsyninfo();
end
else return FCodeFormatInfo;
end
function getexecuteparams(f); //获得当前的执行参数
@@ -4212,14 +4218,37 @@ type TEditer=class(TCustomcontrol) //
hc := CreateASynObject(n,self);
if hc then
begin
if n="tsl" then
begin
set_tsl_compinfo(hc[1]);
end
lns.Push(hc);
return hc;
end
end
end
public
static Fhightercolor;
FExecuteEditer;
private
function settslsyninfo();
begin
lns := FSynHCS["tsl"];
if lns then
begin
for i := 0 to lns.length()-1 do
begin
vi := lns[i];
cp := vi[1];
set_tsl_compinfo(vi[1]);
end
end
end
function set_tsl_compinfo(cp);
begin
cp.minmatch := FCodeFormatInfo["matchidx"];
cp.IgnoreCase := not FCodeFormatInfo["case"];
cp.matchfirst := FCodeFormatInfo["matchfirst"];
end
function sethclor(cs);
begin
Fhightercolor.colors := cs;