编辑器

修改常量
This commit is contained in:
JianjunLiu 2023-10-26 15:18:29 +08:00
parent 0a6d53d7bd
commit faf5a8aaa5
1 changed files with 93 additions and 48 deletions

View File

@ -1,5 +1,50 @@
type teditorform = class(TVCform) //编辑器主窗口 type teditorform = class(TVCform) //编辑器主窗口
uses utslvclauxiliary,tslvcl,UTslSynMemo,UtslCodeEditor; uses utslvclauxiliary,tslvcl,UTslSynMemo,UtslCodeEditor;
const c_e_ansi = "ANSI";
const c_e_utf8 = "UTF8";
const c_e_utf8bom = "UTF8 BOM";
const c_e_ucs2big = "UCS2-big";
const c_e_ucs2little = "UCS2-little";
const c_e_separator = "----";
const c_e_to_ansi = "转为ANSI";
const c_e_to_utf8 = "转为UTF8";
const c_e_to_utf8bom = "转为UTF8 BOM";
const c_e_to_ucs2big = "转为UCS2-big";
const c_e_to_ucs2little="转为UCS2-little";
const c_m_cmd_config="命令行配置";
const c_m_debuger = "调试器";
const c_m_tsl_dir = "tsl函数目录";
const c_m_exec = "执行";
const c_m_exec_debug = "调试运行";
const c_m_remote_debug = "远程调试";
const c_m_remote_debug_wait="远程调试(waitattach)";
const c_m_compile="编译当前脚本";
const c_m_window = "窗口";
const c_m_logwindow = "日志窗口..";
const c_m_dir = "目录";
const c_m_encode = "编码";
const c_m_open = "打开";
const c_m_new = "新建";
const c_m_open_other="其他窗口打开";
const c_m_open_history = "打开历史";
const c_m_lang_config = "语言设置";
const c_m_tsl_style_config="tsl代码格式设置";
const c_m_tsl_block = "tsl代码块设置";
const c_m_config = "设置";
const c_m_block_mgr = "代码块管理";
const c_m_exec_config= "tsl执行设置";
const c_m_file = "文件";
const c_m_edit_color = "编辑器颜色";
const c_m_tab_config = "tab设置:";
const c_m_blank = "空格";
const c_m_close_min = "关闭时最小化";
const c_m_lang = "语言";
const c_m_run = "运行";
const c_m_editor = "编辑器";
const c_m_exer = "当前执行程序";
const c_m_help = "帮助";
const c_m_tsl_help = "tsl语言帮助";
const c_m_about = "关于";
function WMACTIVATE(o,e):WM_ACTIVATE;override; //激活 function WMACTIVATE(o,e):WM_ACTIVATE;override; //激活
begin begin
inherited; inherited;
@ -78,15 +123,15 @@ type teditorform = class(TVCform) //
m := new TMainMenu(self); m := new TMainMenu(self);
////////////////////////////////////////////// //////////////////////////////////////////////
FmTool := new TMenu(self); FmTool := new TMenu(self);
FmTool.Caption := "窗口"; FmTool.Caption := c_m_window;
fmglobsearch := new TMenu(self); fmglobsearch := new TMenu(self);
fmglobsearch.caption := "日志窗口.."; fmglobsearch.caption := c_m_logwindow;
fmglobsearch.OnClick := function(o,e) fmglobsearch.OnClick := function(o,e)
begin begin
FEDter.SwitchLogWnd(); FEDter.SwitchLogWnd();
end end
fmglobdir := new TMenu(self); fmglobdir := new TMenu(self);
fmglobdir.caption := "目录"; fmglobdir.caption := c_m_dir;
fmglobdir.onclick := function(o,e) fmglobdir.onclick := function(o,e)
begin begin
v := not(Fdirview.Visible); v := not(Fdirview.Visible);
@ -97,16 +142,16 @@ type teditorform = class(TVCform) //
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
FEnCodeMenu := new TMenu(self); FEnCodeMenu := new TMenu(self);
FEnCodeMenu.Caption := "编码"; FEnCodeMenu.Caption := c_m_encode;
FCodeMenus := array(); FCodeMenus := array();
for i,v in array("ANSI","UTF8","UTF8 BOM","UCS2-big","UCS2-little","----","转为ANSI","转为UTF8","转为UTF8 BOM","转为UCS2-big","转为UCS2-little") do for i,v in array(c_e_ansi,c_e_utf8,c_e_utf8bom,c_e_ucs2big,c_e_ucs2little,c_e_separator,c_e_to_ansi,c_e_to_utf8,c_e_to_utf8bom,c_e_to_ucs2big,c_e_to_ucs2little) do
begin begin
it := new TMenu(self); it := new TMenu(self);
it.Caption := v; it.Caption := v;
FCodeMenus[i] := it; FCodeMenus[i] := it;
if v="----" then it.TSeparator := true; if v=c_e_separator then it.TSeparator := true;
else else
if v in array("UCS2-big","UCS2-little","UTF8 BOM") then if v in array(c_e_ucs2big,c_e_ucs2little,c_e_utf8bom) then
begin begin
it.Enabled := false; it.Enabled := false;
end else end else
@ -119,7 +164,7 @@ type teditorform = class(TVCform) //
Fmopen := new TMenu(self); Fmopen := new TMenu(self);
newaction := new TAction(self); newaction := new TAction(self);
NewAction.ShortCut := "ctrl+O"; NewAction.ShortCut := "ctrl+O";
NewAction.caption := "打开"; NewAction.caption := c_m_open;
NewAction.onexecute := function(o,e) NewAction.onexecute := function(o,e)
begin begin
return FEdter.OpenAfile(); return FEdter.OpenAfile();
@ -130,39 +175,39 @@ type teditorform = class(TVCform) //
Fmnew:= new TMenu(self); Fmnew:= new TMenu(self);
newaction := new TAction(self); newaction := new TAction(self);
NewAction.ShortCut := "ctrl+N"; NewAction.ShortCut := "ctrl+N";
NewAction.caption := "新建"; NewAction.caption := c_m_new;
NewAction.onexecute := function(o,e) NewAction.onexecute := function(o,e)
begin begin
return FEdter.CreateAfile(); return FEdter.CreateAfile();
end end
Fmnew.action := NewAction; Fmnew.action := NewAction;
FOpenOther := new TMenu(self); FOpenOther := new TMenu(self);
FOpenOther.Caption := "其他窗口打开"; FOpenOther.Caption := c_m_open_other;
FOpenOther.OnClick := thisfunction(OpenInOtherWnd) ; FOpenOther.OnClick := thisfunction(OpenInOtherWnd) ;
FOpenHistoryMenu := new TMenu(self); FOpenHistoryMenu := new TMenu(self);
FOpenHistoryMenu.caption := "打开历史"; FOpenHistoryMenu.caption := c_m_open_history;
FOpenHistoryMenu.OnClick := function(o,e)begin FOpenHistoryMenu.OnClick := function(o,e)begin
FEdter.ShowHistoryWnd(); FEdter.ShowHistoryWnd();
end end
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
FTslLangMenu := new tmenu(self); FTslLangMenu := new tmenu(self);
FTslLangMenu.Caption := "语言设置"; FTslLangMenu.Caption := c_m_lang_config;
FTslFormatMenu := new tmenu(self); FTslFormatMenu := new tmenu(self);
FTslFormatMenu.Caption := "tsl代码格式设置"; FTslFormatMenu.Caption := c_m_tsl_style_config;
FTslFormatMenu.OnClick := function(o,e)begin FTslFormatMenu.OnClick := function(o,e)begin
FFormatInfoWnd.show(); FFormatInfoWnd.show();
end end
FCodeBlockMenu := new TMenu(self); FCodeBlockMenu := new TMenu(self);
FCodeBlockMenu.caption := "tsl代码块设置"; FCodeBlockMenu.caption := c_m_tsl_block;
FCodeBlockMenu.OnClick := function(o,e)begin FCodeBlockMenu.OnClick := function(o,e)begin
fBlockManager.ShowModal(); fBlockManager.ShowModal();
end end
FMenuSet := new TMenu(self); FMenuSet := new TMenu(self);
FMenuSet.caption := "设置"; FMenuSet.caption := c_m_config;
fmtslexepath := new TMenu(self); fmtslexepath := new TMenu(self);
if 1=importfile(ftstream(),"",Fexefilepath,tslexefile) then if 1=importfile(ftstream(),"",Fexefilepath,tslexefile) then
begin begin
@ -186,7 +231,7 @@ type teditorform = class(TVCform) //
end end
fBlockManager := new TBlockManager(self); fBlockManager := new TBlockManager(self);
fBlockManager.WsDlgModalFrame := true; fBlockManager.WsDlgModalFrame := true;
fBlockManager.caption := "代码块管理"; fBlockManager.caption := c_m_block_mgr;
fBlockManager.minmaxbox := false; fBlockManager.minmaxbox := false;
fBlockManager.Visible := false; fBlockManager.Visible := false;
fBlockManager.Parent := self; fBlockManager.Parent := self;
@ -213,9 +258,9 @@ type teditorform = class(TVCform) //
end end
///////////////////////////////////////// /////////////////////////////////////////
//////////////////////////////////////////////// ////////////////////////////////////////////////
fmtslexepath.caption :="tsl执行设置"; fmtslexepath.caption :=c_m_exec_config;
fmfile := new TMenu(self); fmfile := new TMenu(self);
fmfile.caption := "文件"; fmfile.caption := c_m_file;
fmfile.parent := m; fmfile.parent := m;
FMenuSet.parent := m; FMenuSet.parent := m;
Fmopen.parent := fmfile; Fmopen.parent := fmfile;
@ -232,15 +277,15 @@ type teditorform = class(TVCform) //
end end
FMTabContain :=new TMenu(self); FMTabContain :=new TMenu(self);
fmshowhltediter :=new TMenu(self); fmshowhltediter :=new TMenu(self);
fmshowhltediter.caption := "编辑器颜色"; fmshowhltediter.caption := c_m_edit_color;
FMTabs := array(); FMTabs := array();
FMTabContain.Caption := "tab设置:"; FMTabContain.Caption := c_m_tab_config;
for i:= 0 to 6 do for i:= 0 to 6 do
begin begin
tm := new TMenu(self); tm := new TMenu(self);
if i=0 then tm.Caption := "\\t"; if i=0 then tm.Caption := "\\t";
else else
tm.Caption := inttostr(i)+"空格"; tm.Caption := inttostr(i)+c_m_blank;
if tbwidth=i then tm.Checked := true; if tbwidth=i then tm.Checked := true;
tm.Onclick := thisfunction(TabWidthClick); tm.Onclick := thisfunction(TabWidthClick);
FMTabs[i] := tm; FMTabs[i] := tm;
@ -269,7 +314,7 @@ type teditorform = class(TVCform) //
end end
FCloseMenu := new tmenu(self); FCloseMenu := new tmenu(self);
FCloseMenu.Caption:="关闭时最小化"; FCloseMenu.Caption:=c_m_close_min;
//FCloseMenu.Checked := true; //FCloseMenu.Checked := true;
FCloseMenu.parent := FMenuSet; FCloseMenu.parent := FMenuSet;
FCloseMenu.OnClick := function(o,e) FCloseMenu.OnClick := function(o,e)
@ -296,7 +341,7 @@ type teditorform = class(TVCform) //
//语言按钮 //语言按钮
FSynMenu := New TMenu(self); FSynMenu := New TMenu(self);
FSynMenu.Caption := "语言"; FSynMenu.Caption := c_m_lang;
FSynMenus := array(); FSynMenus := array();
for i,v in FEdter.GetSynTypeNames() do for i,v in FEdter.GetSynTypeNames() do
begin begin
@ -309,30 +354,30 @@ type teditorform = class(TVCform) //
FSynMenu.Parent := m; FSynMenu.Parent := m;
FRunMenu := new TMenu(self); FRunMenu := new TMenu(self);
FRunMenu.caption := "运行"; FRunMenu.caption := c_m_run;
FExeaction := new TAction(self); FExeaction := new TAction(self);
FExeaction.caption := "执行"; FExeaction.caption := c_m_exec;
FExeaction.ShortCut := "F9"; FExeaction.ShortCut := "F9";
FExeaction.onexecute := function(o,e) FExeaction.onexecute := function(o,e)
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(c_m_cmd_config,c_m_debuger,c_m_tsl_dir,c_m_exec,c_m_exec_debug,c_m_remote_debug,c_m_remote_debug_wait,c_m_compile) do
begin begin
it := new TMenu(self); it := new TMenu(self);
if v = "执行" then if v = c_m_exec then
begin begin
it.Action := FExeaction; it.Action := FExeaction;
end end
if v="调试器" then if v=c_m_debuger then
begin begin
it.caption := v; it.caption := v;
ite := new TMenu(self); ite := new TMenu(self);
ite.caption := "编辑器"; ite.caption := c_m_editor;
ite.Checked := true; ite.Checked := true;
ite.Parent := it; ite.Parent := it;
itb := new TMenu(self); itb := new TMenu(self);
itb.caption := "当前执行程序"; itb.caption := c_m_exer;
itb.Parent := it; itb.Parent := it;
itb._tag := ite; itb._tag := ite;
ite._tag := itb; ite._tag := itb;
@ -356,9 +401,9 @@ type teditorform = class(TVCform) //
FEdter.Parent := self; FEdter.Parent := self;
////////////////////////////////////////////////// //////////////////////////////////////////////////
FHelpMenu := new TMenu(self); FHelpMenu := new TMenu(self);
FHelpMenu.Caption := "帮助"; FHelpMenu.Caption := c_m_help;
FHelpMenus := array(); FHelpMenus := array();
for i,v in array("tsl语言帮助","关于") do for i,v in array(c_m_tsl_help,c_m_about) do
begin begin
vi := new TMenu(self); vi := new TMenu(self);
vi.Caption := v; vi.Caption := v;
@ -494,13 +539,13 @@ type teditorform = class(TVCform) //
function HelpClick(o,e); function HelpClick(o,e);
begin begin
case o.Caption of case o.Caption of
"tsl语言帮助": c_m_tsl_help:
begin begin
return FEdter.ShowTslLangChm(); return FEdter.ShowTslLangChm();
end end
"关于": c_m_about:
begin begin
return messageboxa(static editerinfo(),"关于",0,self.Handle); return messageboxa(static editerinfo(),c_m_about,0,self.Handle);
end end
end end
@ -671,27 +716,27 @@ type teditorform = class(TVCform) //
function clickRun(o,e); function clickRun(o,e);
begin begin
case o.caption of case o.caption of
"编译当前脚本": c_m_compile:
begin begin
FEdter.buildpageitem(FEdter.GetCurrentItem()); FEdter.buildpageitem(FEdter.GetCurrentItem());
end end
"命令行配置": c_m_cmd_config:
begin begin
FEdter.ShowExeEditer(); FEdter.ShowExeEditer();
end end
"调试运行": c_m_exec_debug:
begin begin
FEdter.DebugPageItem(FEdter.GetCurrentItem()); FEdter.DebugPageItem(FEdter.GetCurrentItem());
end end
"远程调试": c_m_remote_debug:
begin begin
FEdter.Debugremote(0); FEdter.Debugremote(0);
end end
"远程调试(waitattach)": c_m_remote_debug_wait:
begin begin
FEdter.Debugremote(1); FEdter.Debugremote(1);
end end
"tsl函数目录": c_m_tsl_dir:
begin begin
SearDirMenuClick(o,e); SearDirMenuClick(o,e);
end end
@ -711,31 +756,31 @@ type teditorform = class(TVCform) //
if not it then return ; if not it then return ;
if o.Checked then return ; if o.Checked then return ;
case o.Caption of case o.Caption of
"ANSI": c_e_ansi:
begin begin
it.CurrentcodeIsAnsi(); it.CurrentcodeIsAnsi();
end end
"UTF8": c_e_utf8:
begin begin
it.CurrentCodeIsUtf8(); it.CurrentCodeIsUtf8();
end end
"转为UCS2-big": c_e_to_ucs2big:
begin begin
it.ToUnicode_big(); it.ToUnicode_big();
end end
"转为UCS2-little": c_e_to_ucs2little:
begin begin
it.ToUniocode_little(); it.ToUniocode_little();
end end
"转为ANSI": c_e_to_ansi:
begin begin
it.ToANSI(); it.ToANSI();
end end
"转为UTF8": c_e_to_utf8:
begin begin
it.ToUtF8(); it.ToUtF8();
end end
"转为UTF8 BOM": c_e_to_utf8bom:
begin begin
it.ToUtF8BOM(); it.ToUtF8BOM();
end end