函数查找 打开的时候关闭窗口

This commit is contained in:
liujianjun 2025-01-23 17:49:04 +08:00
parent 3614e645b4
commit 5e04ec2088
15 changed files with 189 additions and 43 deletions

View File

@ -0,0 +1,47 @@
object searchdir_mgr:t_searchdir_mgr
caption="函数搜索目录:左侧为别名,右侧为-libpath目录...."
height=454
left=570
top=447
width=766
object panel1:tpanel
caption="panel1"
height=300
left=165
top=85
width=455
object panel2:tpanel
align=alleft
autosize=true
caption="panel2"
height=294
left=0
top=0
width=140
object label1:tlabel
left=90
top=145
width=44
height=17
autosize=true
caption="label1"
end
end
object splitter1:tsplitter
left=140
top=0
width=10
height=294
align=alleft
caption="splitter1"
end
object panel3:tpanel
align=alclient
caption="panel3"
height=294
left=150
top=0
width=299
end
end
end

View File

@ -38,6 +38,7 @@ type t_function_finder=class(tdcreateform)
if not d then return ; if not d then return ;
f := ffcomp.GetFileFullPath(d[1]); f := ffcomp.GetFileFullPath(d[1]);
Owner.OpenAndGotoFileByName(f,d[3]); Owner.OpenAndGotoFileByName(f,d[3]);
Visible := false;
end end
function show_finder(); function show_finder();
begin begin
@ -51,10 +52,33 @@ type t_function_finder=class(tdcreateform)
end end
function edfind_keydown(o;e); function edfind_keydown(o;e);
begin begin
if e.charcode=13 then ec := e.charcode;
case ec of
13:
begin
return dofind();
end
VK_UP:
begin
sid := listfunc.SelectedId;
if sid>0 then listfunc.SelectedId := sid-1;
else return ;
end
VK_DOWN:
begin
sid := listfunc.SelectedId;
if sid<listfunc.ItemCount-1 then listfunc.SelectedId := sid+1;
else return ;
end
end ;
n := listfunc.Height/listfunc.ItemHeight;
idx := listfunc.SelectedId ;
tidx := listfunc.topline;
if idx<tidx or idx>=(n+tidx-3) then
begin begin
dofind(); listfunc.topline := integer(idx-(n/2)-3);
end end
end end
function dofind(); function dofind();
begin begin

View File

@ -0,0 +1,30 @@
type t_searchdir_mgr=class(tdcreateform)
uses tslvcl;
panel1:tpanel;
panel2:tpanel;
splitter1:tsplitter;
panel3:tpanel;
label1:tlabel;
function Create(AOwner);override; //构造
begin
inherited;
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
end

View File

@ -0,0 +1 @@
//tsl script :tsl1

View File

@ -48,6 +48,16 @@ array(
"name":"t_shortcut_keys_view", "name":"t_shortcut_keys_view",
"type":"form", "type":"form",
"dir":"" "dir":""
),
"t_searchdir_mgr":(
"name":"t_searchdir_mgr",
"type":"form",
"dir":""
),
"tsl1":(
"name":"tsl1",
"type":"tsl",
"dir":""
) )
), ),
"mainform":"t_shortcut_keys_view", "mainform":"t_shortcut_keys_view",

View File

