编辑器

添加编译功能
This commit is contained in:
JianjunLiu
2023-10-26 10:34:02 +08:00
parent 667772a463
commit 33f86eb012
13 changed files with 1204 additions and 17 deletions
@@ -0,0 +1,324 @@
object ed_script:t_compile_config
caption="编译选项设置"
height=631
left=618
minmaxbox=false
onclose=compile_config_close
top=180
width=502
wssizebox=false
object bt_ok:tbtn
caption="确定"
height=31
left=365
onclick=bt_ok_clk
parentcolor=false
top=551
width=98
end
object gp_dir:tgroupbox
caption="输入目录"
height=94
left=24
parentcolor=true
top=186
width=442
object bt_f_dir:tbtn
caption=".."
height=23
left=408
onclick=bt_f_dir_clk
top=20
width=24
end
object bt_s_dir:tbtn
caption="..."
height=23
left=408
onclick=bt_s_dir_clk
top=51
width=24
end
object label1:tlabel
left=14
top=20
width=68
height=23
caption="函数目录"
end
object ed_f_dirs:tedit
caption="edit1"
height=22
left=87
top=21
width=312
end
object label2:tlabel
left=13
top=51
width=60
height=23
caption="资源目录"
end
object ed_s_dirs:tedit
caption="edit2"
height=23
left=87
top=51
width=311
end
end
object gp_filter:tgroupbox
caption="筛选"
height=145
left=27
parentcolor=true
top=288
width=437
object lb_s_type:tlabel
left=11
top=20
width=92
height=25
caption="资源文件后缀"
end
object ed_s_type:tedit
caption="edit2"
height=27
left=112
text="*.tfm,*.ini"
top=20
width=290
end
object bt_i_f:tbtn
caption="..."
height=24
left=408
onclick=bt_i_f_clk
top=83
width=21
end
object bt_d_f:tbtn
caption="..."
height=24
left=408
onclick=bt_d_f_clk
top=114
width=21
end
object bt_i_s:tbtn
caption="..."
height=25
left=408
onclick=bt_i_s_clk
top=52
width=21
end
object label3:tlabel
left=13
top=51
width=61
height=25
caption="指定资源"
end
object ed_include_s:tedit
caption="edit1"
height=25
left=84
top=52
width=317
end
object label4:tlabel
left=11
top=83
width=63
height=25
caption="指定函数"
end
object ed_include_f:tedit
caption=""
height=25
left=84
top=83
width=317
end
object label5:tlabel
left=13
top=113
width=61
height=25
caption="排除函数"
end
object ed_exclude_f:tedit
caption=""
height=25
left=84
top=114
width=317
end
end
object gp_out:tgroupbox
caption="输出"
height=123
left=27
parentcolor=true
top=48
width=433
object lb_ype:tlabel
left=14
top=17
width=53
height=25
caption="类型"
end
object cb_type:tcombobox
caption="combobox1"
height=23
itemindex=0
items=["执行程序" "动态库" tsg ]
left=79
onselchanged=cb_type_sel
top=18
width=131
end
object lb_output:tlabel
left=13
top=45
width=46
height=25
caption="输出"
end
object ed_output:tedit
caption="edit1"
height=25
left=79
placeholder="输出文件"
top=48
width=320
end
object bt_output:tbtn
caption="..."
enabled=false
height=23
left=404
onclick=bt_output_clk
top=86
width=22
end
object bt_outputname:tbtn
caption="..."
height=25
left=404
onclick=bt_outputname_clk
top=48
width=22
end
object lb_output_f:tlabel
left=14
top=83
width=60
height=25
caption="输出函数"
end
object ed_out_f:tedit
caption="edit1"
height=25
left=79
top=86
width=320
end
end
object bt_cancel:tbtn
caption="取消"
height=31
left=247
onclick=bt_cancel_clk
top=551
width=94
end
object gp_other:tgroupbox
caption="其他"
height=100
left=28
parentcolor=true
top=442
width=437
object ck_gui:tcheckbtn
caption="gui"
height=25
left=17
top=25
width=75
end
object ck_strong:tcheckbtn
caption="强引用函数"
height=25
left=122
onclick=checkbtn2_clk
top=25
width=98
end
object ck_s_rp:tcheckbtn
caption="资源文件保留相对路径"
enabled=false
height=25
left=253
top=25
width=173
end
object lb_ico:tlabel
left=17
top=64
width=39
height=25
caption="图标"
end
object ed_ico:tedit
caption="edit3"
height=25
left=63
top=64
width=249
end
object bt_ico:tbtn
caption="..."
height=25
left=319
onclick=bt_ico_clk
top=64
width=22
end
end
object f_op:topenfileadlg
left=124
top=556
height=30
width=30
caption="openfileadlg1"
filter=<
"ico图标"="*.ico"
>
end
object lb_input:tlabel
left=32
top=16
width=63
height=25
caption="主程序"
end
object e_script:tedit
caption="edit1"
height=25
left=98
top=16
width=331
end
object bt_script:tbtn
caption="..."
height=25
left=437
onclick=bt_script_clk
top=16
width=22
end
end
@@ -0,0 +1,48 @@
object dir_list:t_dir_list
caption="Ŀ¼¹ÜÀí"
height=228
left=513
minmaxbox=false
onclose=dir_list_close
top=475
visible=false
width=615
object lst_dir:tlistbox
caption="listbox1"
height=176
left=10
top=2
width=474
end
object btn_add:tbtn
caption="Ìí¼Ó"
height=31
left=496
onclick=btn_add_clk
top=5
width=86
end
object btn_del:tbtn
caption="ɾ³ý"
height=31
left=496
onclick=btn_del_clk
top=50
width=86
end
object btn_ok:tbtn
caption="Íê³É"
height=31
left=496
onclick=btn_ok_clk
top=146
width=86
end
object f_d:tfolderchooseadlg
left=508
top=95
height=30
width=30
caption="folderchooseadlg1"
end
end
@@ -0,0 +1,40 @@
object m_list_editor:t_m_list_editor
caption="编辑"
height=506
left=572
minmaxbox=false
onclose=m_list_editor_close
top=275
width=366
wssizebox=false
object lb_tip:tlabel
left=7
top=2
width=325
height=25
caption="采用换行分割"
end
object m_list:tmemo
caption="memo1"
height=378
left=9
top=31
width=328
end
object bt_cancel:tbtn
caption="取消"
height=31
left=126
onclick=bt_cancel_clk
top=420
width=94
end
object bt_ok:tbtn
caption="确定"
height=31
left=240
onclick=bt_ok_clk
top=419
width=94
end
end
+381
View File
@@ -0,0 +1,381 @@
type t_compile_config=class(tdcreateform)
uses tslvcl;
bt_ok:tbtn;
gp_dir:tgroupbox;
bt_f_dir:tbtn;
bt_s_dir:tbtn;
gp_filter:tgroupbox;
lb_s_type:tlabel;
ed_s_type:tedit;
bt_i_f:tbtn;
bt_d_f:tbtn;
gp_out:tgroupbox;
lb_ype:tlabel;
cb_type:tcombobox;
lb_output:tlabel;
ed_output:tedit;
bt_cancel:tbtn;
gp_other:tgroupbox;
ck_gui:tcheckbtn;
ck_strong:tcheckbtn;
ck_s_rp:tcheckbtn;
bt_i_s:tbtn;
lb_ico:tlabel;
ed_ico:tedit;
bt_ico:tbtn;
bt_output:tbtn;
f_op:topenfileadlg;
lb_input:tlabel;
e_script:tedit;
bt_script:tbtn;
bt_outputname:tbtn;
lb_output_f:tlabel;
ed_out_f:tedit;
label1:tlabel;
ed_f_dirs:tedit;
label2:tlabel;
ed_s_dirs:tedit;
label3:tlabel;
ed_include_s:tedit;
label4:tlabel;
ed_include_f:tedit;
label5:tlabel;
ed_exclude_f:tedit;
function Create(AOwner);override; //构造
begin
f_sep := iofileseparator();
fbasedirarray := array();
inherited;
//set_base_dir(%% E:\TSUIGROUP\designer\ctl_mgr\%%);
dir_list := new t_dir_list(self);
dir_list.Visible := false;
dir_list.parent := self;
m_list_editor := new t_m_list_editor(self);
m_list_editor.Visible := false;
m_list_editor.parent := self;
end
function bt_cancel_clk(o;e);virtual;
begin
EndModal(0);
end
function bt_ok_clk(o;e);virtual;
begin
EndModal(1);
end
function set_config(r);
begin
clear_config();
if not ifarray(r) then return ;
e_script.text := r["buildfile"];
ed_output.text := r["output"];
ed_out_f.text := r["exports"] ;
ed_f_dirs.text := r["dependsdir"];
ed_include_f.text := r["depends"];
ed_exclude_f.text := r["excludes"];
ed_s_dirs.text := r["resourcedir"];
ed_s_type.text := r["resourcepat"];
ed_include_s.text := r["extresource"];
ck_strong.Checked := r["strong"] ;
ck_gui.Checked := r["buildgui"] ;
ed_ico.text := r["buildico"];
case r["build"] of
"--buildlib":cb_type.ItemIndex := 1;
"--build":cb_type.ItemIndex := 2;
else
cb_type.ItemIndex := 0;
end
//ck_s_rp.Checked := r["resourcekeepdir"];
end
function get_config();
begin
r := array();
case cb_type.ItemIndex of
0: r["build"] := "--buildexe";
1: r["build"] := "--buildlib";
2: r["build"] := "--build";
end
r["buildfile"] := e_script.text;
r["output"] := ed_output.text;
r["exports"] := ed_out_f.text;
r["dependsdir"]:=ed_f_dirs.text;
r["depends"]:=ed_include_f.text;
r["excludes"] := ed_exclude_f.text;
r["resourcedir"] := ed_s_dirs.text;
r["resourcepat"] := ed_s_type.text;
r["extresource"]:=ed_include_s.text;
r["strong"] := ck_strong.Checked;
r["buildgui"] := ck_gui.Checked;
r["buildico"] := ed_ico.text;
r["resourcekeepdir"] := ck_s_rp.Checked;
return r;
end
function clear_config();//清理
begin
e_script.text := "";
ed_output.text := "";
ed_out_f.text := "";
ed_f_dirs.text := "";
ed_include_f.text := "";
ed_exclude_f.text := "";
ed_s_dirs.text := "";
ed_s_type.text := "";
ed_include_s.text := "";
ck_strong.Checked := "";
ck_gui.Checked := "";
ed_ico.text := "";
ck_s_rp.Checked := "";
end
function bt_outputname_clk(o;e);virtual;
begin
f_op.filter := array(get_type():"*"+get_type());
if f_op.OpenDlg()then
begin
ed_output.text :=relative_path( f_op.filename);
end
end
function cb_type_sel(o;e);virtual;
begin
ab := 0 = o.ItemIndex;
bt_ico.Enabled := ab;
ed_ico.Enabled := ab;
bt_output.Enabled := not ab;
ed_out_f.Enabled := not ab;
lb_output_f.Enabled := not ab;
ed_output.text := createoutputname(ed_output.text);
end
function bt_script_clk(o;e);virtual;
begin
f_op.filter := array("tsl脚本":"*.tsf;*.tsl");
if f_op.OpenDlg()then
begin
e_script.text := relative_path( f_op.filename);
end
end
function bt_ico_clk(o;e);virtual;
begin
f_op.filter := array("ico图标":"*.ico");
if f_op.OpenDlg()then
begin
ed_ico.text := relative_path( f_op.filename);
end
end
function bt_d_f_clk(o;e);virtual;
begin
if show_m_editor(s_to_array(ed_exclude_f.text))then
begin
ed_exclude_f.text := array_to_s(m_list_editor.get_data());
end
end
function bt_i_f_clk(o;e);virtual;
begin
if show_m_editor(s_to_array(ed_include_f.text))then
begin
ed_include_f.text := array_to_s(m_list_editor.get_data());
end
end
function bt_i_s_clk(o;e);virtual;
begin
if show_m_editor(s_to_array(ed_include_s.text))then
begin
ed_include_s.text := array_to_s(m_list_editor.get_data());
end
end
function bt_output_clk(o;e);
begin
if show_m_editor(s_to_array(ed_out_f.text))then
begin
ed_out_f.text := array_to_s(m_list_editor.get_data());
end
end
function bt_s_dir_clk(o;e);
begin
if show_dir_list(s_to_array(ed_s_dirs.text,true))then
begin
ed_s_dirs.text := array_to_s(dir_list.get_dirs(),true);
end
end
function bt_f_dir_clk(o;e);
begin
if show_dir_list(s_to_array(ed_f_dirs.text,true))then
begin
ed_f_dirs.text := array_to_s(dir_list.get_dirs(),true);
end
end
function compile_config_close(o;e);virtual;
begin
e.skip := true;
EndModal(0);
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
function show_dir_list(data);
begin
dir_list.Left := Left-20;
dir_list.top := top+50;
dir_list.set_dirs(data);
return dir_list.ShowModal();
end
function show_m_editor(data);
begin
m_list_editor.Left := Left-20;
m_list_editor.top := top+50;
m_list_editor.set_data(data);
return m_list_editor.ShowModal();
end
function enabled_script_input(f);
begin
e_script.Enabled := f;
bt_script.Enabled := f;
end
function set_data(d);
begin
if ifarray(d) then
begin
f_data := d;
end
end
published
property base_dir read fbasedir write set_base_dir;
dir_list;
m_list_editor;
private
fbasedir;
fbasedirarray;
f_data;
f_sep;
function s_to_array(s,ph);
begin
data := array();
for i,v in str2array( s,",") do
begin
vi := trim(v);
if vi then data[length(data)] := ph? abstruct_path(v):v;
end
return data;
end
function array_to_s(data,ph);
begin
r := "";
for i,v in data do
begin
r+= (ph?relative_path(v):v)+",";
end
return r;
end
function relative_path(d);
begin
if not(fbasedirarray) then return d;
da := str2array(d, f_sep);
for i := 0 to min(length(da),length(fbasedirarray))-1 do
begin
if dirnequ(da[i],fbasedirarray[i]) then
begin
if i>0 then
begin
return createpdir(length(fbasedirarray)-i-1)+ array2str( da[i:],f_sep);
end else
begin
return d;
end
end
end
if i>0 then
begin
if i=length(fbasedirarray)-1 then return "."+f_sep;
return array2str( da[i:],f_sep);
end
return d;
end
function abstruct_path(d);//绝对路径
begin
if not(fbasedirarray) then return d;
da := str2array(d,f_sep);
for i := 0 to length(da)-1 do
begin
if i=0 and da[i]="." then
begin
return array2str((fbasedirarray[0:(length(fbasedirarray)-2)] union da[1:]),f_sep);
end
if da[i]<>".."then
begin
if i>0 then
return array2str( fbasedirarray[0:(length(fbasedirarray)-i-2)] union da[i:],f_sep);
else return d;
end
end
return d;
end
function createpdir(n);
begin
r :="";
if n<1 then return "."+f_sep;
for i:=1 to n do
begin
r+=".."+f_sep;
end
return r;
end
function dirnequ(v1,v2);
begin
{$ifdef linux}
return v1<>v2;
{$else}
return lowercase(v1)<>lowercase(v2);
{$endif}
end
function get_type();
begin
idx := cb_type.ItemIndex;
{$ifdef linux}
case idx of
0:tp:=".out";
1:tp:=".so";
2:tp:=".tsg";
end;
{$else}
case idx of
0:tp:=".exe";
1:tp:=".dll";
2:tp:=".tsg";
end;
{$endif}
return tp;
end
function createoutputname(n);
begin
tp := get_type();
for i:= length(n) downto 1 do
begin
if n[i]="." and i>1 then
begin
nv := n[1:(i-1)];
break;
end
end
if not nv then nv := "."+iofileseparator()+"default";
return nv+tp;
end
function set_base_dir(v);
begin
if fbasedir<>v then
begin
fbasedir := v;
fbasedirarray := str2array(v,f_sep);
end
end
end
+58
View File
@@ -0,0 +1,58 @@
type t_dir_list=class(tdcreateform)
uses tslvcl;
lst_dir:tlistbox;
btn_add:tbtn;
btn_del:tbtn;
btn_ok:tbtn;
f_d:tfolderchooseadlg;
function Create(AOwner);override; //构造
begin
inherited;
end
function btn_ok_clk(o;e);virtual;
begin
//Visible := false;
EndModal(1);
end
function btn_del_clk(o;e);virtual;
begin
idx := lst_dir.ItemIndex;
if idx>=0 then
begin
lst_dir.DeleteItem(idx);
end
end
function btn_add_clk(o;e);virtual;
begin
if f_d.OpenDlg() then
begin
r := f_d.Folder;
if r[length(r)]<>iofileseparator() then r+=iofileseparator();
lst_dir.AppendItem(r);
end
end
function get_dirs();
begin
return lst_dir.Items;
end
function set_dirs(ls);
begin
lst_dir.Items := ls;
end
function dir_list_close(o;e);virtual;
begin
e.skip := true;
EndModal(0);
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
end
+59
View File
@@ -0,0 +1,59 @@
type t_m_list_editor=class(tdcreateform)
uses tslvcl;
lb_tip:tlabel;
m_list:tmemo;
bt_cancel:tbtn;
bt_ok:tbtn;
function Create(AOwner);override; //构造
begin
inherited;
end
function set_data(d);
begin
m_list.text := "";
s :="";
for i,v in d do
begin
s+=v;
s+="\r\n";
end
m_list.text := s;
end
function get_data();
begin
s := m_list.text;
r := array();
for i,v in str2array(s,"\r\n") do
begin
vi := trim(v);
if vi then r[length(r)] := vi;
end
return r;
end
function bt_ok_clk(o;e);virtual;
begin
EndModal(1);
end
function bt_cancel_clk(o;e);virtual;
begin
EndModal(0);
end
function m_list_editor_close(o;e);virtual;
begin
e.skip := true;
EndModal(0);
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
end