ADD: Viewer - search backwards from dialog

This commit is contained in:
Alexander Koblov 2021-03-01 17:51:09 +00:00
commit ca899d276f
4 changed files with 86 additions and 47 deletions

View file

@ -1,8 +1,8 @@
object frmFindView: TfrmFindView
Left = 365
Height = 121
Height = 151
Top = 311
Width = 344
Width = 430
HorzScrollBar.Page = 343
HorzScrollBar.Range = 103
VertScrollBar.Page = 96
@ -13,78 +13,83 @@ object frmFindView: TfrmFindView
BorderStyle = bsDialog
Caption = 'Find'
ChildSizing.TopBottomSpacing = 6
ClientHeight = 121
ClientWidth = 344
ClientHeight = 151
ClientWidth = 430
DesignTimePPI = 120
OnShow = FormShow
Position = poOwnerFormCenter
LCLVersion = '1.8.2.0'
LCLVersion = '2.0.12.0'
object cbDataToFind: TComboBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 26
Top = 12
Width = 328
Left = 10
Height = 28
Top = 15
Width = 410
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 12
BorderSpacing.Right = 8
Constraints.MinWidth = 328
ItemHeight = 18
BorderSpacing.Left = 10
BorderSpacing.Top = 15
BorderSpacing.Right = 10
Constraints.MinWidth = 410
ItemHeight = 20
OnKeyUp = cbDataToFindKeyUp
ParentFont = False
TabOrder = 0
end
object btnFind: TBitBtn
AnchorSideTop.Control = btnClose
AnchorSideRight.Control = btnClose
AnchorSideBottom.Side = asrBottom
Left = 150
Height = 29
Top = 80
Width = 90
Left = 188
Height = 30
Top = 114
Width = 112
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 6
BorderSpacing.Bottom = 4
BorderSpacing.Right = 8
BorderSpacing.Bottom = 5
Caption = '&Find'
Constraints.MinWidth = 90
Constraints.MinWidth = 112
Default = True
OnClick = btnFindClick
TabOrder = 3
ParentFont = False
TabOrder = 5
end
object btnClose: TBitBtn
AnchorSideTop.Control = cbCaseSens
AnchorSideTop.Control = cbBackwards
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 246
Height = 29
Top = 80
Width = 90
Left = 308
Height = 30
Top = 114
Width = 112
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Top = 12
BorderSpacing.Right = 8
BorderSpacing.Bottom = 4
BorderSpacing.Top = 15
BorderSpacing.Right = 10
BorderSpacing.Bottom = 5
Caption = '&Cancel'
Constraints.MinWidth = 90
Constraints.MinWidth = 112
Kind = bkCancel
ModalResult = 2
TabOrder = 4
ParentFont = False
TabOrder = 6
end
object cbCaseSens: TCheckBox
AnchorSideLeft.Control = cbDataToFind
AnchorSideTop.Control = cbDataToFind
AnchorSideTop.Side = asrBottom
Left = 8
Left = 10
Height = 24
Top = 44
Width = 111
BorderSpacing.Top = 6
Top = 51
Width = 115
BorderSpacing.Top = 8
Caption = 'C&ase sensitive'
ParentFont = False
TabOrder = 1
end
object chkHex: TCheckBox
@ -92,13 +97,14 @@ object frmFindView: TfrmFindView
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = cbCaseSens
AnchorSideTop.Side = asrCenter
Left = 131
Left = 140
Height = 24
Top = 44
Width = 104
BorderSpacing.Left = 12
Top = 51
Width = 111
BorderSpacing.Left = 15
Caption = 'Hexadecimal'
OnChange = chkHexChange
ParentFont = False
TabOrder = 2
end
object cbRegExp: TCheckBox
@ -106,12 +112,26 @@ object frmFindView: TfrmFindView
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = chkHex
AnchorSideTop.Side = asrCenter
Left = 8
Height = 19
Top = 90
Width = 144
BorderSpacing.Left = 8
Left = 261
Height = 24
Top = 51
Width = 155
BorderSpacing.Left = 10
Caption = '&Regular expressions'
OnChange = cbRegExpChange
ParentFont = False
TabOrder = 3
end
object cbBackwards: TCheckBox
AnchorSideLeft.Control = cbCaseSens
AnchorSideTop.Control = cbCaseSens
AnchorSideTop.Side = asrBottom
Left = 10
Height = 24
Top = 75
Width = 94
Caption = '&Backwards'
OnChange = cbBackwardsChange
TabOrder = 4
end
end

