编辑器

添加编译功能
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

View File

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

View File

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

View File

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

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

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

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

View File

@ -33,21 +33,23 @@ begin
if (i<=sysparamcount())and ("-install" = sysparamstr(i) ) then //注册右键打开 if (i<=sysparamcount())and ("-install" = sysparamstr(i) ) then //注册右键打开
begin begin
InStallToMenu(); InStallToMenu();
//return sleep(5000); //停留8 //return sleep(5000); //停留5
echo "\r\n press enter exit"; echo "\r\n press enter exit";
sleep(5000);
return readln(); return readln();
end else end else
if (i<=sysparamcount())and ("-uninstall" = sysparamstr(i) ) then //卸载右键打开 if (i<=sysparamcount())and ("-uninstall" = sysparamstr(i) ) then //卸载右键打开
begin begin
UnInStallToMenu(); UnInStallToMenu();
echo "\r\n press enter exit"; echo "\r\n press enter exit";
sleep(5000); //停留5秒
return readln(); return readln();
end end
end end
if sysparamcount()=0 then //处理单独一个文件 if (sysparamcount()=0) or (sysparamcount()=1) then //处理单独一个文件
begin begin
ops := sysparamstr(0); ops := sysparamstr(sysparamcount());
if lowercase(SysExecName())=lowercase(ops) then //处理编译成exe 导致参数次序问题 if lowercase(SysExecName())=lowercase(ops) then //处理编译成exe 导致参数次序问题
begin begin
ops := nil; ops := nil;

View File

@ -317,12 +317,33 @@ type teditorform = class(TVCform) //
begin begin
FEdter.ExecutePageItem(FEdter.GetCurrentItem()); FEdter.ExecutePageItem(FEdter.GetCurrentItem());
end end
for i,v in array("命令行配置","tsl函数目录","执行","调试运行","远程调试","远程调试(waitattach)") do for i,v in array("命令行配置","调试器","tsl函数目录","执行","调试运行","远程调试","远程调试(waitattach)","编译当前脚本") do
begin begin
it := new TMenu(self); it := new TMenu(self);
if v = "执行" then if v = "执行" then
begin begin
it.Action := FExeaction; it.Action := FExeaction;
end
if v="调试器" then
begin
it.caption := v;
ite := new TMenu(self);
ite.caption := "编辑器";
ite.Checked := true;
ite.Parent := it;
itb := new TMenu(self);
itb.caption := "当前执行程序";
itb.Parent := it;
itb._tag := ite;
ite._tag := itb;
f := function(o,e)begin
o.Checked := true;
o._tag.Checked := false;
global g_debug_chooser;
g_debug_chooser := o.caption;
end
ite.OnClick := f;
itb.OnClick := f;
end else end else
begin begin
it.caption := v; it.caption := v;
@ -650,6 +671,10 @@ type teditorform = class(TVCform) //
function clickRun(o,e); function clickRun(o,e);
begin begin
case o.caption of case o.caption of
"编译当前脚本":
begin
FEdter.buildpageitem(FEdter.GetCurrentItem());
end
"命令行配置": "命令行配置":
begin begin
FEdter.ShowExeEditer(); FEdter.ShowExeEditer();

View File

