更新编辑器

This commit is contained in:
liujianjun 2025-03-25 16:20:53 +08:00
parent 254dc0b2cd
commit ab8b5bb6a5
16 changed files with 444 additions and 210 deletions

View File

@ -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

View File

@ -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

View File

@ -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

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

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

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":""
)

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;

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;

Binary file not shown.

View File

@ -67,6 +67,7 @@ function remotetslcallback(data);
function TslToHexFormatStr(tsl);
function HexFormatStrToTsl(D);
function GetTextWidthAndHeightWidthFont(s,f,mul);
function center_popup_wnd(wnd,f);//居中窗口
////////////////////////////////////
//Ó¦ÓÃ
type tapplication=class(tcomponent)
@ -4339,7 +4340,9 @@ type TDragImageList=class(TCustomImageList)
end
end
protected
procedure Initialize;override;
procedure Initialize();override;
begin
end
public
function create(Owner);override;
begin
@ -6502,10 +6505,35 @@ function GetTextWidthAndHeightWidthFont(s,f,mul);//
begin
return unit(utslvclgdi).GetTextWidthAndHeightWidthFont(s,f,mul);
end
function CallMessgeFunction(f,o,e); //执行消息回调
function CallMessgeFunction(f,o,e); //执行消息回调
begin
return unit(utslvclauxiliary).CallMessgeFunction(f,o,e);
end
function center_popup_wnd(wnd,f);
begin
////////////////////窗口居中处理/////////////////////////////////
////////////////////wnd待居中的窗口/////////////////////////////////
////////////////////pwnd父窗口/////////////////////////////////
if not((wnd is class(TWinControl)) and wnd.WsPopUp ) then return false;
pd := wnd.parent;
if pd and pd.Visible then
begin
while (ifnil(f) or f) and not(pd.wspopup) do
begin
npd := pd.parent;
if npd then pd := npd;
else break;
end
r := pd.ClientRect;
xy := pd.clienttoscreen(r[0],r[1]);
end else
begin
xy := array(0,0);
r := wnd._wapi.GetScreenRect();
end
wnd.Left := max(0,xy[0]+(r[2]-r[0]-wnd.width)/2) ;
wnd.top := max(0,xy[1]+(r[3]-r[1]-wnd.Height)/2);
end
/////////////////////////³õʼ»¯////////////////////////////////////
function initallib();
begin

View File

@ -2784,7 +2784,7 @@ type TSynCompletion = class(TSynCompletionList)
end else
begin
x := xy[0]; y := xy[1];
SetBoundsRect(array(x,y,x+w,y+h)) ;
SetBoundsRect(array(x,y,x+w,y+h));
end
Show(SW_SHOWNOACTIVATE);
//Visible := true;
@ -2912,7 +2912,7 @@ type TSynCompletion = class(TSynCompletionList)
wd := max(wd,v["clen"]);
end
end
FCurrentWidth := wd;
FCurrentWidth := min(1500,wd);
SetData(d);
if d then
SetCurrentSelection(0);

View File

@ -57,6 +57,7 @@ function rec_inc(rec,n); //
function get_tsl_mem_ptr(s,n);
function Encode_Password(s); //加密
function Decode_Password(s);//解密
function complementary_color(c);//²¹É«¼ÆËã
type tuiglobaldata=class() //全局对象存储
static UIData;
class Function uisetdata(n,d);
@ -2682,6 +2683,10 @@ type tstr_step_match=class()
fcaches[""] := mrows(fits,1);
end
end
function set_init_find_indexs(idxs); //ÉèÖóõʼ¼¯ºÏ
begin
if ifarray(idxs) and idxs<>fcaches[""] then fcaches := array("":idxs);
end
private
function get_same_idexs(si,idxs);virtual; //直接判断全部
begin
@ -4542,6 +4547,10 @@ begin
if n>0 then return v+n;
return v;
end
function complementary_color(c);//²¹É«¼ÆËã
begin
return rgb((255-GetRValue(c)),(255-GetgValue(c)),(255-GetbValue(c)));
end
initialization
uinit();

View File

@ -340,11 +340,13 @@ type tcustomtabcontrol = class(TCustomControl)
CallMessgeFunction(fondrawtab,self(true),e);
continue;
end
dc.pen.color := 13158600;//rgb(200,200,200);
dc.pen.color := 13158600;//rgb(200,200,200);
if FCurrentid=i then
begin
dc.brush.color := 0xc0b0a0;//rgb(100,192,250);//rgb(230,240,250);//rgb(200,200,200);
end else dc.brush.color := 16711422;//rgb(254,254,254);
bc:= 0xc0b0a0;//rgb(100,192,250);//rgb(230,240,250);//rgb(200,200,200);
end else bc := 16711422;//rgb(254,254,254);
dc.brush.color := bc;
dc.font.color := complementary_color(bc);///////////采用补色
dc.draw("roundrect",array(rec[0:1],rec[2:3],array(2,2)));
rec[1]+=2;
it := FTabItems[i];

View File