View file

@ -3,5 +3,7 @@
{"hash":2805828,"name":"tfrmfindview.btnfind.caption","sourcebytes":[38,70,105,110,100],"value":"&Find"},
{"hash":177752476,"name":"tfrmfindview.btnclose.caption","sourcebytes":[38,67,97,110,99,101,108],"value":"&Cancel"},
{"hash":219655237,"name":"tfrmfindview.cbcasesens.caption","sourcebytes":[67,38,97,115,101,32,115,101,110,115,105,116,105,118,101],"value":"C&ase sensitive"},
{"hash":183979276,"name":"tfrmfindview.chkhex.caption","sourcebytes":[72,101,120,97,100,101,99,105,109,97,108],"value":"Hexadecimal"}
{"hash":183979276,"name":"tfrmfindview.chkhex.caption","sourcebytes":[72,101,120,97,100,101,99,105,109,97,108],"value":"Hexadecimal"},
{"hash":8115171,"name":"tfrmfindview.cbregexp.caption","sourcebytes":[38,82,101,103,117,108,97,114,32,101,120,112,114,101,115,115,105,111,110,115],"value":"&Regular expressions"},
{"hash":170860739,"name":"tfrmfindview.cbbackwards.caption","sourcebytes":[38,66,97,99,107,119,97,114,100,115],"value":"&Backwards"}
]}

View file

@ -29,8 +29,11 @@ type
btnFind: TBitBtn;
btnClose: TBitBtn;
cbCaseSens: TCheckBox;
cbBackwards: TCheckBox;
chkHex: TCheckBox;
cbRegExp: TCheckBox;
procedure cbBackwardsChange(Sender: TObject);
procedure cbRegExpChange(Sender: TObject);
procedure chkHexChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btnFindClick(Sender: TObject);
@ -72,6 +75,16 @@ begin
cbCaseSens.Enabled:= not chkHex.Checked;
end;
procedure TfrmFindView.cbBackwardsChange(Sender: TObject);
begin
if cbBackwards.Checked then cbRegExp.Checked:= False
end;
procedure TfrmFindView.cbRegExpChange(Sender: TObject);
begin
if cbRegExp.Checked then cbBackwards.Checked:= False;
end;
procedure TfrmFindView.btnFindClick(Sender: TObject);
begin
InsertFirstItem(cbDataToFind.Text, cbDataToFind, GetTextSearchOptions);
@ -81,7 +94,6 @@ end;
procedure TfrmFindView.cbDataToFindKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if (Key = VK_Down) and (cbDataToFind.Items.Count > 0) then
cbDataToFind.DroppedDown:= True;
if Key = 13 then

View file

@ -2384,14 +2384,19 @@ begin
(TRegExprU.Available and (ViewerControl.Encoding in [veUtf8, veUtf8bom]))
);
if not FFindDialog.cbRegExp.Visible then FFindDialog.cbRegExp.Checked:= False;
if FFindDialog.cbRegExp.Checked then bSearchBackwards:= False;
FFindDialog.cbBackwards.Checked:= bSearchBackwards;
// Load search history
FFindDialog.cbDataToFind.Items.Assign(glsSearchHistory);
sSearchTextU:= ViewerControl.Selection;
if Length(sSearchTextU) > 0 then
FFindDialog.cbDataToFind.Text:= sSearchTextU;
if FFindDialog.ShowModal <> mrOK then Exit;
if FFindDialog.cbDataToFind.Text = '' then Exit;
sSearchTextU:= FFindDialog.cbDataToFind.Text;
bSearchBackwards:= FFindDialog.cbBackwards.Checked;
// Save search history
glsSearchHistory.Assign(FFindDialog.cbDataToFind.Items);
gFirstTextSearch:= False;