mirror of https://gitlab.com/basile.b/dexed.git
added search all to search & replace widget
This commit is contained in:
parent
ce9779d416
commit
fc24add7e3
|
@ -1,20 +1,20 @@
|
||||||
inherited CESearchWidget: TCESearchWidget
|
inherited CESearchWidget: TCESearchWidget
|
||||||
Left = 1486
|
Left = 742
|
||||||
Height = 243
|
Height = 282
|
||||||
Top = 327
|
Top = 278
|
||||||
Width = 394
|
Width = 394
|
||||||
Caption = 'Search & replace'
|
Caption = 'Search & replace'
|
||||||
ClientHeight = 243
|
ClientHeight = 282
|
||||||
ClientWidth = 394
|
ClientWidth = 394
|
||||||
inherited Back: TPanel
|
inherited Back: TPanel
|
||||||
Height = 243
|
Height = 282
|
||||||
Width = 394
|
Width = 394
|
||||||
ClientHeight = 243
|
ClientHeight = 282
|
||||||
ClientWidth = 394
|
ClientWidth = 394
|
||||||
inherited Content: TPanel
|
inherited Content: TPanel
|
||||||
Height = 243
|
Height = 282
|
||||||
Width = 394
|
Width = 394
|
||||||
ClientHeight = 243
|
ClientHeight = 282
|
||||||
ClientWidth = 394
|
ClientWidth = 394
|
||||||
object cbToFind: TComboBox[0]
|
object cbToFind: TComboBox[0]
|
||||||
Left = 4
|
Left = 4
|
||||||
|
@ -32,7 +32,7 @@ inherited CESearchWidget: TCESearchWidget
|
||||||
object btnFind: TBitBtn[1]
|
object btnFind: TBitBtn[1]
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 24
|
Height = 24
|
||||||
Top = 159
|
Top = 170
|
||||||
Width = 386
|
Width = 386
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BorderSpacing.Around = 4
|
BorderSpacing.Around = 4
|
||||||
|
@ -78,7 +78,7 @@ inherited CESearchWidget: TCESearchWidget
|
||||||
object btnReplace: TBitBtn[2]
|
object btnReplace: TBitBtn[2]
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 24
|
Height = 24
|
||||||
Top = 187
|
Top = 226
|
||||||
Width = 386
|
Width = 386
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BorderSpacing.Around = 4
|
BorderSpacing.Around = 4
|
||||||
|
@ -123,13 +123,13 @@ inherited CESearchWidget: TCESearchWidget
|
||||||
end
|
end
|
||||||
object grpOpts: TGroupBox[3]
|
object grpOpts: TGroupBox[3]
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 97
|
Height = 108
|
||||||
Top = 58
|
Top = 58
|
||||||
Width = 386
|
Width = 386
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BorderSpacing.Around = 4
|
BorderSpacing.Around = 4
|
||||||
Caption = 'Options'
|
Caption = 'Options'
|
||||||
ClientHeight = 67
|
ClientHeight = 78
|
||||||
ClientWidth = 382
|
ClientWidth = 382
|
||||||
TabOrder = 4
|
TabOrder = 4
|
||||||
object chkWWord: TCheckBox
|
object chkWWord: TCheckBox
|
||||||
|
@ -180,8 +180,8 @@ inherited CESearchWidget: TCESearchWidget
|
||||||
Left = 128
|
Left = 128
|
||||||
Height = 26
|
Height = 26
|
||||||
Top = 48
|
Top = 48
|
||||||
Width = 139
|
Width = 96
|
||||||
Caption = 'regular expression'
|
Caption = 'allow regex'
|
||||||
Checked = True
|
Checked = True
|
||||||
State = cbChecked
|
State = cbChecked
|
||||||
TabOrder = 5
|
TabOrder = 5
|
||||||
|
@ -190,7 +190,7 @@ inherited CESearchWidget: TCESearchWidget
|
||||||
object btnReplaceAll: TBitBtn[4]
|
object btnReplaceAll: TBitBtn[4]
|
||||||
Left = 4
|
Left = 4
|
||||||
Height = 24
|
Height = 24
|
||||||
Top = 215
|
Top = 254
|
||||||
Width = 386
|
Width = 386
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
BorderSpacing.Around = 4
|
BorderSpacing.Around = 4
|
||||||
|
@ -267,6 +267,52 @@ inherited CESearchWidget: TCESearchWidget
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object btnFindAll: TBitBtn[6]
|
||||||
|
Left = 4
|
||||||
|
Height = 24
|
||||||
|
Top = 198
|
||||||
|
Width = 386
|
||||||
|
Align = alBottom
|
||||||
|
BorderSpacing.Around = 4
|
||||||
|
Caption = 'btnFindAll'
|
||||||
|
Glyph.Data = {
|
||||||
|
36040000424D3604000000000000360000002800000010000000100000000100
|
||||||
|
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF003E39
|
||||||
|
34FF393430FF332F2BFF2C2925FF272421FF201D1BFF1716141A110F0EDB0B0A
|
||||||
|
09FF070706FF040403FF000000FF000000FFFFFFFF00FFFFFF00FFFFFF004641
|
||||||
|
3BFF857A70FFC3B8AEFF7C7268FF7F756BFF36322DFF1E1C190F282522D49589
|
||||||
|
7DFFBAAEA2FF7C7268FF7F756BFF010101FFFFFFFF00FFFFFF00FFFFFF004D47
|
||||||
|
41FF83786FFFCCC3BAFF786F65FF7B7167FF2F2B28F9272421011D1B18EE9589
|
||||||
|
7DFFC2B8ADFF786F65FF7C7268FF060505FFFFFFFF00FFFFFF00FFFFFF00534C
|
||||||
|
46FC83786FFFCCC3BAFF797066FF71685FFF37332ED5FFFFFF00252220D5857A
|
||||||
|
70FFC2B8ADFF786F65FF7B7167FF0A0908FCFFFFFF00FFFFFF00FFFFFF005A52
|
||||||
|
4CC39F9286FFCCC3BAFFC0B4AAFFA6988BFF3E3934A8FFFFFF002C2925A89084
|
||||||
|
79FFC2B8ADFFC0B4AAFFA89B8EFF110F0EC3FFFFFF00FFFFFF00797066055C55
|
||||||
|
4EF9423D38FF58514AFF3D3833FF332F2BFF23201DE5171614301E1C19B51A18
|
||||||
|
16FF252220FF191715FF0F0E0DFF010101EE00000002FFFFFF009F9286059D91
|
||||||
|
85FFB1A396FF7F756BFF7C7268FF776D64FF6C635BFF2E2A26FF564F48FF8076
|
||||||
|
6CFF7C7268FF776D64FF70675EFF000000FE00000005FFFFFF00AB9D9004AFA1
|
||||||
|
94E1BAAEA2FF82776DFF82776DFFAA917BFFBAA794FFB7A48EFAB09781FF9F8D
|
||||||
|
7DFF836D5BFF716357FF95897DFF040403E000000003FFFFFF00B9ACA008877D
|
||||||
|
72489B8E82FF9D9185FF867B71FF564F48FF504A44FF80766CFF6E665DFF826C
|
||||||
|
58FFA6917DFF948474FF564F48FF0C0B0B7A07070601FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00746B62FFA4978AFF95897DFF9F9286FF3E3934FFFFFFFF004C4640FF7E74
|
||||||
|
6AFF857A70FF3E3934FF453F3AA72522200C15131102FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF008E8378E2C3B8AEFF655D55FFFFFFFF007C7268FFA89B
|
||||||
|
8EFF9C8F83E4FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF009C8F83E2BCB0A4FF9D9185FFFFFFFF00AEA093FF9D91
|
||||||
|
85FF655D55DAFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||||
|
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
|
||||||
|
}
|
||||||
|
TabOrder = 6
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
inherited contextMenu: TPopupMenu
|
inherited contextMenu: TPopupMenu
|
||||||
|
|
|
@ -45,6 +45,7 @@ type
|
||||||
{ TCESearchWidget }
|
{ TCESearchWidget }
|
||||||
TCESearchWidget = class(TCEWidget, ICEMultiDocObserver)
|
TCESearchWidget = class(TCEWidget, ICEMultiDocObserver)
|
||||||
btnFind: TBitBtn;
|
btnFind: TBitBtn;
|
||||||
|
btnFindAll: TBitBtn;
|
||||||
btnReplace: TBitBtn;
|
btnReplace: TBitBtn;
|
||||||
btnReplaceAll: TBitBtn;
|
btnReplaceAll: TBitBtn;
|
||||||
cbToFind: TComboBox;
|
cbToFind: TComboBox;
|
||||||
|
@ -66,8 +67,10 @@ type
|
||||||
fDoc: TCESynMemo;
|
fDoc: TCESynMemo;
|
||||||
fToFind: string;
|
fToFind: string;
|
||||||
fReplaceWth: string;
|
fReplaceWth: string;
|
||||||
fActFindNext, fActReplaceNext: TAction;
|
fActReplaceNext: TAction;
|
||||||
|
fActFindNext: TAction;
|
||||||
fActReplaceAll: TAction;
|
fActReplaceAll: TAction;
|
||||||
|
fActFindAll: TAction;
|
||||||
fSearchMru, fReplaceMru: TCEMruList;
|
fSearchMru, fReplaceMru: TCEMruList;
|
||||||
fCancelAll: boolean;
|
fCancelAll: boolean;
|
||||||
fHasSearched: boolean;
|
fHasSearched: boolean;
|
||||||
|
@ -89,6 +92,7 @@ type
|
||||||
//
|
//
|
||||||
procedure actFindNextExecute(sender: TObject);
|
procedure actFindNextExecute(sender: TObject);
|
||||||
procedure actReplaceNextExecute(sender: TObject);
|
procedure actReplaceNextExecute(sender: TObject);
|
||||||
|
procedure actFindAllExecute(sender: TObject);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
@ -185,6 +189,9 @@ begin
|
||||||
fActFindNext := TAction.Create(self);
|
fActFindNext := TAction.Create(self);
|
||||||
fActFindNext.Caption := 'Find';
|
fActFindNext.Caption := 'Find';
|
||||||
fActFindNext.OnExecute := @actFindNextExecute;
|
fActFindNext.OnExecute := @actFindNextExecute;
|
||||||
|
fActFindAll := TAction.Create(self);
|
||||||
|
fActFindAll.Caption := 'Find all';
|
||||||
|
fActFindAll.OnExecute := @actFindAllExecute;
|
||||||
fActReplaceNext := TAction.Create(self);
|
fActReplaceNext := TAction.Create(self);
|
||||||
fActReplaceNext.Caption := 'Replace';
|
fActReplaceNext.Caption := 'Replace';
|
||||||
fActReplaceNext.OnExecute := @actReplaceNextExecute;
|
fActReplaceNext.OnExecute := @actReplaceNextExecute;
|
||||||
|
@ -207,6 +214,7 @@ begin
|
||||||
btnFind.Action := fActFindNext;
|
btnFind.Action := fActFindNext;
|
||||||
btnReplace.Action := fActReplaceNext;
|
btnReplace.Action := fActReplaceNext;
|
||||||
btnReplaceAll.Action := fActReplaceAll;
|
btnReplaceAll.Action := fActReplaceAll;
|
||||||
|
btnFindAll.Action := fActFindAll;
|
||||||
updateImperative;
|
updateImperative;
|
||||||
//
|
//
|
||||||
EntitiesConnector.addObserver(self);
|
EntitiesConnector.addObserver(self);
|
||||||
|
@ -262,6 +270,54 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCESearchWidget.actFindAllExecute(sender: TObject);
|
||||||
|
var
|
||||||
|
search: TSynEditSearch;
|
||||||
|
options: TSynSearchOptions;
|
||||||
|
start, stop: TPoint;
|
||||||
|
startf, stopf: TPoint;
|
||||||
|
msgs: ICEMessagesDisplay;
|
||||||
|
msg: string;
|
||||||
|
fmt: string;
|
||||||
|
i: integer;
|
||||||
|
res: array of TPoint = nil;
|
||||||
|
begin
|
||||||
|
if fDoc = nil then exit;
|
||||||
|
//
|
||||||
|
fSearchMru.Insert(0,fToFind);
|
||||||
|
cbToFind.Items.Assign(fSearchMru);
|
||||||
|
//
|
||||||
|
search := TSynEditSearch.Create;
|
||||||
|
try
|
||||||
|
options := getOptions;
|
||||||
|
search.Sensitive := ssoMatchCase in options;
|
||||||
|
search.Whole := ssoWholeWord in options;
|
||||||
|
search.RegularExpressions:= ssoRegExpr in options;
|
||||||
|
search.Pattern:=fToFind;
|
||||||
|
search.IdentChars:=fDoc.IdentChars;
|
||||||
|
start := Point(1,1);
|
||||||
|
stop := Point(high(integer), fDoc.Lines.Count);
|
||||||
|
while search.FindNextOne(fDoc.Lines, start, stop, startf, stopf) do
|
||||||
|
begin
|
||||||
|
setLength(res, length(res) + 1);
|
||||||
|
res[high(res)].X := startf.X;
|
||||||
|
res[high(res)].Y := startf.Y;
|
||||||
|
start := stopf;
|
||||||
|
end;
|
||||||
|
msgs := getMessageDisplay;
|
||||||
|
msg := format('%d result(s) for the pattern <%s>', [length(res), fToFind]);
|
||||||
|
msgs.message(msg, fDoc, amcEdit, amkInf);
|
||||||
|
fmt := fDoc.fileName + '(%d,%d): match %d';
|
||||||
|
for i := 0 to high(res) do
|
||||||
|
begin
|
||||||
|
msg := format(fmt, [res[i].Y, res[i].X, i]);
|
||||||
|
msgs.message(msg, fDoc, amcEdit, amkInf);
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
search.free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCESearchWidget.actFindNextExecute(sender: TObject);
|
procedure TCESearchWidget.actFindNextExecute(sender: TObject);
|
||||||
begin
|
begin
|
||||||
if fDoc = nil then exit;
|
if fDoc = nil then exit;
|
||||||
|
@ -408,6 +464,7 @@ end;
|
||||||
procedure TCESearchWidget.updateImperative;
|
procedure TCESearchWidget.updateImperative;
|
||||||
begin
|
begin
|
||||||
btnFind.Enabled := (fDoc <> nil) and (fToFind <> '');
|
btnFind.Enabled := (fDoc <> nil) and (fToFind <> '');
|
||||||
|
btnFindAll.Enabled := (fDoc <> nil) and (fToFind <> '');
|
||||||
btnReplace.Enabled := (fDoc <> nil) and (chkEnableRep.Checked) and (fToFind <> '');
|
btnReplace.Enabled := (fDoc <> nil) and (chkEnableRep.Checked) and (fToFind <> '');
|
||||||
btnReplaceAll.Enabled := btnReplace.Enabled;
|
btnReplaceAll.Enabled := btnReplace.Enabled;
|
||||||
cbReplaceWth.Enabled := (fDoc <> nil) and (chkEnableRep.Checked);
|
cbReplaceWth.Enabled := (fDoc <> nil) and (chkEnableRep.Checked);
|
||||||
|
|
Loading…
Reference in New Issue