编辑器

优化编辑器
1.调试
2.右键打开
3.标签切换
This commit is contained in:
JianjunLiu 2023-04-21 10:42:35 +08:00
parent 73bd2e82d3
commit 683605bcda
4 changed files with 49 additions and 56 deletions

View File

@ -1,15 +1,15 @@
//Æô¶¯tsl±à¼­Æ÷ //Æô¶¯tsl±à¼­Æ÷
//20230421 整理代码
uses tslvcl; uses tslvcl;
deletefuncacheini(); deletefuncacheini(); //清空缓存
//mtic ; ops := ""; //待打开文件
ops := "";
GLobal G_OpenHostory; GLobal G_OpenHostory;
G_OpenHostory := true; //ĬÈÏ´ò¿ªÀúÊ·½ø³Ì G_OpenHostory := true; //默认打开历史文件标记
hasinstance := true; //µ¥¶À½ø³Ì hasinstance := true; //µ¥¶À½ø³Ì
isdebug := false; isdebug := false;
for i:= 0 to sysparamcount() do for i:= 0 to sysparamcount() do
begin begin
if ("-DEBUGSERVER" = sysparamstr(i)) then if ("-DEBUGSERVER" = sysparamstr(i)) then //调试标记
begin begin
isdebug := true; isdebug := true;
end else end else
@ -54,7 +54,7 @@ begin
if not FileList("",ops) then if not FileList("",ops) then
begin begin
s := ""; s := "";
n := 512; n := 1024;//512;
setlength(s,n); setlength(s,n);
GetCurrentDirectoryA(n,s); GetCurrentDirectoryA(n,s);
for i:= 1 to n do for i:= 1 to n do
@ -82,18 +82,13 @@ begin
end end
end else end else
begin begin
global g_dotsavehistory; global g_dotsavehistory; //是否保存打开的历史记录
g_dotsavehistory := true; g_dotsavehistory := true;
end end
app := initializeapplication(); app := initializeapplication();
//mtic;
//setprofiler(7);
app.createform(class(TRunEditerForm),fm); app.createform(class(TRunEditerForm),fm);
fm.OpenAndGotoFileByName(ops); fm.OpenAndGotoFileByName(ops);
fm.show(); fm.show();
//echo mtoc;
//d := Getprofilerinfo(true);
//exportfile(ftstream(),"",format("d:\\tst\\profile\\%ssynprofile.stm",tostn(random())),d);
app.run(); app.run();
type TRunEditerForm = class(TEditerForm) type TRunEditerForm = class(TEditerForm)
function Create(AOwner);override; function Create(AOwner);override;
@ -111,9 +106,10 @@ type TRunEditerForm = class(TEditerForm)
begin begin
OpenAndGotoFileByName(n); OpenAndGotoFileByName(n);
end end
//_wapi.ShowWindow(self.Handle, SW_SHOWNORMAL); _wapi.ShowWindow(self.Handle, SW_SHOWNORMAL);//确保显示
PostMessageA(self.Handle,WM_USER,303,10); _Wapi.ForegroundWindow(self.Handle);//PostMessageA(self.Handle,WM_USER,303,10);//放到前端
end else
end {else
if e.wparam = 303 and e.lparam=10 then if e.wparam = 303 and e.lparam=10 then
begin begin
//Show(SW_SHOWNORMAL); //Show(SW_SHOWNORMAL);
@ -133,7 +129,7 @@ type TRunEditerForm = class(TEditerForm)
end end
//_wapi.SetForegroundWindow(seLF.Handle); //_wapi.SetForegroundWindow(seLF.Handle);
end end}
inherited; inherited;
end end
function CreateParams(p);override; function CreateParams(p);override;

View File

@ -812,7 +812,8 @@ type TExecuteEditer=class(TCustomControl) //ִ
return ""; return "";
end end
function InsureItemVisible(idx); //移动当前的格子 function InsureItemVisible(idx); //移动当前的格子
begin begin
return ;//
rc := GetIdxRect(idx); rc := GetIdxRect(idx);
c := ClientRect; c := ClientRect;
if rc[1]<c[1]then if rc[1]<c[1]then
@ -4232,6 +4233,7 @@ type TEditer=class(TCustomcontrol) //
end else end else
begin //初始化 begin //初始化
bit := GetCurrentItem(); bit := GetCurrentItem();
{
for i := 0 to its.Length()-1 do for i := 0 to its.Length()-1 do
begin begin
it := its[i]; it := its[i];
@ -4257,10 +4259,23 @@ type TEditer=class(TCustomcontrol) //
it.FPageOrderId := idx++; it.FPageOrderId := idx++;
end end
end end
sit := sselect[0]from sr order by[1]asc end; sit := sselect[0]from sr order by[1]asc end;
FCurrentItemCode := sselect[2]from sr order by[1]desc end; FCurrentItemCode := sselect[2]from sr order by[1] desc end;
FListPages.SetData(sit); }
FListPages.IncIndex(-1); sr := array();
cidx := 0;
for i := 0 to its.Length()-1 do
begin
it := its[i];
if it=bit then cidx := i;
sv := it.OrigScriptPath;
if it.FEditer.ChangedFlag then sv := "*"+sv;
sr[i]:= sv;
end
FListPages.SetData(sr);
FListPages.ItemIndex := cidx;
xy := ClientToScreen(100,100); xy := ClientToScreen(100,100);
FListPages.Top := xy[1]; FListPages.Top := xy[1];
FListPages.Left := xy[0]; FListPages.Left := xy[0];
@ -5625,6 +5640,8 @@ type TListPages=class(TListBox)
end end
function InsureItemVisible(idx); //移动当前的格子 function InsureItemVisible(idx); //移动当前的格子
begin begin
return ;//
//return InsureIdxInClient(idx);
rc := GetIdxRect(idx); rc := GetIdxRect(idx);
c := ClientRect; c := ClientRect;
if rc[1]<c[1]then if rc[1]<c[1]then
@ -5651,8 +5668,10 @@ type TListPages=class(TListBox)
idx := getCurrentSelection(); idx := getCurrentSelection();
ct := ItemCount; ct := ItemCount;
nidx := idx-f; nidx := idx-f;
if nidx>=ct or nidx<0 then return ;
{
if idx=ct-1 then nidx := 0; if idx=ct-1 then nidx := 0;
else if idx=-1 then nidx := 1; else if idx=-1 then nidx := 1;}
SetCurrentSelection(nidx); SetCurrentSelection(nidx);
InsureItemVisible(nidx); InsureItemVisible(nidx);
end end