@ -190,11 +190,13 @@ type teditorform = class(TVCform) //
FTslFormatMenu := new tmenu(self); FTslFormatMenu := new tmenu(self);
FTslFormatMenu.Caption := c_m_tsl_style_config; FTslFormatMenu.Caption := c_m_tsl_style_config;
FTslFormatMenu.OnClick := function(o,e)begin FTslFormatMenu.OnClick := function(o,e)begin
move_popwnd_to_center2(FFormatInfoWnd);
FFormatInfoWnd.show(); FFormatInfoWnd.show();
end end
FCodeBlockMenu := new TMenu(self); FCodeBlockMenu := new TMenu(self);
FCodeBlockMenu.caption := c_m_tsl_block; FCodeBlockMenu.caption := c_m_tsl_block;
FCodeBlockMenu.OnClick := function(o,e)begin FCodeBlockMenu.OnClick := function(o,e)begin
move_popwnd_to_center2(fBlockManager);
fBlockManager.ShowModal(); fBlockManager.ShowModal();
end end
@ -1064,6 +1066,7 @@ end
height=240 height=240
left=497 left=497
minmaxbox=false minmaxbox=false
autosize=true
onclose=tformatinfownd1_close onclose=tformatinfownd1_close
top=295 top=295
width=280 width=280
@ -1290,6 +1293,7 @@ type TBlockManager=class(TVCForm)
FEditer.caption := "添加代码块..." FEditer.caption := "添加代码块..."
end end
FEditer.SetData(FList.SelectedValue); FEditer.SetData(FList.SelectedValue);
move_popwnd_to_center2(FEditer);
FEditer.showmodal(); FEditer.showmodal();
end end
@ -1394,6 +1398,8 @@ type tsearchdir = class(TCustomControl)
function Create(AOwner);override; function Create(AOwner);override;
begin begin
inherited; inherited;
ParentFont := false;
font := array("width":10,"height":20);
fcopyer := new TClipBoard(self); fcopyer := new TClipBoard(self);
caption := "函数搜索目录:左侧为别名,右侧为-libpath目录...."; caption := "函数搜索目录:左侧为别名,右侧为-libpath目录....";
fcpmenu := new TPopupmenu(self); fcpmenu := new TPopupmenu(self);
@ -1402,7 +1408,7 @@ type tsearchdir = class(TCustomControl)
mui.Parent := fcpmenu; mui.Parent := fcpmenu;
mui.OnClick := thisfunction(copy_current_dirs); mui.OnClick := thisfunction(copy_current_dirs);
WsDlgModalFrame := true; WsDlgModalFrame := true;
WSSizebox := true; //WSSizebox := true;
visible := false; visible := false;
wsPopUp := true; wsPopUp := true;
WsSysMenu := true; WsSysMenu := true;
@ -1448,6 +1454,7 @@ type tsearchdir = class(TCustomControl)
bt.Color := ci; bt.Color := ci;
FBtns[i] := bt; FBtns[i] := bt;
end end
FBtns[4].autosize := true;
///////////////////////////////// /////////////////////////////////
FEdit := new tedit(self); FEdit := new tedit(self);
FEdit.SetBoundsRect(array(2,2,120,26)); FEdit.SetBoundsRect(array(2,2,120,26));
@ -1459,6 +1466,13 @@ type tsearchdir = class(TCustomControl)
e.skip := true; e.skip := true;
o.endmodal(0); o.endmodal(0);
end ; end ;
autosize := true;
end
function GetPreferredSize(w,h);override;
begin
inherited;
w+=5;
h+=5;
end end
function copy_current_dirs(o,e); function copy_current_dirs(o,e);
begin begin

View File

@ -17,6 +17,7 @@ TPagees; TPageItem
} }
function gettslexe(); function gettslexe();
function move_popwnd_to_center2(wnd);
function to_ansi_str(s); function to_ansi_str(s);
type TPageItem=class() //±êÇ©Ïî type TPageItem=class() //±êÇ©Ïî
function Create(AOwner); function Create(AOwner);
@ -3704,30 +3705,7 @@ type TEditer=class(TCustomcontrol) //
wnd.top := xy[1]; wnd.top := xy[1];
end end
end end
function move_popwnd_to_center2(wnd);
begin
////////////////////窗口居中处理/////////////////////////////////
////////////////////wnd待居中的窗口/////////////////////////////////
////////////////////pwnd父窗口/////////////////////////////////
pd := pwnd;
if pd then
begin
while 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 SetPageItemSyn(it,n); function SetPageItemSyn(it,n);
begin begin
if not it then return; if not it then return;
@ -4513,6 +4491,30 @@ AE40CC0000000049454E44AE42608200";//GetSaveFileBitmapInfo();
end end
end end
implementation implementation
function move_popwnd_to_center2(wnd);
begin
////////////////////窗口居中处理/////////////////////////////////
////////////////////wnd待居中的窗口/////////////////////////////////
////////////////////pwnd父窗口/////////////////////////////////
pd := wnd.Parent;
if pd then
begin
while 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
type thighlightercoloredter=class(tvcform) type thighlightercoloredter=class(tvcform)
uses tslvcl; uses tslvcl;
colorcombobox1:tcolorcombobox; colorcombobox1:tcolorcombobox;
@ -5927,6 +5929,8 @@ type TGoToLineWnd=class(TVCForm) //
function Create(AOwner);override; function Create(AOwner);override;
begin begin
inherited; inherited;
ParentFont := false;
font := array("width":10,"height":20);
wssizebox := false; wssizebox := false;
minmaxbox := false; minmaxbox := false;
WsDlgModalFrame := true; WsDlgModalFrame := true;
@ -5934,13 +5938,14 @@ type TGoToLineWnd=class(TVCForm) //
height := 110; height := 110;
caption := "תµ½.."; caption := "תµ½..";
FLabel := new TLabel(self); FLabel := new TLabel(self);
FLabel.TextAlign := AL9_CENTER;//tAlignStyle9
FLabel.SetBoundsRect(array(3,10,70,35)); FLabel.SetBoundsRect(array(3,10,70,35));
FEdit := new TEdit(self); FEdit := new TEdit(self);
FEdit.SetBoundsRect(array(75,10,200,35)); FEdit.SetBoundsRect(array(75,10,200,35));
FBtn := new TBtn(self); FBtn := new TBtn(self);
FBtn.SetBoundsRect(array(210,10,280,35)); FBtn.SetBoundsRect(array(210,10,280,35));
FLabel.Caption := "目标位置:"; FLabel.Caption := "跳到行:";
FBtn.Caption := "定位"; FBtn.Caption := " 确定 ";
FLabel.parent := self; FLabel.parent := self;
FEdit.parent := self; FEdit.parent := self;
FEdit.OnKeyPress := function(o,e) FEdit.OnKeyPress := function(o,e)
@ -5961,6 +5966,8 @@ type TGoToLineWnd=class(TVCForm) //
begin begin
GotoTextInteger(); GotoTextInteger();
end end
childsizing := array("layout":1,"leftrightspacing":5,"topbottomspacing":10,"verticalspacing":5,"controlsperline":3);
autosize := true;
end end
function DoControlAlign();override; function DoControlAlign();override;
begin begin

