编辑器

加速文件查找
This commit is contained in:
JianjunLiu 2023-04-11 10:31:54 +08:00
parent a7dea9b2cd
commit 0a4713c591
6 changed files with 589 additions and 5645 deletions

View File

@ -3801,10 +3801,123 @@ type TEditer=class(TCustomcontrol) //
end end
//fo.SetStatusText(format("¹²Ìæ»»:%d ´¦",idx)); //fo.SetStatusText(format("¹²Ìæ»»:%d ´¦",idx));
end end
function matchword(f,d);
begin
wr := d["c_wrap"];
cw := d["c_case"];
tg := d["target"];
if not tg then return ;
ctl2 := "m";
if not d["c_reg"] then
begin
ntg := "";
ltg := length(tg);
for i := 1 to length(tg) do
begin
vi := tg[i];
cvi := ord(vi);
if cvi>=9 and cvi<=13 then
begin
ntg +="\\s";
if i=1 then wrp :=1;
if i=ltg then wrp .|= 2;
end else
if (cvi>=0x21 and cvi<=0x2f) or
(cvi>=0x3a and cvi<=0x40) or
(cvi>=0x5b and cvi<=0x60) or
(cvi>=0x7b and cvi<=0x7e) then
begin
ntg +="\\"+vi;
if i=1 then wrp :=1;
if i=ltg then wrp .|= 2;
end else
begin
ntg+=vi;
end
end
tg := ntg;
end
ctl := tg;
if wr then
begin
if not((wrp .& 1) >1) then ctl := "\\b"+ctl;
if not((wrp .& 2) >1) then ctl := ctl+"\\b";
end
if cw then ctl2 += "i";
linesi := array(1:1);
if (1 = readfile(rwraw(),"",f,0,filesize("",f),s)) and s then
begin
if 1= parseregexpr(ctl,s,ctl2,m,mp,mlen) then
begin
r := array();
idx := 1;
rid := 1;
jid := 1;
ip := 1;
if pos("\r\n",s) or pos("\n",s) then
begin
fgf := "\n";
end else
fgf := "\r";
for i,v in m do
begin
mi := mp[i,0];
while idx<mi do
begin
vi := s[idx];
idx++;
jid++;
if vi=fgf then
begin
linesi[rid]:=idx;
rid++;
jid := 1;
end
end
r[i][0] := rid; //ÐÐ
r[i][1] := jid; //ÁÐ
p1 := linesi[rid-1];
p2 := idx+mlen[i,0]-1;
if (p2>p1) and (rid<>orid) then
begin
r[i][2] := trim(s[p1:p2]);
end
else r[i,2] := "";
orid := rid;
end
return r;
end
end
end
function FindInFiles(d,o,rep,ct); function FindInFiles(d,o,rep,ct);
begin begin
fs := GetFilesFormSearchInfo(d); fs := GetFilesFormSearchInfo(d);
ct := 0; ct := 0;
if not rep then
begin
for i,v in fs do
begin
ri := matchword(i,d);
if ri then
begin
ril := length(ri);
FFindListWnd.AppendItem(array("caption":format("find:%s in file:%s has:%d",d["target"],i,ril)));
orii := -1;
for ii,vi in ri do
begin
rii := vi[0];
ct++;
if orii=rii then continue;
orii := rii;
scap := format(" %d:(µÚ%dÐÐ) ",ct,rii)+limitstringlength(vi[2]);
FFindListWnd.AppendItem(array("caption":scap,"file":i,"line":rii));
end
end
end
return ;
end
for i,v in fs do for i,v in fs do
begin begin
if not FIsFinding then break; if not FIsFinding then break;
@ -3967,7 +4080,10 @@ type TEditer=class(TCustomcontrol) //
end end
function FindAllInCurrent(data,fo,it,rt); function FindAllInCurrent(data,fo,it,rt);
begin begin
if rt = "noshow" then fnoshow := true; if rt = "noshow" then
begin
fnoshow := true;
end
rt := 0; rt := 0;
if not it then it := GetCurrentItem(); if not it then it := GetCurrentItem();
if not it then return; if not it then return;

View File