View File

@ -367,7 +367,6 @@ type TTslDebuga=class(TCustomControl)
Fdbgstack; Fdbgstack;
fdefaultdbger; //±à¼­Æ÷µÄµ÷ÊÔÆ÷ fdefaultdbger; //±à¼­Æ÷µÄµ÷ÊÔÆ÷
fpopediterhandle; fpopediterhandle;
fcurrentgroundwindow;
type tdbgwnd=class(TPanel) type tdbgwnd=class(TPanel)
uses tslvcl; uses tslvcl;
function Create(AOwner); function Create(AOwner);
@ -837,16 +836,20 @@ type TTslDebuga=class(TCustomControl)
dbgunsetbreak(FConnectchannel,usr,n,idx+1); dbgunsetbreak(FConnectchannel,usr,n,idx+1);
end end
end end
function GetWindowHandleByPID(dwProcessID,api) //通过进程ID获取窗口句柄 function GetWindowHandleByPID(pid,api) //通过进程ID获取窗口句柄
begin begin
{$ifdef linux}
return 0;
{$endif}
dwProcessID := _wapi.GetProcessId(pid);
h := api.GetTopWindow(0); h := api.GetTopWindow(0);
while(h) do while(h) do
begin begin
pid := 0; pid := 0;
dwTheardId := api.GetWindowThreadProcessId(h,pid); dwTheardId := api.GetWindowThreadProcessId(h,pid);
if(dwTheardId <> 0) and (pid=dwProcessID) then if(dwTheardId <> 0) and (pid=dwProcessID) then
begin begin
//while(api.GetParent(h)<> 0) do h := api.GetParent(h); // 原有的处理方式找到最上层
cni := 100; cni := 100;
cn := "";setlength(cn,cni); cn := "";setlength(cn,cni);
cno := api.GetClassNameA(h,cn,cni); cno := api.GetClassNameA(h,cn,cni);
@ -860,26 +863,6 @@ type TTslDebuga=class(TCustomControl)
end end
return 0; return 0;
end end
{function GetWindowHandleByPID2(dwProcessID,api) //通过进程ID获取窗口句柄
begin
h := api.GetTopWindow(0);
while(h) do
begin
pid := 0;
dwTheardId := api.GetWindowThreadProcessId(h,pid);
if(dwTheardId <> 0)then
begin
if(pid=dwProcessID)then
begin
// here h is the handle to the window
while(api.GetParent(h)<> 0) do h := api.GetParent(h);
return h;
end
end
h := api.GetNextWindow(h,2);
end
return 0;
end}
function dbgtooldorun(o,e); function dbgtooldorun(o,e);
begin begin
if not(FConnectchannel or FRemoteWait) then if not(FConnectchannel or FRemoteWait) then
@ -890,17 +873,11 @@ type TTslDebuga=class(TCustomControl)
toolbtnState("¼ÌÐø"); toolbtnState("¼ÌÐø");
if FCurrentgotoitem and FCurrentgotoitem.FEditer then FCurrentgotoitem.FEditer.ExecuteCommand("ecruningto",nil); if FCurrentgotoitem and FCurrentgotoitem.FEditer then FCurrentgotoitem.FEditer.ExecuteCommand("ecruningto",nil);
ExecuteCommand("dbgrun"); ExecuteCommand("dbgrun");
{$ifdef linux} Fdebugedwhandle := GetWindowHandleByPID(fdebugproc.Handle,_wapi);
{$else} if Fdebugedwhandle then
//if not Fdebugedwhandle then
// Fdebugedwhandle := GetWindowHandleByPID(_wapi.GetProcessId(fdebugproc.Handle),_wapi);
fcurrentgroundwindow := GetWindowHandleByPID(_wapi.GetProcessId(fdebugproc.Handle),_wapi);
fdoforegroundflag := true;
if fcurrentgroundwindow then
begin begin
_wapi.SetForegroundWindow(fcurrentgroundwindow); _wapi.SetForegroundWindow(Fdebugedwhandle);
end end
{$endif}
end end
function Dbgtooldo(o,e) function Dbgtooldo(o,e)
begin begin

View File

@ -3541,7 +3541,8 @@ type TcustomListBox=class(TCustomListBoxbase)
SelRange(false); SelRange(false);
FSelBegin := FSelEnd := n; FSelBegin := FSelEnd := n;
SelRange(true); SelRange(true);
SetYpos(n); //SetYpos(n);
InsureIdxInClient(n);
calllistselchengd(); calllistselchengd();
end end
function getItemSelectedState(n); function getItemSelectedState(n);