added option to set if regexes are handled

This commit is contained in:
Basile Burg 2015-02-24 07:10:45 +01:00
parent bfee995bd9
commit 0d4c216e27
2 changed files with 43 additions and 26 deletions

View File

@ -128,50 +128,62 @@ inherited CESearchWidget: TCESearchWidget
Align = alClient Align = alClient
BorderSpacing.Around = 4 BorderSpacing.Around = 4
Caption = 'Options' Caption = 'Options'
ClientHeight = 79 ClientHeight = 77
ClientWidth = 382 ClientWidth = 382
TabOrder = 3 TabOrder = 3
object chkWWord: TCheckBox object chkWWord: TCheckBox
Left = 8 Left = 8
Height = 19 Height = 21
Top = 0 Top = 0
Width = 82 Width = 84
Caption = 'whole word' Caption = 'whole word'
Checked = True
State = cbChecked
TabOrder = 0 TabOrder = 0
end end
object chkBack: TCheckBox object chkBack: TCheckBox
Left = 8 Left = 8
Height = 19 Height = 21
Top = 24 Top = 24
Width = 71 Width = 73
Caption = 'backward' Caption = 'backward'
TabOrder = 1 TabOrder = 2
end end
object chkFromCur: TCheckBox object chkFromCur: TCheckBox
Left = 8 Left = 8
Height = 19 Height = 21
Top = 48 Top = 48
Width = 82 Width = 84
Caption = 'from cursor' Caption = 'from cursor'
Checked = True Checked = True
State = cbChecked State = cbChecked
TabOrder = 2 TabOrder = 3
end end
object chkCaseSens: TCheckBox object chkCaseSens: TCheckBox
Left = 128 Left = 128
Height = 19 Height = 21
Top = 0 Top = 0
Width = 91 Width = 93
Caption = 'case sensitive' Caption = 'case sensitive'
TabOrder = 3 TabOrder = 4
end end
object chkPrompt: TCheckBox object chkPrompt: TCheckBox
Left = 128 Left = 128
Height = 19 Height = 21
Top = 24 Top = 24
Width = 60 Width = 62
Caption = 'prompt' Caption = 'prompt'
TabOrder = 4 TabOrder = 1
end
object chkRegex: TCheckBox
Left = 128
Height = 21
Top = 48
Width = 117
Caption = 'regular expression'
Checked = True
State = cbChecked
TabOrder = 5
end end
end end
object btnReplaceAll: TBitBtn[4] object btnReplaceAll: TBitBtn[4]
@ -232,25 +244,25 @@ inherited CESearchWidget: TCESearchWidget
ClientWidth = 386 ClientWidth = 386
TabOrder = 5 TabOrder = 5
object cbReplaceWth: TComboBox object cbReplaceWth: TComboBox
Left = 90 Left = 92
Height = 23 Height = 23
Top = 0 Top = 0
Width = 296 Width = 294
Align = alClient Align = alClient
Anchors = [akTop, akLeft, akBottom] Anchors = [akTop, akLeft, akBottom]
ItemHeight = 15 ItemHeight = 15
OnChange = cbReplaceWthChange OnChange = cbReplaceWthChange
TabOrder = 0 TabOrder = 1
end end
object chkEnableRep: TCheckBox object chkEnableRep: TCheckBox
Left = 0 Left = 0
Height = 23 Height = 23
Top = 0 Top = 0
Width = 90 Width = 92
Align = alLeft Align = alLeft
Caption = 'Replace with ' Caption = 'Replace with '
OnChange = chkEnableRepChange OnChange = chkEnableRepChange
TabOrder = 1 TabOrder = 0
end end
end end
end end

View File

@ -7,9 +7,12 @@ interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
Menus, StdCtrls, actnList, Buttons, SynEdit, SynEditSearch, SynEditTypes, ce_common, Menus, StdCtrls, actnList, Buttons, SynEdit, SynEditSearch, SynEditTypes, ce_common,
ce_widget, ce_synmemo, ce_interfaces, ce_observer; ce_widget, ce_synmemo, ce_interfaces, ce_observer, SynEditHighlighter;
type type
{ TCESearchWidget }
TCESearchWidget = class(TCEWidget, ICEMultiDocObserver) TCESearchWidget = class(TCEWidget, ICEMultiDocObserver)
btnFind: TBitBtn; btnFind: TBitBtn;
btnReplace: TBitBtn; btnReplace: TBitBtn;
@ -18,6 +21,7 @@ type
cbReplaceWth: TComboBox; cbReplaceWth: TComboBox;
chkEnableRep: TCheckBox; chkEnableRep: TCheckBox;
chkPrompt: TCheckBox; chkPrompt: TCheckBox;
chkRegex: TCheckBox;
chkWWord: TCheckBox; chkWWord: TCheckBox;
chkBack: TCheckBox; chkBack: TCheckBox;
chkFromCur: TCheckBox; chkFromCur: TCheckBox;
@ -156,11 +160,12 @@ end;
function TCESearchWidget.getOptions: TSynSearchOptions; function TCESearchWidget.getOptions: TSynSearchOptions;
begin begin
result := [ssoRegExpr]; result := [];
if chkWWord.Checked then result += [ssoWholeWord]; if chkRegex.Checked then result += [ssoRegExpr];
if chkBack.Checked then result += [ssoBackwards]; if chkWWord.Checked then result += [ssoWholeWord];
if chkCaseSens.Checked then result += [ssoMatchCase]; if chkBack.Checked then result += [ssoBackwards];
if chkPrompt.Checked then result += [ssoPrompt]; if chkCaseSens.Checked then result += [ssoMatchCase];
if chkPrompt.Checked then result += [ssoPrompt];
end; end;
function dlgReplaceAll: TModalResult; function dlgReplaceAll: TModalResult;