@ -222,6 +222,7 @@ type tapplication=class(tcomponent)
frundeep.Push(idledata); frundeep.Push(idledata);
r := _wapi.gtk_mainidle(idledata); r := _wapi.gtk_mainidle(idledata);
frundeep.pop(); frundeep.pop();
exitloopdo();
return r; return r;
{$endif} {$endif}
if not FMessageObj then FMessageObj := new TTagMSG(); if not FMessageObj then FMessageObj := new TTagMSG();
@ -259,6 +260,7 @@ type tapplication=class(tcomponent)
if FTerminated then break; if FTerminated then break;
end end
exitloopdo();
{while (_wapi.GetMessageA(ptr, 0, 0, 0)) do {while (_wapi.GetMessageA(ptr, 0, 0, 0)) do
begin begin
_wapi.TranslateMessage(ptr); _wapi.TranslateMessage(ptr);
@ -289,10 +291,40 @@ type tapplication=class(tcomponent)
begin begin
CloseMainForm(); CloseMainForm();
end end
function addExitMessageLoopdo(f);
begin
if f then
begin
if not fexitdolist then fexitdolist := new tnumindexarray();
fexitdolist.Push(f);
end
end
property Visible read FVisible write SetVisible; property Visible read FVisible write SetVisible;
property handle read FHandle; property handle read FHandle;
property IfDebug read FDebug write FDebug; property IfDebug read FDebug write FDebug;
property MainForm read Fmainform write SetMainForm; property MainForm read Fmainform write SetMainForm;
private
fexitdolist;
function exitloopdo();
begin
if fexitdolist then
begin
for i := 0 to fexitdolist.length()-1 do
begin
f := fexitdolist[i];
if f then
begin
try
//echo tostn(f.functioninfo());
##f();
except
end ;
end
end
end
fexitdolist := nil;
end
end end
type TLabel = class(TcustomLabel) type TLabel = class(TcustomLabel)

File diff suppressed because it is too large Load Diff

View File

@ -6712,7 +6712,35 @@ type tcustomprocess = class(tcomponent) //
@return(pointer) 句柄 %% @return(pointer) 句柄 %%
**} **}
if fprocesshandle then return 0; if fprocesshandle then return 0;
if not parserasexeclevparam(exe,cmd,e,arg,envp) then return 0; if fexecstr then
begin
if not(ifstring(e) and e) then return 0;
e := exe;
arg := cmd;
end else
begin
if not parserasexeclevparam(exe,cmd,e,arg,envp) then return 0;
end
//////////////处理linux启动路径/////////////////////
{$ifdef linux}
for i := length(e) downto 2 do
begin
if e[i]="/" then
begin
ph := e[1:i];
break;
end
end
envp := array();
if ph then
begin
//envp[length(envp)] := "LD_LIBRARY_PATH=LD_LIBRARY_PATH:"+ph;
envp[length(envp)] := "LD_LIBRARY_PATH="+ph;
end
//envp[length(envp)] := getgtkdisplay();
Sysexecsetenvs(envp,1);
{$endif}
///////////////////////////处理管道////////////////////////
Sysexecnewpipe(0); Sysexecnewpipe(0);
ferrinfo := nil; ferrinfo := nil;
hd := sysexec(e,arg,nil,false,code); hd := sysexec(e,arg,nil,false,code);
@ -6769,6 +6797,7 @@ type tcustomprocess = class(tcomponent) //
property OnEcho read FOnEcho write FOnEcho; property OnEcho read FOnEcho write FOnEcho;
property onstarted read fonprcstart write fonprcstart; property onstarted read fonprcstart write fonprcstart;
property onended read fonprocended write fonprocended; property onended read fonprocended write fonprocended;
property execstr read fexecstr write fexecstr;
{** {**
@param(OnEcho)(function[tcustomprocess,str]) 打印信息回调 %% @param(OnEcho)(function[tcustomprocess,str]) 打印信息回调 %%
@param(onstarted)(function[tcustomprocess,nil]) 启动回调 %% @param(onstarted)(function[tcustomprocess,nil]) 启动回调 %%
@ -6776,6 +6805,7 @@ type tcustomprocess = class(tcomponent) //
@param(handle)(pointer) 进程句柄 %% @param(handle)(pointer) 进程句柄 %%
**} **}
private //成员变量 private //成员变量
fexecstr;
ferrinfo; ferrinfo;
fprocesshandle; fprocesshandle;
weakref weakref
@ -6823,24 +6853,7 @@ type tcustomprocess = class(tcomponent) //
e := arg[0]; e := arg[0];
end end
if not(ifstring(e) and e) then return 0; if not(ifstring(e) and e) then return 0;
{$ifdef linux} //////////////将linux启动目录移入到上层,避免复杂的命令行参数////////////////
for i := length(e) downto 2 do
begin
if e[i]="/" then
begin
ph := e[1:i];
break;
end
end
envp := array();
if ph then
begin
//envp[length(envp)] := "LD_LIBRARY_PATH=LD_LIBRARY_PATH:"+ph;
envp[length(envp)] := "LD_LIBRARY_PATH="+ph;
end
//envp[length(envp)] := getgtkdisplay();
Sysexecsetenvs(envp,1);
{$endif}
return 1; return 1;
end end
{function getgtkdisplay(); {function getgtkdisplay();

View File

@ -70,6 +70,17 @@ type twindowsapi = class()
r := tslvclgetencoderclsid(n,ed); r := tslvclgetencoderclsid(n,ed);
return r; return r;
end; end;
function GetSystemDirectory(); //»ñµÃwindowssystemĿ¼
begin
s := "";
n := 1024;
setlength(s,n);
c := GetSystemDirectoryA(s,n);
if c>0 then
return s[1:c];
return "";
end
function GetSystemDirectoryA(var bf:string;sz:integer):integer;stdcall;external "Kernel32.dll" name "GetSystemDirectoryA";
function drawbitmaptodc(bm,hdc,x,y,rc,flag,thdc); function drawbitmaptodc(bm,hdc,x,y,rc,flag,thdc);
begin begin
oldmp := SelectObject(thdc,bm); oldmp := SelectObject(thdc,bm);