@ -1528,7 +1528,57 @@ end
if it then FTslEditer.DebugPageItem(it); if it then FTslEditer.DebugPageItem(it);
return; return;
end end
compile_config;
fcompier;
function get_config_info();
begin
f := FCProjectPath+"!buildconfig.stm";
if importfile(ftstream(),"",f,r) =1 then
begin
end
if not ifarray(r) then
begin
r := array();
r["build"] := "--buildexe";
r["buildfile"] := "."+"\\"+FExecEntry+".tsl";
r["output"] := "."+"\\"+FExecEntry+".exe";
r["exports"] := "";
r["dependsdir"]:=".\\";
r["depends"]:="";
r["excludes"] := "";
r["resourcedir"] := ".\\";
r["resourcepat"] := "*.tfm";
r["extresource"]:="";
r["strong"] := true;
r["buildgui"] := true;
r["buildico"] := "";
end
iof := ioFileseparator();
if iof<>"\\" then
begin
for i,v in mrows(r,1) do
begin
if ifstring(r[v]) then
r[v] := replacetext(r[v],"\\",iof);
end
end
return r;
end
function save_config_info(d);
begin
if not ifarray(d) then return ;
f := FCProjectPath+"!buildconfig.stm";
iof := ioFileseparator();
if iof<>"\\" then
begin
for i,v in mrows(d,1) do
begin
if ifstring(d[v]) then d[v] := replacetext(d[v],iof,"\\") ;
end
end
exportfile(ftstream(),"",f,d);
end
function WrapTo(); function WrapTo();
begin begin
if not FMainForm then if not FMainForm then
@ -1536,10 +1586,14 @@ end
messageboxa("¹¤³Ìδ´ò¿ª","Ìáʾ",0,self); messageboxa("¹¤³Ìδ´ò¿ª","Ìáʾ",0,self);
exit; exit;
end end
{$ifdef linux} d := get_config_info();
messageboxa("linux系统不支持打包","提示",0,self); ShowEditor();
exit; d := FTslEditer.build_with_data(FCProjectPath,d);
{$endif} if d then
begin
save_config_info(d);
end
return ;
fio := ioFileseparator(); fio := ioFileseparator();
if FWrapFolder.opendlg() then if FWrapFolder.opendlg() then
begin begin

View File

