Skip to content

Commit

Permalink
Merge pull request Alexey-T#101 from springsunx/master
Browse files Browse the repository at this point in the history
Add Find/Replace and Enhanced right-click menu
  • Loading branch information
Alexey-T authored Jan 27, 2023
2 parents f070372 + df20ef1 commit 2b368a9
Show file tree
Hide file tree
Showing 6 changed files with 725 additions and 114 deletions.
9 changes: 8 additions & 1 deletion cudalister.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<PackageName Value="LCLBase"/>
</Item7>
</RequiredPackages>
<Units Count="6">
<Units Count="7">
<Unit0>
<Filename Value="cudalister.lpr"/>
<IsPartOfProject Value="True"/>
Expand Down Expand Up @@ -125,6 +125,13 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit5>
<Unit6>
<Filename Value="form_find.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="fmFind"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit6>
</Units>
</ProjectOptions>
<CompilerOptions>
Expand Down
58 changes: 29 additions & 29 deletions cudalister.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -170,32 +170,32 @@ function ListSendCommand(ListWin: HWND;
end;


function ListSearchTextW(ListWin: HWND;
SearchString: PWideChar;
SearchParameter: integer): integer; stdcall;
var
Form: TfmMain;
begin
Result:= LISTPLUGIN_OK;
Form:= TfmMain(FindControl(ListWin));
if Assigned(Form) then
Form.DoFind(
(SearchParameter and lcs_findfirst)=0,
(SearchParameter and lcs_backwards)<>0,
(SearchParameter and lcs_matchcase)<>0,
(SearchParameter and lcs_wholewords)<>0,
WideString(SearchString)
);
end;

function ListSearchText(ListWin: HWND;
SearchString: PChar;
SearchParameter: integer): integer; stdcall;
begin
Result:= ListSearchTextW(ListWin,
PWideChar(WideString(string(SearchString))),
SearchParameter);
end;
//function ListSearchTextW(ListWin: HWND;
// SearchString: PWideChar;
// SearchParameter: integer): integer; stdcall;
//var
// Form: TfmMain;
//begin
// Result:= LISTPLUGIN_OK;
// Form:= TfmMain(FindControl(ListWin));
// if Assigned(Form) then
// Form.DoFind(
// (SearchParameter and lcs_findfirst)=0,
// (SearchParameter and lcs_backwards)<>0,
// (SearchParameter and lcs_matchcase)<>0,
// (SearchParameter and lcs_wholewords)<>0,
// WideString(SearchString)
// );
//end;
//
//function ListSearchText(ListWin: HWND;
// SearchString: PChar;
// SearchParameter: integer): integer; stdcall;
//begin
// Result:= ListSearchTextW(ListWin,
// PWideChar(WideString(string(SearchString))),
// SearchParameter);
//end;


exports
Expand All @@ -206,9 +206,9 @@ function ListSearchText(ListWin: HWND;
ListLoadNext,
ListLoadNextW,
ListCloseWindow,
ListSendCommand,
ListSearchText,
ListSearchTextW;
ListSendCommand;
//ListSearchText,
//ListSearchTextW;

begin
Application.ShowHint:= false;
Expand Down
157 changes: 157 additions & 0 deletions form_find.lfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
object fmFind: TfmFind
Left = 446
Height = 350
Top = 397
Width = 734
BorderStyle = bsDialog
Caption = 'Find/Replace'
ClientHeight = 350
ClientWidth = 734
OnShow = FormShow
Position = poScreenCenter
LCLVersion = '2.2.4.0'
object bFind: TButton
Left = 564
Height = 38
Top = 72
Width = 148
Caption = 'Find'
ModalResult = 1
TabOrder = 10
end
object bCancel: TButton
Left = 564
Height = 38
Top = 216
Width = 148
Cancel = True
Caption = 'Cancel'
ModalResult = 2
TabOrder = 15
end
object Label1: TLabel
Left = 14
Height = 24
Top = 12
Width = 76
Caption = 'Find what:'
ParentColor = False
end
object edFind: TEdit
Left = 14
Height = 32
Top = 48
Width = 538
TabOrder = 0
end
object chkRegex: TCheckBox
Left = 14
Height = 28
Top = 192
Width = 118
Caption = 'Regex'
OnChange = chkRegexChange
TabOrder = 3
end
object chkBack: TCheckBox
Left = 14
Height = 28
Top = 300
Width = 100
Caption = 'Backward'
TabOrder = 6
end
object chkCase: TCheckBox
Left = 14
Height = 28
Top = 228
Width = 118
Caption = 'Case sensitive'
TabOrder = 4
end
object chkWords: TCheckBox
Left = 14
Height = 28
Top = 264
Width = 118
Caption = 'Whole words only'
TabOrder = 5
end
object edRep: TEdit
Left = 14
Height = 32
Top = 132
Width = 538
TabOrder = 2
end
object chkRep: TCheckBox
Left = 14
Height = 28
Top = 96
Width = 104
Caption = 'Replace with:'
OnChange = chkRepChange
TabOrder = 1
end
object bRep: TButton
Left = 564
Height = 38
Top = 24
Width = 148
Caption = 'Replace'
Default = True
ModalResult = 6
TabOrder = 11
end
object bRepAll: TButton
Left = 564
Height = 38
Top = 72
Width = 148
Caption = 'Replace all'
ModalResult = 10
TabOrder = 12
end
object chkFromCaret: TCheckBox
Left = 324
Height = 28
Top = 192
Width = 118
Caption = 'From caret'
TabOrder = 7
end
object bCount: TButton
Left = 564
Height = 38
Top = 120
Width = 148
Caption = 'Count all'
ModalResult = 5
TabOrder = 13
end
object chkConfirm: TCheckBox
Left = 324
Height = 28
Top = 228
Width = 100
Caption = 'Confirm replace'
TabOrder = 8
end
object bMarkAll: TButton
Left = 564
Height = 38
Top = 168
Width = 148
Caption = 'Mark all'
ModalResult = 4
TabOrder = 14
end
object chkInSel: TCheckBox
Left = 324
Height = 28
Top = 264
Width = 118
Caption = 'In selection'
TabOrder = 9
end
end
93 changes: 93 additions & 0 deletions form_find.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
unit form_find;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ButtonPanel,
StdCtrls;

type

{ TfmFind }

TfmFind = class(TForm)
bCount: TButton;
bMarkAll: TButton;
bFind: TButton;
bCancel: TButton;
bRep: TButton;
bRepAll: TButton;
chkInSel: TCheckBox;
chkFromCaret: TCheckBox;
chkConfirm: TCheckBox;
chkRep: TCheckBox;
chkRegex: TCheckBox;
chkBack: TCheckBox;
chkCase: TCheckBox;
chkWords: TCheckBox;
edFind: TEdit;
edRep: TEdit;
Label1: TLabel;
procedure chkRegexChange(Sender: TObject);
procedure chkRepChange(Sender: TObject);
procedure FormShow(Sender: TObject);
private
procedure Update; reintroduce;
{ private declarations }
public
{ public declarations }
end;

var
fmFind: TfmFind;

implementation

{$R *.lfm}

{ TfmFind }

procedure TfmFind.chkRegexChange(Sender: TObject);
begin
Update;
end;

procedure TfmFind.chkRepChange(Sender: TObject);
begin
Update;
end;

procedure TfmFind.FormShow(Sender: TObject);
begin
Update;
end;

procedure TfmFind.Update;
var
rep: boolean;
begin
rep:= chkRep.Checked;

chkWords.Enabled:= not chkRegex.Checked;
chkBack.Enabled:= not chkRegex.Checked;
chkConfirm.Enabled:= rep;
edRep.Enabled:= rep;
bFind.Visible:= not rep;
bRep.Visible:= rep;
bRepAll.Visible:= rep;

if rep then
Caption:= 'Replace'
else
Caption:= 'Find';

if rep then
bRep.Default:= true
else
bFind.Default:= true;
end;

end.

Loading

0 comments on commit 2b368a9

Please sign in to comment.