Skip to content

Commit

Permalink
Text search hit offsets and count now recorded and saved to log file.…
Browse files Browse the repository at this point in the history
… Yet to add for hex searches. Progress labelling renamed.
  • Loading branch information
tedsmith committed Oct 31, 2015
1 parent d417126 commit 52c0a01
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 429 deletions.
19 changes: 5 additions & 14 deletions TextSearch/textsearch.lfm
Expand Up @@ -7,15 +7,6 @@ object frmTextSearch: TfrmTextSearch
ClientHeight = 390
ClientWidth = 320
LCLVersion = '1.4.4.0'
object btnDontUse: TButton
Left = 16
Height = 25
Top = 288
Width = 75
Caption = 'dont use'
OnClick = btnDontUseClick
TabOrder = 0
end
object Memo1: TMemo
Left = 22
Height = 178
Expand All @@ -28,15 +19,15 @@ object frmTextSearch: TfrmTextSearch
)
OnEnter = Memo1Enter
ScrollBars = ssAutoBoth
TabOrder = 1
TabOrder = 0
end
object cbMatchCase: TCheckBox
Left = 22
Height = 17
Top = 248
Width = 79
Caption = 'Match case?'
TabOrder = 2
TabOrder = 1
end
object cbHexSearch: TCheckBox
Left = 205
Expand All @@ -45,7 +36,7 @@ object frmTextSearch: TfrmTextSearch
Width = 80
Caption = 'Hex Search?'
OnClick = cbHexSearchClick
TabOrder = 3
TabOrder = 2
end
object btnTextSearchCancel: TButton
Left = 176
Expand All @@ -54,7 +45,7 @@ object frmTextSearch: TfrmTextSearch
Width = 75
Caption = 'Cancel'
OnClick = btnTextSearchCancelClick
TabOrder = 4
TabOrder = 3
end
object btnTextSearchOK: TButton
Left = 72
Expand All @@ -63,7 +54,7 @@ object frmTextSearch: TfrmTextSearch
Width = 75
Caption = 'OK'
OnClick = btnTextSearchOKClick
TabOrder = 5
TabOrder = 4
end
object OpenDialog1: TOpenDialog
left = 264
Expand Down
65 changes: 34 additions & 31 deletions TextSearch/textsearch.pas
Expand Up @@ -15,7 +15,6 @@ interface
{ TfrmTextSearch }

TfrmTextSearch = class(TForm)
btnDontUse: TButton;
btnTextSearchCancel: TButton;
btnTextSearchOK: TButton;
cbMatchCase: TCheckBox;
Expand All @@ -24,7 +23,6 @@ TfrmTextSearch = class(TForm)
OpenDialog1: TOpenDialog;
procedure btnTextSearchCancelClick(Sender: TObject);
procedure btnTextSearchOKClick(Sender: TObject);
procedure btnDontUseClick(Sender: TObject);
procedure cbHexSearchClick(Sender: TObject);
procedure Memo1Enter(Sender: TObject);
private
Expand Down Expand Up @@ -84,6 +82,7 @@ procedure TfrmTextSearch.btnTextSearchOKClick(Sender: TObject);
frmYaffi.toggleSearchMode.State := cbChecked;
frmYaffi.toggleSearchMode.Enabled := true;
frmYaffi.toggleSearchMode.Caption := 'Search Mode: ON';
ShowMessage('Search hit data will be saved to ' + (frmYaffi.SaveImageDialog.FileName + '_SearchHits.txt'));
// And now hide the form and return user to YAFFI interface
frmTextSearch.Hide;
end;
Expand Down Expand Up @@ -209,6 +208,38 @@ function InsensPosEx(const SubStr, S: string; Offset: Integer = 1): Integer;
result := 0;
end;

// Uncheck and disable the case sensitivity tick box if hex search chosen
procedure TfrmTextSearch.cbHexSearchClick(Sender: TObject);
begin
if cbHexSearch.Checked then
begin
cbMatchCase.Checked := false;
cbMatchCase.Enabled := false;
end;

if not cbHexSearch.Checked then
begin
cbMatchCase.Enabled := true;
end;
end;

procedure TfrmTextSearch.Memo1Enter(Sender: TObject);
begin
Memo1.Clear;
end;


initialization
// Used to initialise the upper case table as used by InsensPosEx
// http://stackoverflow.com/a/1554544
InitCharUpCaseTable(CharUpCaseTable);

end.

{ Old code, initially developed just to see how best to parse. Keep for a bit
just in case its helpful }

{
procedure TfrmTextSearch.btnDontUseClick(Sender: TObject);
var
fs : TFileStream;
Expand Down Expand Up @@ -294,32 +325,4 @@ procedure TfrmTextSearch.btnDontUseClick(Sender: TObject);
ShowMessage(IntToStr(TotalBytesRead) + ' read. Done');
fs.Free;
end;

// Uncheck and disable the case sensitivity tick box if hex search chosen
procedure TfrmTextSearch.cbHexSearchClick(Sender: TObject);
begin
if cbHexSearch.Checked then
begin
cbMatchCase.Checked := false;
cbMatchCase.Enabled := false;
end;

if not cbHexSearch.Checked then
begin
cbMatchCase.Enabled := true;
end;
end;

procedure TfrmTextSearch.Memo1Enter(Sender: TObject);
begin
Memo1.Clear;
end;


initialization
// Used to initialise the upper case table as used by InsensPosEx
// http://stackoverflow.com/a/1554544
InitCharUpCaseTable(CharUpCaseTable);

end.

}
49 changes: 0 additions & 49 deletions TextSearch/unit1.lfm

This file was deleted.

183 changes: 0 additions & 183 deletions TextSearch/unit1.pas

This file was deleted.

0 comments on commit 52c0a01

Please sign in to comment.