@ -1150,6 +1150,7 @@ type TPageEditerItem=class(TPageItem)
published published
property scripttype read Fscripttype write setFscripttype; property scripttype read Fscripttype write setFscripttype;
property ScriptPath read FScriptPath write SetScriptPath; //文件名 property ScriptPath read FScriptPath write SetScriptPath; //文件名
property scriptname read fscriptname;
property OrigScriptPath read FOrgScriptPath; property OrigScriptPath read FOrgScriptPath;
property TslSynText read FTslSynText write FTslSynText; property TslSynText read FTslSynText write FTslSynText;
property LastText read FLastVersion; //最新的版本 property LastText read FLastVersion; //最新的版本
@ -1546,6 +1547,7 @@ type TPageEditerItem=class(TPageItem)
return ftslparser2.gettslfunctions(); return ftslparser2.gettslfunctions();
end end
private private
fscriptname;
ftslparser2; ftslparser2;
FEnCode; FEnCode;
FLastFileTime; FLastFileTime;
@ -1601,17 +1603,26 @@ type TPageEditerItem=class(TPageItem)
function SetScriptPath(v); function SetScriptPath(v);
begin begin
sp := ioFileseparator(); sp := ioFileseparator();
ddex := 0;
if ifstring(v)then if ifstring(v)then
begin begin
for i := length(v)downto 1 do for i := length(v) downto 1 do
begin begin
if v[i]=sp then if v[i]=sp then
begin begin
Caption := v[i+1:]; if ddex>i then
begin
fscriptname := v[(i+1):(ddex-1)];
end else
begin
fscriptname := v[i+1:];
end
Caption := fscriptname;
break; break;
end end
if v[i]="." then if v[i]="." then
begin begin
ddex := i;
if lowercase(v[i:])in array(".tsl",".tsf")then FTslSynText := true; if lowercase(v[i:])in array(".tsl",".tsf")then FTslSynText := true;
end end
end end
@ -2183,6 +2194,90 @@ type TEditer=class(TCustomcontrol) //
s := FExecuteEditer.GetCurrentExuteString(it.Scriptpath); s := FExecuteEditer.GetCurrentExuteString(it.Scriptpath);
FEchoWnd.Exec("",s,h); FEchoWnd.Exec("",s,h);
end end
compile_config;
function buildpageitem(it);
begin
if not it then return;
ShowEchoWnd();
if FEchoWnd.Exeing()then return FEchoWnd.Endexe();
r := array();
f := it.ScriptPath;
if 1=parseregexpr("\\.tsf$",f,"i",m,mp,ml) then
begin
r["build"] := "--buildlib";
{$ifdef linux}
hz := ".so" ;
{$else}
hz := ".dll";
{$endif}
end else
begin
r["build"] := "--buildexe";
{$ifdef linux}
hz := ".out" ;
{$else}
hz := ".exe";
{$endif}
end
r["buildfile"] := f;
fio := ioFileseparator();
plg := pluginpath();
for i := length(plg)-1 downto 1 do
begin
if plg[i]=fio then
begin
ot := plg[1:i]+it.scriptname+hz;
break;
end
end
ds := getlibpathstr();
r["libpath"] := ds;
if ot then r["output"] := ot;
r["dependsdir"] := replacetext(ds,";",",");
build_with_data(nil,r);
end
function get_local_pos(x,y);
begin
o := self;
x := 0;
y := 0;
while o and not(o.WSpOPUp) do
begin
o := o.Parent;
end
if o then
begin
x := o.left+100;
y := o.top+20;
end
end
function build_with_data(dir,data);
begin
if not compile_config then
begin
compile_config := new t_compile_config(self);
compile_config.visible := false;
compile_config.parent := self;
fcompier :=1;
end
compile_config.base_dir := dir;
compile_config.set_config(data);
get_local_pos(x,y);
compile_config.left := x;
compile_config.top := y;
if compile_config.ShowModal() then
begin
ndata := compile_config.get_config();
ShowEchoWnd();
if FEchoWnd.Exeing()then return FEchoWnd.Endexe();
FEchoWnd.build(dir,ndata);
return ndata;
end
return false ;
end
function SavePageItem(it,f); function SavePageItem(it,f);
begin begin
if not it then return -1; if not it then return -1;
@ -5110,10 +5205,47 @@ type TEditerEchoWnd=class(TSynMemoNorm) //
AppendString(s); AppendString(s);
return true; return true;
end end
function build(dir,d);
begin
plg := pluginpath();
fio := ioFileseparator();
for i := length(plg)-1 downto 1 do
begin
if plg[i]=fio then
begin
{$ifdef linux}
exe := plg[1:i]+"TSL" ;
{$else}
exe := plg[1:i]+"tsl.exe";
{$endif}
break;
end
end
if fileexists("",exe) then
begin
AppendString("build:\r\n");
cmd := "tsl "+format_build_params(d);
FProcess.StartupDirectory := dir;
FProcess.execstr := true;
self.HighLighter := nil;
AppendString(format('%s %s\r\n',exe,cmd));
r := FProcess.CreateProcess(exe,cmd);
h := r;
if r=0 then AppendString("±àÒëʧ°Ü!");
self.HighLighter := F_Highlighter;
return r;
end
//AppendString(format('%s %s\r\n',exe,cmd));
end
function Exec(exe,cmd,h); function Exec(exe,cmd,h);
begin begin
self.HighLighter := nil; self.HighLighter := nil;
AppendString(format('%s %s\r\n',exe,cmd)); AppendString(format('%s %s\r\n',exe,cmd));
FProcess.StartupDirectory := "";
FProcess.execstr := false;
r := FProcess.CreateProcess(exe,cmd); r := FProcess.CreateProcess(exe,cmd);
h := r; h := r;
if r=0 then AppendString("执行失败!"); if r=0 then AppendString("执行失败!");
@ -5167,6 +5299,43 @@ type TEditerEchoWnd=class(TSynMemoNorm) //
FIsLocked; FIsLocked;
FDoLockTime; FDoLockTime;
F_Highlighter; F_Highlighter;
private
function format_build_params(d);
begin
r := d["build"]+="="+format('"%s" ',d["buildfile"]);
if d["libpath"] and ifstring(d["libpath"]) then
begin
r+="-libpath "+d["libpath"]+" ";
end else
r+="-libpath ."+ioFileseparator()+" ";
r += f_b_a_param(d,"exports");
r += f_b_a_param(d,"dependsdir");
r += f_b_a_param(d,"depends");
r += f_b_a_param(d,"excludes");
r += f_b_a_param(d,"resourcedir");
r += f_b_a_param(d,"resourcepat");
r += f_b_a_param(d,"extresource");
r += f_b_a_param(d,"buildico");
r += f_b_a_param(d,"output");
if d["strong"] then r+= " -strong";
if d["buildgui"] then r+= " -buildgui";
return r;
end
function f_b_a_param(d,n);
begin
dn := d[n];
if not ifstring(dn) then return "";
v :=trim( dn);
r :="";
if v then
begin
if v[length(v)]="\\" then v+=",";
r :=format( "--%s=",n)+format('"%s" ',v);
end
return r;
end
end end
type tfincodemap = class(tcustomcontrol) type tfincodemap = class(tcustomcontrol)
function create(AOwner); function create(AOwner);