Binary file not shown.

View File

@ -892,7 +892,10 @@ type tcontrol = class(tcomponent)
bds:= array(0,0,w,h); bds:= array(0,0,w,h);
end end
else else
bds := UnAlignBounds; begin
//bds := UnAlignBounds;
bds := BoundsRect;
end
case Align of case Align of
alTop: alTop:
begin begin

View File

@ -247,9 +247,9 @@ BFC6105000000097048597300000EC300000EC301C76FA8640000010D49444154
vL := v.Left; vL := v.Left;
sw := fcursplitter.Width; sw := fcursplitter.Width;
nvl := max(x-vl-sw,sw); nvl := max(x-vl-sw,sw);
v.Align := alNone; //v.Align := alNone;
v.Width := nvl; v.Width := nvl;
v.Align := fcurspltype; //v.Align := fcurspltype;
return ; return ;
end end
end end
@ -265,9 +265,9 @@ BFC6105000000097048597300000EC300000EC301C76FA8640000010D49444154
vL := v.top; vL := v.top;
sw := fcursplitter.Height; sw := fcursplitter.Height;
nvl := max(y-vl-sw,sw); nvl := max(y-vl-sw,sw);
v.Align := alNone; //v.Align := alNone;
v.Height := nvl; v.Height := nvl;
v.Align := fcurspltype; //v.Align := fcurspltype;
return ; return ;
end end
end end
@ -282,9 +282,9 @@ BFC6105000000097048597300000EC300000EC301C76FA8640000010D49444154
vl := (v.BoundsRect)[2]; vl := (v.BoundsRect)[2];
sw := fcursplitter.Width; sw := fcursplitter.Width;
nvl := max(vl-x-sw*1.5,sw); nvl := max(vl-x-sw*1.5,sw);
v.Align := alNone; //v.Align := alNone;
v.Width := nvl; v.Width := nvl;
v.Align := fcurspltype; //v.Align := fcurspltype;
return ; return ;
end end
end end
@ -299,9 +299,9 @@ BFC6105000000097048597300000EC300000EC301C76FA8640000010D49444154
vL := (v.BoundsRect)[3]; vL := (v.BoundsRect)[3];
sw := fcursplitter.Height; sw := fcursplitter.Height;
nvl := max(vl-y-sw*1.5,sw); nvl := max(vl-y-sw*1.5,sw);
v.Align := alNone; //v.Align := alNone;
v.Height := nvl; v.Height := nvl;
v.Align := fcurspltype; //v.Align := fcurspltype;
return ; return ;
end end
end end

View File

@ -12,7 +12,7 @@ type tcustomsplitter = class(tgraphiccontrol)
end end
function paint();override; function paint();override;
begin begin
inherited; //inherited;
r := ClientRect; r := ClientRect;
dc := Canvas; dc := Canvas;
if Border then if Border then

View File

@ -80,6 +80,16 @@ type tgraphiccontrol = class(TControl)
InvalidateRectForce(); InvalidateRectForce();
end end
end end
function GetPreferredSize(w,h);override;
begin
ft := Font;
if ft then
begin
c := caption;
w := ft.Width*(max(length(c),1))+2;
h := ft.Height+3;
end
end
function InvalidateRect(rec,f); function InvalidateRect(rec,f);
begin begin
{** {**

View File

@ -2511,10 +2511,10 @@ type TWinControl = class(tcontrol)
begin begin
e.Result := hit; e.Result := hit;
e.skip := true; e.skip := true;
if (csDesigning in ComponentState) then {if (csDesigning in ComponentState) then
begin begin
if al <> alNone then _send_(WM_USER,1644,1644,1); if al <> alNone then _send_(WM_USER,1644,1644,1);
end end}
end end
end end
end end
@ -2567,7 +2567,7 @@ type TWinControl = class(tcontrol)
if e.wparam=1644 and e.lparam=1644 then if e.wparam=1644 and e.lparam=1644 then
begin begin
//Align=alNone; //Align=alNone;
al := Align; {al := Align;
if al in array(alLeft,alRight,alTop,alBottom) then if al in array(alLeft,alRight,alTop,alBottom) then
begin begin
@ -2579,7 +2579,7 @@ type TWinControl = class(tcontrol)
Align := al; Align := al;
end end
end end
}
end end
end end

Binary file not shown.

Binary file not shown.