mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-19 05:19:25 +02:00
IDE: find in files wnd: load history
This commit is contained in:
parent
b05acdb4f8
commit
fbb3adf777
@ -6,13 +6,14 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
Caption = 'Find in Files'
|
||||
ClientHeight = 476
|
||||
ClientWidth = 801
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '2.3.0.0'
|
||||
object CaseSensitiveSpeedButton: TSpeedButton
|
||||
AnchorSideTop.Control = FindCombobox
|
||||
AnchorSideTop.Control = TextToFindCombobox
|
||||
AnchorSideRight.Control = WholeWordsSpeedButton
|
||||
AnchorSideBottom.Control = FindCombobox
|
||||
AnchorSideBottom.Control = TextToFindCombobox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 686
|
||||
Height = 30
|
||||
@ -26,9 +27,9 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
ParentShowHint = False
|
||||
end
|
||||
object WholeWordsSpeedButton: TSpeedButton
|
||||
AnchorSideTop.Control = FindCombobox
|
||||
AnchorSideTop.Control = TextToFindCombobox
|
||||
AnchorSideRight.Control = RegularExpressionsSpeedButton
|
||||
AnchorSideBottom.Control = FindCombobox
|
||||
AnchorSideBottom.Control = TextToFindCombobox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 709
|
||||
Height = 30
|
||||
@ -42,9 +43,9 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
ParentShowHint = False
|
||||
end
|
||||
object RegularExpressionsSpeedButton: TSpeedButton
|
||||
AnchorSideTop.Control = FindCombobox
|
||||
AnchorSideTop.Control = TextToFindCombobox
|
||||
AnchorSideRight.Control = MultilineSpeedButton
|
||||
AnchorSideBottom.Control = FindCombobox
|
||||
AnchorSideBottom.Control = TextToFindCombobox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 732
|
||||
Height = 30
|
||||
@ -58,10 +59,10 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
ParentShowHint = False
|
||||
end
|
||||
object AutoUpdateSpeedButton: TSpeedButton
|
||||
AnchorSideTop.Control = FindCombobox
|
||||
AnchorSideTop.Control = TextToFindCombobox
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = FindCombobox
|
||||
AnchorSideBottom.Control = TextToFindCombobox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 778
|
||||
Height = 30
|
||||
@ -76,9 +77,9 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
ParentShowHint = False
|
||||
end
|
||||
object MultilineSpeedButton: TSpeedButton
|
||||
AnchorSideTop.Control = FindCombobox
|
||||
AnchorSideTop.Control = TextToFindCombobox
|
||||
AnchorSideRight.Control = AutoUpdateSpeedButton
|
||||
AnchorSideBottom.Control = FindCombobox
|
||||
AnchorSideBottom.Control = TextToFindCombobox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 755
|
||||
Height = 30
|
||||
@ -92,9 +93,9 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
ParentShowHint = False
|
||||
end
|
||||
object StoreAndNewSpeedButton: TSpeedButton
|
||||
AnchorSideTop.Control = FindCombobox
|
||||
AnchorSideTop.Control = TextToFindCombobox
|
||||
AnchorSideRight.Control = CaseSensitiveSpeedButton
|
||||
AnchorSideBottom.Control = FindCombobox
|
||||
AnchorSideBottom.Control = TextToFindCombobox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 663
|
||||
Height = 30
|
||||
@ -107,8 +108,8 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
end
|
||||
object ShowReplaceSpeedButton: TSpeedButton
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = FindCombobox
|
||||
AnchorSideBottom.Control = FindCombobox
|
||||
AnchorSideTop.Control = TextToFindCombobox
|
||||
AnchorSideBottom.Control = TextToFindCombobox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 30
|
||||
@ -120,7 +121,7 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
GroupIndex = 1
|
||||
OnClick = ShowReplaceSpeedButtonClick
|
||||
end
|
||||
object FindCombobox: TComboBox
|
||||
object TextToFindCombobox: TComboBox
|
||||
AnchorSideLeft.Control = ShowReplaceSpeedButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Owner
|
||||
@ -133,9 +134,9 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
ItemHeight = 0
|
||||
TabOrder = 0
|
||||
end
|
||||
object ReplaceComboBox: TComboBox
|
||||
AnchorSideLeft.Control = FindCombobox
|
||||
AnchorSideTop.Control = FindCombobox
|
||||
object ReplaceTextComboBox: TComboBox
|
||||
AnchorSideLeft.Control = TextToFindCombobox
|
||||
AnchorSideTop.Control = TextToFindCombobox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = ReplaceButton
|
||||
Left = 23
|
||||
@ -679,7 +680,7 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
end
|
||||
object WherePanel: TPanel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = ReplaceComboBox
|
||||
AnchorSideTop.Control = ReplaceTextComboBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
@ -694,7 +695,7 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
ClientHeight = 62
|
||||
ClientWidth = 801
|
||||
TabOrder = 4
|
||||
object DirsComboBox: TComboBox
|
||||
object DirectoriesComboBox: TComboBox
|
||||
AnchorSideLeft.Control = WherePanel
|
||||
AnchorSideTop.Control = FileMaskComboBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
@ -785,10 +786,10 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
Caption = '...'
|
||||
end
|
||||
object DirsEditSpeedButton: TSpeedButton
|
||||
AnchorSideTop.Control = DirsComboBox
|
||||
AnchorSideTop.Control = DirectoriesComboBox
|
||||
AnchorSideRight.Control = WherePanel
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = DirsComboBox
|
||||
AnchorSideBottom.Control = DirectoriesComboBox
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 778
|
||||
Height = 30
|
||||
@ -799,7 +800,7 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
end
|
||||
end
|
||||
object ReplaceButton: TButton
|
||||
AnchorSideTop.Control = ReplaceComboBox
|
||||
AnchorSideTop.Control = ReplaceTextComboBox
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 741
|
||||
@ -809,6 +810,7 @@ object LazFindInFilesWindow: TLazFindInFilesWindow
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
Caption = 'Replace'
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
Visible = False
|
||||
end
|
||||
|
@ -20,8 +20,9 @@ unit FindInFilesWnd;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, StdCtrls, Buttons, ComCtrls, ExtCtrls, SynEdit,
|
||||
DividerBevel, MenuIntf, IDEWindowIntf, LazIDEIntf;
|
||||
Classes, SysUtils, Forms, StdCtrls, Buttons, ComCtrls, ExtCtrls, DividerBevel,
|
||||
SynEdit, EnvironmentOpts, MenuIntf, IDEWindowIntf, LazIDEIntf, SrcEditorIntf,
|
||||
LazFileUtils, InputHistory, EditorOptions;
|
||||
|
||||
type
|
||||
|
||||
@ -30,10 +31,10 @@ type
|
||||
TLazFindInFilesWindow = class(TForm)
|
||||
CaseSensitiveSpeedButton: TSpeedButton;
|
||||
AutoUpdateSpeedButton: TSpeedButton;
|
||||
DirsComboBox: TComboBox;
|
||||
DirectoriesComboBox: TComboBox;
|
||||
DirsEditSpeedButton: TSpeedButton;
|
||||
FileMaskComboBox: TComboBox;
|
||||
FindCombobox: TComboBox;
|
||||
TextToFindCombobox: TComboBox;
|
||||
ShowReplaceSpeedButton: TSpeedButton;
|
||||
InEditorFilesSpeedButton: TSpeedButton;
|
||||
InProjectFilesSpeedButton1: TSpeedButton;
|
||||
@ -41,7 +42,7 @@ type
|
||||
ReplaceButton: TButton;
|
||||
WherePanel: TPanel;
|
||||
PkgComboBox: TComboBox;
|
||||
ReplaceComboBox: TComboBox;
|
||||
ReplaceTextComboBox: TComboBox;
|
||||
ResultsTreeView: TTreeView;
|
||||
SrcDividerBevel: TDividerBevel;
|
||||
StoreAndNewSpeedButton: TSpeedButton;
|
||||
@ -49,11 +50,16 @@ type
|
||||
MultilineSpeedButton: TSpeedButton;
|
||||
SynEdit1: TSynEdit;
|
||||
WholeWordsSpeedButton: TSpeedButton;
|
||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
procedure ShowReplaceSpeedButtonClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
private
|
||||
procedure InitImageList;
|
||||
protected
|
||||
procedure DoFirstShow; override;
|
||||
procedure InitImageList; virtual;
|
||||
procedure LoadHistory; virtual;
|
||||
procedure SaveHistory; virtual;
|
||||
public
|
||||
end;
|
||||
|
||||
@ -80,8 +86,11 @@ procedure RegisterFindInFilesWnd;
|
||||
var
|
||||
MenuCommand: TIDEMenuCommand;
|
||||
begin
|
||||
{$IFNDEF EnableFindInFilesWnd}
|
||||
exit;
|
||||
{$ENDIF}
|
||||
RegisterDummy:=TRegisterDummy.Create;
|
||||
MenuCommand:=RegisterIDEMenuCommand(itmSearchFindReplace,'FindInFilesWndItem','New Find In Files');
|
||||
MenuCommand:=RegisterIDEMenuCommand(itmSearchFindReplace,'FindInFilesWnd','New Find In Files');
|
||||
MenuCommand.OnClick:=@RegisterDummy.mnuFindInFilesWndClicked;
|
||||
end;
|
||||
|
||||
@ -102,7 +111,7 @@ end;
|
||||
procedure TLazFindInFilesWindow.FormCreate(Sender: TObject);
|
||||
begin
|
||||
ShowReplaceSpeedButton.Caption:='';
|
||||
FindCombobox.TextHint:='Find text';
|
||||
TextToFindCombobox.TextHint:='Find text';
|
||||
StoreAndNewSpeedButton.Hint:='Store results in search results window and start a new search';
|
||||
CaseSensitiveSpeedButton.Hint:='Case Sensitive';
|
||||
WholeWordsSpeedButton.Hint:='Whole words';
|
||||
@ -110,7 +119,7 @@ begin
|
||||
MultilineSpeedButton.Hint:='Multi line';
|
||||
AutoUpdateSpeedButton.Hint:='Start searching while you type';
|
||||
|
||||
ReplaceComboBox.TextHint:='Replace text';
|
||||
ReplaceTextComboBox.TextHint:='Replace text';
|
||||
ReplaceButton.Hint:='Replace all found matches';
|
||||
|
||||
FileMaskComboBox.TextHint:='*.pas;*.inc;*.txt;*.lfm';
|
||||
@ -119,8 +128,8 @@ begin
|
||||
PkgComboBox.TextHint:='lcl;lazutils';
|
||||
PkgComboBox.Text:='do not search in packages';
|
||||
|
||||
DirsComboBox.TextHint:='folder1;folder2';
|
||||
DirsComboBox.Text:='';
|
||||
DirectoriesComboBox.TextHint:='folder1;folder2';
|
||||
DirectoriesComboBox.Text:='';
|
||||
|
||||
SrcDividerBevel.Caption:='Preview';
|
||||
SynEdit1.Lines.Text:='No source selected';
|
||||
@ -134,10 +143,10 @@ begin
|
||||
try
|
||||
if ShowReplaceSpeedButton.Down then
|
||||
begin
|
||||
ReplaceComboBox.Visible:=true;
|
||||
ReplaceTextComboBox.Visible:=true;
|
||||
ReplaceButton.Visible:=true;
|
||||
end else begin
|
||||
ReplaceComboBox.Visible:=false;
|
||||
ReplaceTextComboBox.Visible:=false;
|
||||
ReplaceButton.Visible:=false;
|
||||
end;
|
||||
finally
|
||||
@ -145,16 +154,95 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLazFindInFilesWindow.FormClose(Sender: TObject;
|
||||
var CloseAction: TCloseAction);
|
||||
begin
|
||||
if CloseAction=caNone then ;
|
||||
SaveHistory;
|
||||
end;
|
||||
|
||||
procedure TLazFindInFilesWindow.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TLazFindInFilesWindow.DoFirstShow;
|
||||
begin
|
||||
LoadHistory;
|
||||
inherited DoFirstShow;
|
||||
end;
|
||||
|
||||
procedure TLazFindInFilesWindow.InitImageList;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TLazFindInFilesWindow.LoadHistory;
|
||||
|
||||
procedure AssignToComboBox(AComboBox: TComboBox; Strings: TStrings);
|
||||
begin
|
||||
AComboBox.Items.Assign(Strings);
|
||||
if AComboBox.Items.Count>0 then
|
||||
AComboBox.ItemIndex := 0;
|
||||
end;
|
||||
|
||||
procedure AddFileToComboBox(AComboBox: TComboBox; Filename: string);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if Filename='' then exit;
|
||||
Filename:=AppendPathDelim(TrimFilename(Filename));
|
||||
for i:=0 to AComboBox.Items.Count-1 do begin
|
||||
if CompareFilenames(Filename,AComboBox.Items[i])=0 then begin
|
||||
// move to front (but not top, top should be the last used directory)
|
||||
if i>2 then
|
||||
AComboBox.Items.Move(i,1);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
// insert in front (but not top, top should be the last used directory)
|
||||
if AComboBox.Items.Count>0 then
|
||||
i:=1
|
||||
else
|
||||
i:=0;
|
||||
AComboBox.Items.Insert(i,Filename);
|
||||
end;
|
||||
|
||||
var
|
||||
SrcEdit: TSourceEditorInterface;
|
||||
begin
|
||||
SrcEdit := SourceEditorManagerIntf.ActiveEditor;
|
||||
|
||||
TextToFindComboBox.Items.Assign(InputHistories.FindHistory);
|
||||
ReplaceTextComboBox.Items.Assign(InputHistories.ReplaceHistory);
|
||||
|
||||
if not EditorOpts.FindTextAtCursor then begin
|
||||
if TextToFindComboBox.Items.Count>0 then begin
|
||||
TextToFindComboBox.ItemIndex:=0;
|
||||
TextToFindComboBox.SelectAll;
|
||||
end;
|
||||
end;
|
||||
|
||||
// show recent directories and directory of current file
|
||||
AssignToComboBox(DirectoriesComboBox, InputHistories.FindInFilesPathHistory);
|
||||
if (SrcEdit<>nil) and (FilenameIsAbsolute(SrcEdit.FileName)) then
|
||||
AddFileToComboBox(DirectoriesComboBox, ExtractFilePath(SrcEdit.FileName));
|
||||
if DirectoriesComboBox.Items.Count>0 then
|
||||
DirectoriesComboBox.Text:=DirectoriesComboBox.Items[0];
|
||||
|
||||
// recent file masks
|
||||
FileMaskComboBox.DropDownCount:=EnvironmentOptions.DropDownCount;
|
||||
AssignToComboBox(FileMaskComboBox, InputHistories.FindInFilesMaskHistory);
|
||||
|
||||
// recent packages
|
||||
|
||||
end;
|
||||
|
||||
procedure TLazFindInFilesWindow.SaveHistory;
|
||||
begin
|
||||
InputHistories.AddToFindInFilesMaskHistory(FileMaskComboBox.Text);
|
||||
end;
|
||||
|
||||
finalization
|
||||
FreeAndNil(RegisterDummy);
|
||||
|
||||
|
@ -1042,9 +1042,7 @@ begin
|
||||
CreateMenuItem(ParentMI,itmSearchFindNext,'itmSearchFindNext',lisMenuFindNext, 'menu_search_find_next');
|
||||
CreateMenuItem(ParentMI,itmSearchFindPrevious,'itmSearchFindPrevious',lisMenuFindPrevious, 'menu_search_find_previous');
|
||||
CreateMenuItem(ParentMI,itmSearchFindInFiles,'itmSearchFindInFiles',lisMenuFindInFiles, 'menu_search_files');
|
||||
{$IFDEF EnableFindInFilesWnd}
|
||||
RegisterFindInFilesWnd;
|
||||
{$ENDIF}
|
||||
CreateMenuItem(ParentMI,itmSearchReplace, 'itmSearchReplace', lisBtnDlgReplace, 'menu_search_replace');
|
||||
CreateMenuItem(ParentMI,itmIncrementalFind,'itmIncrementalFind',lisMenuIncrementalFind, 'menu_search_incremental');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user