View File

@ -1330,7 +1330,15 @@ type TTslDebuga=class(TCustomControl)
function getdebuger(pms); //获得调试程序 function getdebuger(pms); //获得调试程序
begin begin
p := static pluginpath(); p := static pluginpath();
FDebugExe := inireadstring("",p+"localediter.ini","debug","debuger",""); //FDebugExe := inireadstring("",p+"localediter.ini","debug","debuger","");
global g_debug_chooser;
if g_debug_chooser="当前执行程序" then
begin
FDebugExe := "1";
end else
begin
end
pms := " "; pms := " ";
//if FDebugExe="1" then //默认获取参数 //if FDebugExe="1" then //默认获取参数
// begin // begin

View File

@ -490,7 +490,7 @@ type TVclDesigner = class(tvcform)
"bitmap":getcreateprojectbmpinfo()), "bitmap":getcreateprojectbmpinfo()),
("type":"menu","caption":"打开历史","onclick":thisfunction(OpenProjectFromtpj), ("type":"menu","caption":"打开历史","onclick":thisfunction(OpenProjectFromtpj),
"bitmap":GetHostroyBimp()), "bitmap":GetHostroyBimp()),
//("type":"menu","caption":"打包到","onclick":thisfunction(WrapProjectTo),"bitmap":getwrapprojectbmpinfo()) ("type":"menu","caption":"±àÒ빤³Ì","onclick":thisfunction(WrapProjectTo),"bitmap":getwrapprojectbmpinfo())
) )
), ),
("type":"menu","caption":"运行","items":( ("type":"menu","caption":"运行","items":(

View File

@ -6803,7 +6803,24 @@ type tcustomprocess = class(tcomponent) //
///////////////////////////处理管道//////////////////////// ///////////////////////////处理管道////////////////////////
Sysexecnewpipe(0); Sysexecnewpipe(0);
ferrinfo := nil; ferrinfo := nil;
hd := sysexec(e,arg,nil,false,code); sdir :=nil;
if ifstring(fStartupDirectory) and fStartupDirectory then
begin
if fStartupDirectory[length(fStartupDirectory)]=iofileseparator() then
begin
if filelist("",fStartupDirectory+"*") then
begin
sdir := fStartupDirectory;
end
end else
begin
if filelist("",fStartupDirectory) then
begin
sdir := fStartupDirectory+iofileseparator();
end
end
end
hd := sysexec(e,arg,sdir,false,code);
if hd=0 then if hd=0 then
begin begin
return 0; return 0;
@ -6850,6 +6867,7 @@ type tcustomprocess = class(tcomponent) //
fonprocended := nil; fonprocended := nil;
end end
published published
property StartupDirectory read fStartupDirectory write fStartupDirectory;
property handle read fprocesshandle; property handle read fprocesshandle;
property errinfo read ferrinfo; property errinfo read ferrinfo;
property exename read fexestring; property exename read fexestring;
@ -6865,6 +6883,7 @@ type tcustomprocess = class(tcomponent) //
@param(handle)(pointer) 进程句柄 %% @param(handle)(pointer) 进程句柄 %%
**} **}
private //成员变量 private //成员变量
fStartupDirectory;
fexecstr; fexecstr;
ferrinfo; ferrinfo;
fprocesshandle; fprocesshandle;