@ -678,7 +678,7 @@ type tcustomcheckbtn=class(tcustombtn) //checkbtn
end
function BMSETCHECK(o,e):BM_SETCHECK;virtual;
begin
FcheckState := e.wparam;
FcheckState := integer(e.wparam);
InvalidateRect(nil,false);
end
function GetPreferredSize(w,h);override;
@ -3645,10 +3645,11 @@ type TcustomListBox=class(TCustomListBoxbase)
end
idx := GetIdxByYpos(y);
if idx<0 then return;
if FMultisel=2 then
if FMultisel=2 then //非连续选择
begin
end else
if idx <> FSelEnd then
if idx <> FSelEnd then //连续
begin
IncPaintLock();
SelRange(false);
@ -3671,6 +3672,7 @@ type TcustomListBox=class(TCustomListBoxbase)
@param(rc)(array) 绘制区域%%
@param(cvs)(tcustomcanvas) 画布 %%
**}
bkfc := cvs.font.Color;
r := PaintIdxBkg(idx,rc,cvs);
rc1 := rc;
rc1[4]:=r;
@ -3697,6 +3699,7 @@ type TcustomListBox=class(TCustomListBoxbase)
rc1[0]+=nh+5;
end
PaintIdexText(idx,rc1,cvs);
cvs.font.Color := bkfc;
end
function PaintIdexText(idx,rc,cvs);virtual;
begin
@ -4132,6 +4135,7 @@ type TcustomListBox=class(TCustomListBoxbase)
begin
cvs.brush.Color := fselbkcolor;//0xFFE7CB;//rgb(204,231,255);
cvs.FillRect(rc);
if (fselbkcolor .& 0xff000000)<1 then cvs.font.Color := complementary_color(fselbkcolor);
end
end
return r;
@ -5925,6 +5929,8 @@ type TcustomStatusBar=class(TCustomControl)
function create(AOwner);override;
begin
FItemOder := 0;
fsimpletext := "";
fsimplepanel := 0;
inherited;
height := 25;
Align := alBottom;
@ -5935,6 +5941,11 @@ type TcustomStatusBar=class(TCustomControl)
c := clientRect;
FCwid := c[2];
FCHei := c[3];
if fsimplepanel then
begin
cvs := Canvas;
return DrawStatItem(cvs,array("text":fsimpletext),c);
end
if FItemOder then return paintb();
painta();
end
@ -5949,6 +5960,7 @@ type TcustomStatusBar=class(TCustomControl)
if not(wd>0)then wd := 100;
Fitems[Length(Fitems)]:= array("text":str,"width":wd);
if faddlock then return 0;
if fsimplepanel then return ;
if HandleAllocated()then
begin
InvalidateRect(nil,false);
@ -5962,6 +5974,7 @@ type TcustomStatusBar=class(TCustomControl)
**}
if not(itemidok(idx))then return -1;
deleteindex(Fitems,idx,true);
if fsimplepanel then return ;
if HandleAllocated()then
begin
InValidateRect(nil,false);
@ -5977,6 +5990,7 @@ type TcustomStatusBar=class(TCustomControl)
if not ifstring(str)then return -1;
if not(itemidok(idx))then return -1;
Fitems[idx,"text"]:= str;
if fsimplepanel then return ;
if HandleAllocated()then
begin
InvalidateRect(nil,false);
@ -5996,12 +6010,16 @@ type TcustomStatusBar=class(TCustomControl)
property Items:statusitems read Fitems Write SetItems;
property itemtext:string read gettexti write settexti;
property itemwidth:integer read getwidthi write setwidthi;
property itemorder:bool read FItemOder write setitemorder;
property itemorder:bool read FItemOder write setitemorder;
property simplepanel:bool read fsimplepanel write set_simplepanel;
property simpletext:string read fsimpletext write set_simpletext;
{**
@param(Items)(array)设置项 ,二维数组包括 text ,width 两个字段 array(("text":"abc","width":200),("text":"part2","width":0.4))%%
@param(itemtext)(string) 通过索引获取设置文本%%
@param(itemwidth)(integer) 通过索引设置获取宽度%%
@param(itemorder)(bool) item展示排序,默认false从左到右,true为从右到左%%
@param(simplepanel)(bool) 简单面板,只是显示一个字符串%%
@param(simpletext)(string) 简单面板模式下显示的字符串%%
**}
private
faddlock;//添加锁定刷新
@ -6009,7 +6027,26 @@ type TcustomStatusBar=class(TCustomControl)
FCwid;//宽度
FCHei;//高度
FItemOder;//排序
private
fsimpletext;
fsimplepanel;
private
function set_simplepanel(v);
begin
nv := v?true:false;
if nv<>fsimplepanel then
begin
fsimplepanel := nv;
InvalidateRect(nil,false);
end
end
function set_simpletext(s);
begin
if ifstring(s) and s<>fsimpletext then
begin
fsimpletext := s;
if fsimplepanel then InvalidateRect(nil,false);
end
end
function itemidok(id);
begin
ct := length(Fitems);
@ -6075,6 +6112,7 @@ type TcustomStatusBar=class(TCustomControl)
if nv<>FItemOder then
begin
FItemOder := nv;
if fsimplepanel then return ;
if FItems then
InvalidateRect(nil,false);
end

Binary file not shown.

Binary file not shown.