search & replace widg, add visual feedback will typing in the input field

This commit is contained in:
Basile Burg 2024-01-21 20:51:08 +01:00
parent 58332062d1
commit f349dee6a4
6 changed files with 87 additions and 70 deletions

View File

@ -1,5 +1,9 @@
# v3.9.27-devel
## Enhancements
- Search & Replace, add visual feedback in the editor.
## Bugs fixed
- Mini-explorer, clearing the filter had for effect to scan the root folder instead of the selected one. (#129)

View File

@ -2965,7 +2965,7 @@ begin
if fDoc.SelAvail then
str := fDoc.SelText
else
str := fDoc.Identifier;
str := fDoc.HighlightedIdent;
ffindwidg.cbToFind.Text := str;
ffindwidg.cbToFindChange(nil);
ffindwidg.cbToFind.SetFocus;

View File

@ -8,12 +8,13 @@ inherited SearchWidget: TSearchWidget
ClientWidth = 422
inherited Content: TPanel
Height = 293
Top = 36
Width = 422
ClientHeight = 293
ClientWidth = 422
object cbToFind: TComboBox[0]
Left = 4
Height = 27
Height = 30
Top = 4
Width = 414
Align = alTop
@ -22,15 +23,15 @@ inherited SearchWidget: TSearchWidget
BorderSpacing.Around = 4
ItemHeight = 0
MaxLength = 128
TabOrder = 0
OnChange = cbToFindChange
OnKeyDown = cbToFindKeyDown
OnSelect = cbToFindChange
TabOrder = 0
end
object btnFind: TBitBtn[1]
Left = 4
Height = 27
Top = 169
Height = 32
Top = 149
Width = 414
Align = alBottom
AutoSize = True
@ -40,8 +41,8 @@ inherited SearchWidget: TSearchWidget
end
object btnReplace: TBitBtn[2]
Left = 4
Height = 27
Top = 231
Height = 32
Top = 221
Width = 414
Align = alBottom
AutoSize = True
@ -51,50 +52,50 @@ inherited SearchWidget: TSearchWidget
end
object grpOpts: TGroupBox[3]
Left = 4
Height = 99
Top = 66
Height = 73
Top = 72
Width = 414
Align = alClient
AutoSize = True
BorderSpacing.Around = 4
Caption = 'Options'
ClientHeight = 80
ClientWidth = 410
ClientHeight = 54
ClientWidth = 412
TabOrder = 4
object FlowPanel1: TFlowPanel
Left = 0
Height = 80
Height = 54
Top = 0
Width = 410
Width = 412
Align = alClient
AutoSize = True
BevelOuter = bvNone
ControlList = <
ControlList = <
item
Control = chkRegex
WrapAfter = waAuto
Index = 0
end
end
item
Control = chkPrompt
WrapAfter = waAuto
Index = 1
end
end
item
Control = chkCaseSens
WrapAfter = waAuto
Index = 2
end
end
item
Control = chkFromCur
WrapAfter = waAuto
Index = 3
end
end
item
Control = chkBack
WrapAfter = waAuto
Index = 4
end
end
item
Control = chkWWord
WrapAfter = waAuto
@ -105,9 +106,9 @@ inherited SearchWidget: TSearchWidget
TabOrder = 0
object chkRegex: TCheckBox
Left = 0
Height = 22
Height = 23
Top = 0
Width = 100
Width = 94
Anchors = []
Caption = 'allow regex'
Checked = True
@ -116,27 +117,27 @@ inherited SearchWidget: TSearchWidget
end
object chkPrompt: TCheckBox
Left = 0
Height = 22
Top = 23
Width = 71
Height = 23
Top = 24
Width = 72
Anchors = []
Caption = 'prompt'
TabOrder = 1
end
object chkCaseSens: TCheckBox
Left = 0
Height = 22
Top = 46
Width = 117
Left = 94
Height = 23
Top = 0
Width = 107
Anchors = []
Caption = 'case sensitive'
TabOrder = 2
end
object chkFromCur: TCheckBox
Left = 117
Height = 22
Top = 0
Width = 99
Left = 94
Height = 23
Top = 24
Width = 96
Anchors = []
Caption = 'from cursor'
Checked = True
@ -144,19 +145,19 @@ inherited SearchWidget: TSearchWidget
TabOrder = 3
end
object chkBack: TCheckBox
Left = 117
Height = 22
Top = 23
Width = 87
Left = 201
Height = 23
Top = 0
Width = 84
Anchors = []
Caption = 'backward'
TabOrder = 4
end
object chkWWord: TCheckBox
Left = 117
Height = 22
Top = 46
Width = 99
Left = 201
Height = 23
Top = 24
Width = 96
Anchors = []
Caption = 'whole word'
Checked = True
@ -167,8 +168,8 @@ inherited SearchWidget: TSearchWidget
end
object btnReplaceAll: TBitBtn[4]
Left = 4
Height = 27
Top = 262
Height = 32
Top = 257
Width = 414
Align = alBottom
AutoSize = True
@ -178,69 +179,69 @@ inherited SearchWidget: TSearchWidget
end
object Panel1: TPanel[5]
Left = 4
Height = 27
Top = 35
Height = 30
Top = 38
Width = 414
Align = alTop
AutoSize = True
BorderSpacing.Around = 4
BevelOuter = bvNone
ClientHeight = 27
ClientHeight = 30
ClientWidth = 414
TabOrder = 5
object cbReplaceWth: TComboBox
Left = 111
Height = 27
Left = 104
Height = 30
Top = 0
Width = 303
Width = 310
Align = alClient
AutoComplete = True
AutoCompleteText = [cbactEnabled, cbactEndOfLineComplete, cbactSearchCaseSensitive, cbactSearchAscending]
ItemHeight = 0
MaxLength = 128
TabOrder = 1
OnChange = cbReplaceWthChange
OnKeyDown = cbReplaceWthKeyDown
OnSelect = cbReplaceWthChange
TabOrder = 1
end
object chkEnableRep: TCheckBox
Left = 0
Height = 27
Height = 30
Top = 0
Width = 111
Width = 104
Align = alLeft
Caption = 'Replace with '
OnChange = chkEnableRepChange
TabOrder = 0
OnChange = chkEnableRepChange
end
end
object Panel2: TPanel[6]
Left = 4
Height = 27
Top = 200
Height = 32
Top = 185
Width = 414
Align = alBottom
AutoSize = True
BorderSpacing.Around = 4
BevelOuter = bvNone
ClientHeight = 27
ClientHeight = 32
ClientWidth = 414
TabOrder = 6
object btnFindAll: TBitBtn
Left = 0
Height = 27
Height = 32
Top = 0
Width = 402
Width = 398
Align = alClient
AutoSize = True
Caption = 'btnFindAll'
TabOrder = 0
end
object btnAllScope: TBitBtn
Left = 404
Height = 27
Left = 400
Height = 32
Top = 0
Width = 10
Width = 14
Align = alRight
AutoSize = True
BorderSpacing.Left = 2
@ -256,7 +257,7 @@ inherited SearchWidget: TSearchWidget
Left = 216
Top = 16
end
object imgList: TImageList[2]
object imgList: TImageList[3]
Left = 248
Top = 16
Bitmap = {

View File

@ -762,6 +762,8 @@ begin
fToFind := cbToFind.Text;
fHasSearched := false;
updateImperative;
if fDoc.isAssigned and (not chkRegex.Checked) then
fDoc.HighlightedIdent := fToFind;
end;
procedure TSearchWidget.cbToFindKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);

View File

@ -209,8 +209,8 @@ begin
fSymbols[CFF] := fDoc.fileName;
fSymbols[CFR] := fSymbols[CFF].stripFileExt + exeExt;
fSymbols[CFP] := fSymbols[CFF].extractFilePath;
if fDoc.Identifier.isNotEmpty then
fSymbols[CI] := fDoc.Identifier;
if fDoc.HighlightedIdent.isNotEmpty then
fSymbols[CI] := fDoc.HighlightedIdent;
fSymbols[CL] := fDoc.LineText;
fSymbols[CS] := fDoc.SelText;
end;

View File

@ -201,7 +201,7 @@ type
fCacheLoaded: boolean;
fIsDSource: boolean;
fFocusForInput: boolean;
fIdentifier: string;
fHighlightedIdent: string;
fTempFileName: string;
fMultiDocSubject: TObject;
fDefaultFontSize: Integer;
@ -267,7 +267,7 @@ type
procedure setMatchOpts(value: TIdentifierMatchOptions);
function getMouseBytePosition: Integer;
procedure changeNotify(Sender: TObject);
procedure highlightCurrentIdentifier;
procedure highlightCurrentIdentifier(fromEditor: boolean = true);
procedure saveCache;
procedure loadCache;
class procedure cleanCache; static;
@ -321,6 +321,7 @@ type
procedure debugBreak(const fname: string; line: integer; reason: TDebugBreakReason);
function breakPointsCount: integer;
procedure tryToPatchMixedIndentation;
procedure setHighligthedIdent(value: string);
protected
procedure DoEnter; override;
procedure DoExit; override;
@ -388,7 +389,7 @@ type
procedure scrollCentered(down: boolean);
//
property IdentifierMatchOptions: TIdentifierMatchOptions read fMatchOpts write setMatchOpts;
property Identifier: string read fIdentifier;
property HighlightedIdent: string read fHighlightedIdent write setHighligthedIdent;
property fileName: string read fFilename;
property modified: boolean read fModified;
property tempFilename: string read fTempFileName;
@ -3372,14 +3373,23 @@ begin
fIsDSource := Highlighter = fD2Highlighter;
end;
procedure TDexedMemo.highlightCurrentIdentifier;
procedure TDexedMemo.setHighligthedIdent(value: string);
begin
if fHighlightedIdent = value then
exit;
fHighlightedIdent := value;
highlightCurrentIdentifier(false);
end;
procedure TDexedMemo.highlightCurrentIdentifier(fromEditor: boolean = true);
var
s: string;
i: integer;
begin
fIdentifier := GetWordAtRowCol(LogicalCaretXY);
if (fIdentifier.length > 2) and (not SelAvail) then
SetHighlightSearch(fIdentifier, fMatchIdentOpts)
if fromEditor then
fHighlightedIdent := GetWordAtRowCol(LogicalCaretXY);
if (fHighlightedIdent.length > 2) and (not SelAvail) then
SetHighlightSearch(fHighlightedIdent, fMatchIdentOpts)
else if SelAvail and (BlockBegin.Y = BlockEnd.Y) then
begin
s := SelText;