mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: Everything - stop search
This commit is contained in:
parent
a5ead39c74
commit
8a316d20d5
2 changed files with 33 additions and 18 deletions
|
|
@ -7,26 +7,34 @@ uses
|
|||
|
||||
var
|
||||
List: TFPList;
|
||||
|
||||
threadvar
|
||||
AddFileProc: TSAddFileProc;
|
||||
|
||||
procedure FoundCallback(FileName: PWideChar);
|
||||
procedure FoundCallback(FileName: PWideChar; UserData: Pointer);
|
||||
var
|
||||
S: String;
|
||||
FindData: TFindData absolute UserData;
|
||||
begin
|
||||
S:= CeUtf16ToUtf8(UnicodeString(FileName));
|
||||
AddFileProc(0, PAnsiChar(S));
|
||||
AddFileProc(FindData.PluginNumber, PAnsiChar(S));
|
||||
end;
|
||||
|
||||
function Init(dps: PDsxDefaultParamStruct; pAddFileProc: TSAddFileProc;
|
||||
pUpdateStatus: TSUpdateStatusProc): Integer; stdcall;
|
||||
var
|
||||
FindData: TFindData;
|
||||
begin
|
||||
AddFileProc:= pAddFileProc;
|
||||
FindData:= TFindData.Create;
|
||||
|
||||
if (List = nil) then List:= TFPList.Create;
|
||||
if (List = nil) then
|
||||
begin
|
||||
List:= TFPList.Create;
|
||||
AddFileProc:= pAddFileProc;
|
||||
end;
|
||||
|
||||
Result:= List.Add(pAddFileProc);
|
||||
Result:= List.Add(FindData);
|
||||
|
||||
FindData.PluginNumber:= Result;
|
||||
FindData.FoundCallback:= @FoundCallback;
|
||||
end;
|
||||
|
||||
procedure StartSearch(FPluginNr: Integer; pSearchRecRec: PDsxSearchRecord); stdcall;
|
||||
|
|
@ -34,12 +42,12 @@ var
|
|||
Flags: Integer = 0;
|
||||
begin
|
||||
if pSearchRecRec^.CaseSensitive then Flags:= Flags or EVERYTHING_IPC_MATCHCASE;
|
||||
Start(pSearchRecRec^.FileMask, Flags, @FoundCallback);
|
||||
Start(pSearchRecRec^.FileMask, Flags, TFindData(List[FPluginNr]));
|
||||
end;
|
||||
|
||||
procedure StopSearch(FPluginNr: Integer); stdcall;
|
||||
begin
|
||||
|
||||
TFindData(List[FPluginNr]).Cancel:= True;
|
||||
end;
|
||||
|
||||
procedure Finalize(FPluginNr: Integer); stdcall;
|
||||
|
|
@ -48,6 +56,7 @@ begin
|
|||
begin
|
||||
if FPluginNr < List.Count then
|
||||
begin
|
||||
TFindData(List[FPluginNr]).Free;
|
||||
List.Delete(FPluginNr);
|
||||
if (List.Count = 0) then FreeAndNil(List);
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -138,9 +138,13 @@ type
|
|||
{$pop}
|
||||
|
||||
type
|
||||
TFoundCallback = procedure(FileName: PWideChar);
|
||||
TFindData = class
|
||||
Cancel: Boolean;
|
||||
PluginNumber: Integer;
|
||||
FoundCallback: procedure(FileName: PWideChar; UserData: Pointer);
|
||||
end;
|
||||
|
||||
procedure Start(FileMask: String; Flags: Integer; pr: TFoundCallback);
|
||||
procedure Start(FileMask: String; Flags: Integer; FindData: TFindData);
|
||||
|
||||
implementation
|
||||
|
||||
|
|
@ -206,9 +210,9 @@ var
|
|||
I: DWORD = 0;
|
||||
Temp: UnicodeString;
|
||||
FileName: PWideChar;
|
||||
Callback: TFoundCallback;
|
||||
FindData: TFindData;
|
||||
Item: PEVERYTHING_IPC_ITEMW;
|
||||
dwOldLong: LONG_PTR absolute Callback;
|
||||
dwOldLong: LONG_PTR absolute FindData;
|
||||
begin
|
||||
dwOldLong:= GetWindowLongPtr(hWnd, GWL_USERDATA);
|
||||
|
||||
|
|
@ -226,10 +230,12 @@ begin
|
|||
FileName:= PWideChar(Temp);
|
||||
end;
|
||||
|
||||
Callback(FileName);
|
||||
if (FindData.Cancel) then Break;
|
||||
|
||||
FindData.FoundCallback(FileName, FindData);
|
||||
Inc(I);
|
||||
end;
|
||||
Callback(nil);
|
||||
FindData.FoundCallback(nil, FindData);
|
||||
PostMessage(hWnd, WM_CLOSE, 0, 0);
|
||||
end;
|
||||
|
||||
|
|
@ -254,10 +260,10 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure Start(FileMask: String; Flags: Integer; pr: TFoundCallback);
|
||||
procedure Start(FileMask: String; Flags: Integer; FindData: TFindData);
|
||||
var
|
||||
hWnd: Windows.HWND;
|
||||
dwNewLong: LONG_PTR absolute pr;
|
||||
dwNewLong: LONG_PTR absolute FindData;
|
||||
begin
|
||||
hWnd := CreateWindow(EVERYTHING_DSX_WNDCLASS,
|
||||
'', 0, 0, 0, 0, 0, 0, 0, HINSTANCE,nil);
|
||||
|
|
@ -271,7 +277,7 @@ begin
|
|||
|
||||
if not SendQuery(hWnd, EVERYTHING_IPC_ALLRESULTS, UnicodeString(FileMask), Flags) then
|
||||
begin
|
||||
pr(nil);
|
||||
FindData.FoundCallback(nil, FindData);
|
||||
PostMessage(hWnd, WM_CLOSE, 0, 0);
|
||||
end;
|
||||
end;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue